Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
isp:contrast [2023/09/06 08:56] – [In RGB color space] Igor Yefmov | isp:contrast [2023/09/06 10:35] – [In RGB color space] Igor Yefmov | ||
---|---|---|---|
Line 20: | Line 20: | ||
\[ | \[ | ||
- | component = (component' | + | component = (component' |
component' | component' | ||
contrast \in ]0..2.0]%% | contrast \in ]0..2.0]%% | ||
Line 29: | Line 29: | ||
\[ | \[ | ||
\begin{bmatrix} | \begin{bmatrix} | ||
- | R - 0.5 * 0.2126 | + | R - 0.5 \\ |
- | G - 0.5 * 0.7152 | + | G - 0.5 \\ |
- | B - 0.5 * 0.0722 | + | B - 0.5 |
- | \end{bmatrix} \times contrast^2 | + | |
- | + | + | |
- | \begin{bmatrix} | + | |
- | 0.5 * 0.2126 \\ | + | |
- | 0.5 * 0.7152 \\ | + | |
- | 0.5 * 0.0722 | + | |
\end{bmatrix} | \end{bmatrix} | ||
- | \] | + | \times |
- | + | ||
- | which easily simplifies to | + | |
- | + | ||
- | \[ | + | |
\begin{bmatrix} | \begin{bmatrix} | ||
- | R - 0.1063 \\ | + | 0.2126^2 & 0 & 0 \\ |
- | G - 0.3576 \\ | + | 0 & 0.7152^2 & 0 \\ |
- | B - 0.0361 | + | 0 & 0 & 0.0722^2 |
\end{bmatrix} \times contrast^2 | \end{bmatrix} \times contrast^2 | ||
+ | + | ||
\begin{bmatrix} | \begin{bmatrix} | ||
- | 0.1063 \\ | + | 0.5 \\ |
- | 0.3576 \\ | + | 0.5 \\ |
- | 0.0361 | + | 0.5 |
\end{bmatrix} | \end{bmatrix} | ||
\] | \] | ||
- | Of course, much like in [[isp:: | + | ==== Integer arithmetic ==== |
+ | Of course, much like in [[isp:: | ||
\[ | \[ | ||
Line 65: | Line 56: | ||
G \\ | G \\ | ||
B | B | ||
- | \end{bmatrix} | + | \end{bmatrix} |
- | - | ||
\begin{bmatrix} | \begin{bmatrix} | ||
- | 109 \\ | + | 2047 \\ |
- | 366 \\ | + | 2047 \\ |
- | 37 | + | 2047 |
\end{bmatrix} \right) | \end{bmatrix} \right) | ||
- | | ||
\begin{bmatrix} | \begin{bmatrix} | ||
- | 109 \\ | + | 47394 & 0 & 0 \\ |
- | 366 \\ | + | 0 & 536358 & 0 \\ |
- | 37 | + | 0 & 0 & 5466 |
- | \end{bmatrix} | + | \end{bmatrix} |
- | }{1024} | + | }{1024*1024*1024*1024} + |
- | \] | + | \begin{bmatrix} |
+ | 2047 \\ | ||
+ | 2047 \\ | ||
+ | 2047 | ||
+ | \end{bmatrix} \\ | ||
- | N.B. In the above calculations the range for \(R, G, B\) values is \([0..1.0]\), so keep that in mind when using a different scale. | + | R, G, B \in [0..4095] \\ |
- | + | contrast \in [0..2047] | |
- | For the 12-bit pixel components the values are scaled by 4095, making all this look like the following: | + | |
- | + | ||
- | \[ | + | |
- | \left(\begin{bmatrix} | + | |
- | R \\ | + | |
- | G \\ | + | |
- | B | + | |
- | \end{bmatrix} | + | |
- | - | + | |
- | \begin{bmatrix} | + | |
- | 871 \\ | + | |
- | 2929 \\ | + | |
- | 296 | + | |
- | \end{bmatrix} \right) | + | |
- | | + | |
- | \begin{bmatrix} | + | |
- | 871 \\ | + | |
- | 2929 \\ | + | |
- | 296 | + | |
- | \end{bmatrix} | + | |
\] | \] | ||
- | |||
===== In HSL color space ===== | ===== In HSL color space ===== |