Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
isp:hue_rotation [2023/09/05 22:22] – [In RGB color space] Igor Yefmov | isp:hue_rotation [2023/09/12 12:25] (current) – [In RGB color space] Igor Yefmov | ||
---|---|---|---|
Line 4: | Line 4: | ||
===== In RGB color space ===== | ===== In RGB color space ===== | ||
- | To rotate the color vector by an angle \(\Theta\) the following | + | To rotate the color vector by an angle \(\Theta\) |
\[ | \[ | ||
+ | cos_1 = cos(\Theta) \\ | ||
+ | cos_2 = \frac{1 - cos_1}{3} \\ | ||
+ | sin_1 = sin(\Theta)\sqrt{1/ | ||
+ | |||
\begin{bmatrix} | \begin{bmatrix} | ||
- | R \\ | + | cos_1 + cos_2 & cos_2 - sin_1 & cos_2 + sin_1 \\ |
- | G \\ | + | cos_2 + sin_1 & cos_1 + cos_2 & cos_2 - sin_1 \\ |
- | B | + | cos_2 - sin_1 & cos_2 + sin_1 & cos_1 + cos_2 |
- | \end{bmatrix} | + | |
- | \times | + | |
- | \begin{bmatrix} | + | |
- | cox(\Theta) | + | |
- | -sin(\Theta) | + | |
- | 0 & 0 & 1 | + | |
\end{bmatrix} | \end{bmatrix} | ||
\] | \] | ||
- | In our codebase the Hue adjustment is a 14-bit signed integer in range \([-16385..16384]\) that corresponds to \([-180°..+180°)\). | + | In our codebase the Hue adjustment is a 14-bit signed integer in range \([-8192..8191]\) that corresponds to \([-180°..+180°)\). |
+ | M.B. this does **not** take into account the fact that different chroma components contribute differently to the luma of the pixel. A more correct implementation must first separate luma and chroma, perform rotation on chroma, and then convert back to RGB triplet, but that is way too expensive to perform in-line during video transmission. | ||
===== In HSL color space ===== | ===== In HSL color space ===== |