|EU-Asia Link, Project "ENLICHTEN"||
The three CIE color matching functions (CMFs) are called Xbar, Ybar and Zbar, and for practical color matching and display applications these can be treated as if they were the spectral response curves for the cone-receptors in the human eye.
A "color" is defined by the relative stimulus of the eye's XYZ channels (the actual magnitudes will define the brightness or intensity). It makes sense therefore to define a color by an xyz triplet which are normalised versions of XYZ:
|x =||y =||z =|
Of course, by definition now, x + y + z = 1 . As such, only two out of the three xyz coordinates are needed to uniquely define a color. It is conventional to define colors by their x,y coordinates. This then gives rise to the CIE chromaticity diagram.
Spectrum to RGB Conversion
In 1931, the International Commission on Illumination (CIE) defined three standard primaries, called X, Y and Z. The corresponding functions , , and are called color-matching functions. The color-matching function is defined to match the eye's sensitivity to brightness; the other two do not correlate with any perceptual attributes. X, Y and Z represent the weights of the respective color-matching functions needed to approximate a particular spectrum.
To match a color with power distribution P, the amounts of the primaries are given by the following formulae :
where k for self-luminous bodies, such as CRT, is equal to 680 lumens per watt.
RGB to XYZ & XYZ to RGB Conversion
RGB values in a particular set of primaries can be transformed to and from CIE XYZ via a 3x3 matrix transform. These transforms involve tristimulus values, that is a set of three linear-light components that conform to the CIE color-matching functions. CIE XYZ is a special set of tristimulus values. In XYZ, any color is represented as a set of positive values.
To transform from XYZ to RGB (with D65 white point), the matrix transform used is :
[ R ] [ 3.240479 -1.537150 -0.498535
] [ X ]
[ G ] = [ -0.969256 1.875992 0.041556 ] * [ Y ]
[ B ] [ 0.055648 -0.204043 1.057311 ] [ Z ].
The range for valid R, G, B values is [0,1]. Note, this matrix has negative coefficients. Some XYZ color may be transformed to RGB values that are negative or greater than one. This means that not all visible colors can be produced using the RGB system.
The inverse from RGB to XYZ transformation matrix is as follows:
[ X ] [ 0.412453 0.357580 0.180423
] [ R ]
[ Y ] = [ 0.212671 0.715160 0.072169 ] * [ G ]
[ Z ] [ 0.019334 0.119193 0.950227 ] [ B ].
CIE 1931 Chromaticity Diagram
Adapted from A. Zukauskas, M. S. Shur, and R. Gaska, Introduction to Solid State Lighting, Wiley (2002).
The RGB system and the HSB system are just different ways of describing the same set of colors. It is possible to translate between one system and the other. The best way to understand the color systems is to experiment with them. In the following applet, you can use the scroll bars to control the RGB and HSB values of a color. A sample of the color is shown on the left side of the applet.
HSL is another way to describe color with 3 parameters. RGB is the way computer
screens work, but not very intuitive. HSL is more intuitive, but you need to
convert it to RGB before you can draw a pixel with it. The nicest application of
this color model is that you can easily create rainbow gradients or change the
color, lightness or saturation of an image with this color model.
HSL color obviously has the parameters H, S and L, or Hue, Saturation and Lightness.
Hue indicates the color sensation of the light, in other words if the color is red, yellow, green, cyan, blue, magenta, ... This representation looks almost the same as the visible spectrum of light, except on the right is now the color magenta (the combination of red and blue), instead of violet (light with a frequency higher than blue):
Hue works circular, so it can be represented on a circle instead. A hue of 360° looks the same again as a hue of 0°.
Saturation indicates the degree to which the hue differs from a neutral gray. The values run from 0%, which is no color, to 100%, which is the fullest saturation of a given hue at a given percentage of illumination. The more the spectrum of the light is concentrated around one wavelength, the more saturated the color will be.
Lightness indicates the illumination of the color, at 0% the color is completely black, at 50% the color is pure, and at 100% it becomes white. In HSL color, a color with maximum lightness (L=255) is always white, no matter what the hue or saturation components are. Lightness is defined as (maxColor+minColor)/2 where maxColoris the R, G or B component with the maximum value, and minColor the one with the minimum value.
In this tutorial, Hue, Saturation and Lightness will be presented as numbers between 0-255 instead, so that the HSL model has the same 24 bits as the RGB model.
 F. W. Billmeyer, Jr., M. Saltzman. Principles of Color Technology, 2nd edition, John Wiley & Sons, Inc., New York, 1981.
 CIE 1971, International Commission on Illumination. Colorimetry: Official Recommendations of the International Commission on Illumination. Publication CIE No. 15 (E-1.3.1) 1971, Bureau Central de la CIE, Paris, 1971.
 A. Zukauskas, M. S. Shur, and R. Gaska, Introduction to Solid State Lighting, Wiley (2002).