User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
isp:contrast [2023/09/05 05:01] Igor Yefmovisp:contrast [2023/09/10 21:53] (current) – [Integer arithmetic] Igor Yefmov
Line 7: Line 7:
  
 ===== In RGB color space ===== ===== 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 ===== ===== In HSL color space =====

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information