next up previous contents
Next: 13.2.4.6 CMY Conversion Up: 13.2.4 The Color Matrix Previous: 13.2.4.4 Modifying Saturation   Contents

13.2.4.5 Hue Rotation

Changing the hue of a color may be accomplished by loading a rotation about the gray vector $(1, 1, 1)$. This operation may be performed in one step using the glRotate() command. The matrix may also be constructed via the following steps [42]:

49.
Load the identity matrix (glLoadIdentity()).
50.
Rotate such that the gray vector maps onto the $z$ axis using the glRotate() command.
51.
Rotate about the $z$ axis to adjust the hue (glRotate<degrees>, 0, 0, 1(<degrees>, 0, 0, 1)).
52.
Rotate the gray vector back into position.
Unfortunately, a naive application of glRotate() will not preserve the luminance of the image. To avoid this problem, you must make sure that areas of constant luminance map to planes perpendicular to the $z$ axis when you perform the hue rotation. Recalling that the luminance of a vector $(R, G, B)$ is equal to:

\begin{displaymath}(R, G, B) \cdot (R_w, G_w, B_w)\end{displaymath}

you realize the plane of constant luminance $k$ is defined by:

\begin{displaymath}(R, G, B) \cdot (R_w, G_w, B_w) = k\end{displaymath}

Therefore, the vector $(R_w, G_w, B_w)$ is perpendicular to planes of constant luminance. The algorithm for matrix construction becomes the following [42]:
53.
Load the identity matrix.
54.
Apply a rotation matrix $M$ such that the gray vector $(1, 1, 1)$ maps onto the positive $z$ axis.
55.
Compute $(R_w', G_w', B_w') = M(R_w, G_w, B_w)$. Apply a skew transform which maps $(R_w', G_w', B_w')$ to $(0, 0, B_w')$. This matrix is:

\begin{displaymath}
\left[
\begin{array}{c c c c}
1& 0& \frac{-R_w'}{B_w'}& 0 \\...
..._w'}{B_w'}& 0 \\
0& 0& 1& 0 \\
0& 0& 0& 1
\end{array}\right]
\end{displaymath}

56.
Rotate about the $z$ axis to adjust the hue.
57.
Apply the inverse of the shear matrix.
58.
Apply the inverse of the rotation matrix.
It is possible to compute a single matrix as a function of $R_w$, $G_w$, $B_w$, and the degrees of rotation which performs this operation.


next up previous contents
Next: 13.2.4.6 CMY Conversion Up: 13.2.4 The Color Matrix Previous: 13.2.4.4 Modifying Saturation   Contents
2001-01-10