Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
isp:contrast [2023/09/06 08:56] – [In RGB color space] Igor Yefmov | isp:contrast [2023/09/10 21:53] (current) – [Integer arithmetic] Igor Yefmov | ||
---|---|---|---|
Line 7: | Line 7: | ||
===== In RGB color space ===== | ===== In RGB color space ===== | ||
- | As with the [[isp:: | ||
- | Traditionally | + | Each component' |
\[ | \[ | ||
- | lum = 0.2126 * R + 0.7152 * G + 0.0722 * B | + | component = (component' |
- | \] | + | |
- | + | ||
- | + | ||
- | + | ||
- | With that in mind each component' | + | |
- | + | ||
- | \[ | + | |
- | component = (component' | + | |
component' | component' | ||
contrast \in ]0..2.0]%% | contrast \in ]0..2.0]%% | ||
\] | \] | ||
- | which looks like this: | ||
- | \[ | + | ==== Integer arithmetic ==== |
- | \begin{bmatrix} | + | Of course, much like in [[isp:: |
- | R - 0.5 * 0.2126 \\ | + | |
- | G - 0.5 * 0.7152 \\ | + | |
- | B - 0.5 * 0.0722 | + | |
- | \end{bmatrix} \times contrast^2 | + | |
- | + | + | |
- | \begin{bmatrix} | + | |
- | 0.5 * 0.2126 \\ | + | |
- | 0.5 * 0.7152 \\ | + | |
- | 0.5 * 0.0722 | + | |
- | \end{bmatrix} | + | |
- | \] | + | |
- | + | ||
- | which easily simplifies to | + | |
- | + | ||
- | \[ | + | |
- | \begin{bmatrix} | + | |
- | R - 0.1063 \\ | + | |
- | G - 0.3576 \\ | + | |
- | B - 0.0361 | + | |
- | \end{bmatrix} \times contrast^2 | + | |
- | + | + | |
- | \begin{bmatrix} | + | |
- | 0.1063 \\ | + | |
- | 0.3576 \\ | + | |
- | 0.0361 | + | |
- | \end{bmatrix} | + | |
- | \] | + | |
- | + | ||
- | Of course, much like in [[isp:: | + | |
\[ | \[ | ||
\frac{ | \frac{ | ||
- | \left(\begin{bmatrix} | ||
- | R \\ | ||
- | G \\ | ||
- | B | ||
- | \end{bmatrix} \times 1024 | ||
- | - | ||
- | \begin{bmatrix} | ||
- | 109 \\ | ||
- | 366 \\ | ||
- | 37 | ||
- | \end{bmatrix} \right) | ||
- | | ||
- | \begin{bmatrix} | ||
- | 109 \\ | ||
- | 366 \\ | ||
- | 37 | ||
- | \end{bmatrix} | ||
- | }{1024} | ||
- | \] | ||
- | |||
- | N.B. In the above calculations the range for \(R, G, B\) values is \([0..1.0]\), | ||
- | |||
- | For the 12-bit pixel components the values are scaled by 4095, making all this look like the following: | ||
- | |||
- | \[ | ||
\left(\begin{bmatrix} | \left(\begin{bmatrix} | ||
R \\ | R \\ | ||
Line 93: | Line 29: | ||
- | - | ||
\begin{bmatrix} | \begin{bmatrix} | ||
- | 871 \\ | + | 2047 \\ |
- | 2929 \\ | + | 2047 \\ |
- | 296 | + | 2047 |
- | \end{bmatrix} \right) | + | \end{bmatrix} \right) \times contrast^2 |
- | \times contrast^2 + | + | }{1024*1024} |
\begin{bmatrix} | \begin{bmatrix} | ||
- | 871 \\ | + | 2047 \\ |
- | 2929 \\ | + | 2047 \\ |
- | 296 | + | 2047 |
\end{bmatrix} | \end{bmatrix} | ||
- | |||
\] | \] | ||
- | |||
===== In HSL color space ===== | ===== In HSL color space ===== |