Next: CMY Conversion
Up: 12.2.4 The Color Matrix
Previous: Modifying Saturation
Changing the hue of a color may be accomplished by loading a rotation
about the grey 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:[18]

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

we realize the a plane of constant luminance k is defined by:

Therefore, the vector
is perpendicular to planes of
constant luminance. The algorithm for matrix construction becomes the
following:[18]

- Load the identity matrix
- Apply a rotation matrix M such that the grey vector (1, 1,
1) maps onto the positive Z axis
- Compute
Apply a skew
transform which maps
to
. This
matrix is:

- Rotate about the Z axis to adjust the hue
- Apply the inverse of the shear matrix
- Apply the inverse of the rotation matrix
It is possible to compute a single matrix as a function of
,
,
, and the degrees of rotation which would perform the
operation.
David Blythe
Thu Jul 17 21:24:28 PDT 1997