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
Next revisionBoth sides next revision
isp:contrast [2023/09/05 05:52] – [In RGB color space] Igor Yefmovisp:contrast [2023/09/06 10:37] – [Integer arithmetic] Igor Yefmov
Line 20: Line 20:
  
 \[ \[
-component = (component - 50*k) * contrast^2 + 50*k \\ +component = (component0.5) * (contrast * k)^2 + 0.5 \\ 
-luma \in [0..100] \\+component' \in [0..1.0] \\
 contrast \in ]0..2.0]%% contrast \in ]0..2.0]%%
 \] \]
Line 29: Line 29:
 \[ \[
 \begin{bmatrix} \begin{bmatrix}
-R - 50 * 0.2126 \\ +R - 0.\\ 
-G - 50 * 0.7152 \\ +G - 0.\\ 
-B - 50 * 0.0722 +B - 0.5
-\end{bmatrix} \times contrast^2 +
-+
-\begin{bmatrix} +
-50 * 0.2126 \\ +
-50 * 0.7152 \\ +
-50 * 0.0722+
 \end{bmatrix} \end{bmatrix}
-\]  + \times
- +
-which easily simplifies to +
- +
-\[+
 \begin{bmatrix} \begin{bmatrix}
-R - 10.63 \\ +0.2126^2 & 0 & 0 \\ 
-G - 35.76 \\ +0 & 0.7152^2 & 0 \\ 
-B - 3.61+0 & 0 & 0.0722^2
 \end{bmatrix} \times contrast^2 \end{bmatrix} \times contrast^2
 + +
 \begin{bmatrix} \begin{bmatrix}
-10.63 \\ +0.\\ 
-35.76 \\ +0.\\ 
-3.61+0.5
 \end{bmatrix} \end{bmatrix}
 \]  \] 
  
-Of course, much like in [[isp::brightness]] case, we'd like to not use floating point arithmetic:+==== 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:
  
 \[ \[
Line 65: Line 56:
 G  \\ G  \\
 B B
-\end{bmatrix} \times 1024+\end{bmatrix}
 - -
 \begin{bmatrix} \begin{bmatrix}
-10885 \\ +2047 \\ 
-36618 \\ +2047 \\ 
-3697+2047
 \end{bmatrix} \right) \end{bmatrix} \right)
- \times contrast^2 + 
 \begin{bmatrix} \begin{bmatrix}
-10885 \\ +47394 & 0 & 0 \\ 
-36618 \\ +0 & 536358 & 0 \\ 
-3697+0 & 0 & 5466 
 +\end{bmatrix} \times contrast^2 
 +}{1024*1024*1024*1024} + 
 +\begin{bmatrix} 
 +2047 \\ 
 +2047 \\ 
 +2047
 \end{bmatrix} \end{bmatrix}
-}{1024} 
 \]  \] 
  
-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. 
 ===== In HSL color space ===== ===== 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.

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