Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision |
isp:contrast [2019/07/17 23:45] – Igor Yefmov | isp:contrast [2023/09/10 21:53] (current) – [Integer arithmetic] Igor Yefmov |
---|
Essentially when the contrast is increased, the pixel's \(L\) value gets "pushed away" from the center of the values' scale, and when the contrast is decreased the \(L\) is being "pushed towards" the center. | Essentially when the contrast is increased, the pixel's \(L\) value gets "pushed away" from the center of the values' scale, and when the contrast is decreased the \(L\) is being "pushed towards" the center. |
| |
| ===== In RGB color space ===== |
| |
| Each component's contrast adjustment is based on its value and the adjustment itself is calculated as |
| |
| \[ |
| component = (component' - 0.5) * k^2 + 0.5 \\ |
| component' \in [0..1.0] \\ |
| contrast \in ]0..2.0]%% |
| \] |
| |
| |
| ==== Integer arithmetic ==== |
| Of course, much like in [[isp::brightness]] case, we'd like to not use floating point arithmetic, so for the 12-bit pixel components and taking into account that the \(contrast\) is in range \([0..2047]\), the math looks like the following: |
| |
| \[ |
| \frac{ |
| \left(\begin{bmatrix} |
| R \\ |
| G \\ |
| B |
| \end{bmatrix} |
| - |
| \begin{bmatrix} |
| 2047 \\ |
| 2047 \\ |
| 2047 |
| \end{bmatrix} \right) \times contrast^2 |
| }{1024*1024} + |
| \begin{bmatrix} |
| 2047 \\ |
| 2047 \\ |
| 2047 |
| \end{bmatrix} |
| \] |
| |
| ===== In HSL color space ===== |
For our purposes we are going to adjust the pixel's \(L\) component in the HSL color space, leaving the other two components intact as the Saturation shouldn't be affected by the Contrast and the Hue (at least for now) is also maintaining its invariance during this operation. | For our purposes we are going to adjust the pixel's \(L\) component in the HSL color space, leaving the other two components intact as the Saturation shouldn't be affected by the Contrast and the Hue (at least for now) is also maintaining its invariance during this operation. |
| |