Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
isp:contrast [2019/07/14 02:43] – Igor Yefmov | isp:contrast [2023/09/10 21:53] (current) – [Integer arithmetic] Igor Yefmov | ||
---|---|---|---|
Line 6: | Line 6: | ||
Essentially when the contrast is increased, the pixel' | Essentially when the contrast is increased, the pixel' | ||
+ | ===== In RGB color space ===== | ||
+ | |||
+ | Each component' | ||
+ | |||
+ | \[ | ||
+ | component = (component' | ||
+ | component' | ||
+ | contrast \in ]0..2.0]%% | ||
+ | \] | ||
+ | |||
+ | |||
+ | ==== Integer arithmetic ==== | ||
+ | Of course, much like in [[isp:: | ||
+ | |||
+ | \[ | ||
+ | \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' | For our purposes we are going to adjust the pixel' | ||
Line 12: | Line 48: | ||
luma = (luma - 50) * contrast^2 + 50 \\ | luma = (luma - 50) * contrast^2 + 50 \\ | ||
luma \in [0..100] \\ | luma \in [0..100] \\ | ||
- | contrast \in ]0..1.0]%% | + | contrast \in ]0..2.0]%% |
\] | \] | ||
<code c++>// pseudo-code | <code c++>// pseudo-code | ||
void contrast(/ | void contrast(/ | ||
- | for(const & pixel: image){ | + | for(auto & pixel: image){ |
pixel.luma = std:: | pixel.luma = std:: | ||
} | } | ||
}</ | }</ | ||