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

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 [39]:

tex2html_nowrap 49.
Load the identity matrix (glLoadIdentity()).
tex2html_nowrap 50.
Rotate such that the gray vector maps onto the zaxis using the glRotate() command.
tex2html_nowrap 51.
Rotate about the z axis to adjust the hue (glRotate<degrees>, 0, 0, 1(<degrees>, 0, 0, 1)).
tex2html_nowrap 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 (Rw, Gw, Bw) is perpendicular to planes of constant luminance. The algorithm for matrix construction becomes the following [39]:
tex2html_nowrap 53.
Load the identity matrix.
tex2html_nowrap 54.
Apply a rotation matrix M such that the gray vector (1, 1, 1) maps onto the positive z axis.
tex2html_nowrap 55.
Compute (Rw', Gw', Bw') = M(Rw, Gw, Bw). Apply a skew transform which maps (Rw', Gw', Bw') to (0, 0, Bw'). 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}

tex2html_nowrap 56.
Rotate about the z axis to adjust the hue.
tex2html_nowrap 57.
Apply the inverse of the shear matrix.
tex2html_nowrap 58.
Apply the inverse of the rotation matrix.
It is possible to compute a single matrix as a function of Rw, Gw, Bw, 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
David Blythe
1999-08-06