APPLICATION NOTE 5410

Abstract: This application note will show how all the colors within the color gamut formed by red, green, and blue constants in a CIE plot can be measured and mapped with an RGB color sensor. This RGB sensor can also monitor the color output of LEDs in a display and/or provide feedback to maintain a reference color. An RGB sensor will also be mapped to measure the color temperature of practical light sources.

A similar version of this article appeared on EE Times, July 17, 2012.

An RGB color sensor today can be used in a wide variety of lighting applications. Typical examples include industrial lightning, biomedical equipment displays, chemical analysis, TV backlight control, automotive interior and exterior lighting, and decorative or "mood" lighting.

But, in fact, a color sensor with integrated RGB color filters can do much more. This application note will show how all the colors within the color gamut formed by red, green, and blue constants in a CIE plot can be measured and mapped with an RGB color sensor. This RGB sensor can also monitor the color output of LEDs in a display and/or provide feedback to maintain a reference color. Finally, an RGB sensor will be mapped to measure the color temperature of practical light sources.

Some systems use color mixing from R, G, and B LED outputs. A color sensor can maintain the desired color and correct for any variances from LED output imperfections, drift over time, and temperature variations. A color sensor also measures color temperature, which gives information about the ambient light environment, including its color content and type of light source.

Consider now a typical LCD TV or medical imaging screen that uses color temperature information to correct the image (**Figure 2**). The human eye's perception of a display is influenced by the surrounding ambient light conditions. A display in an environment with a lower color temperature^{1} from soft white or tungsten lamps will look different than the same display viewed in a high color temperature environment with white fluorescent lamps or sunny daylight. Thus, the LCD panel needs to adjust chromatically to the ambient light color.

The International Commission on Illumination (CIE) established a color system to scientifically define light colors called the CIE XYZ color space. It is the widely used, common reference to define light colors. The CIE has defined a set of three spectral-sensitive functions, x^{'}, y^{'}, and z^{'} (**Figure 3**). These functions would yield CIE XYZ tristimulus values upon numerical integration over its spectrum^{2}.

Thus:

X = f(x^{'}), Y = f(y^{'}), and Z = f(z^{'})

Based on the CIE XYZ values, one can derive the coordinates to plot a two-dimensional chart called a CIE gamut chart or chromaticity chart that shows all the possible colors visible to a human eye (**Figure 4**).

After normalizing the X, Y, and Z from the CIE XYZ tristimulus values, one can derive the final x,y values which define the color of a particular light (irrespective of its luminance) on the chromaticity chart:

x = X/(X + Y + Z) | (Eq. 1) |

y = Y/(X + Y + Z) | (Eq. 2) |

There are distinct advantages to using the CIE color space. It provides the entire gamut of colors that a human can see in two-dimensional formats.^{3} Note that the locus for color temperature in Kelvin extends from the lower color temperatures (in reds) to the higher color temperatures (i.e., in white and blues).

The MAX44005 is a new color sensor that integrates sensors for each of the red, green, blue, ambient (clear), and IR channels. The outputs for each channel are read through digital I²C lines. **Figure 5** shows the spectral response for the R, G, and B channels of the MAX44005.

To get the correct color coordinates (x,y) from the MAX44005's R, G, and B outputs, we first map the response of the RGB color sensor profile in Figure 5 to that of XYZ tristimulus value in Figure 3. Then we must normalize the XYZ tristimulus values to get x and y coordinates.

To map the response of the R, G, and B channels of the color sensor to the corresponding X, Y, and Z values, one has to determine constants to translate R, G, and B outputs to its corresponding XYZ values. This constant is called the correlation constant matrix, a 3 × 3 matrix. Matrix values are found by comparing the response of the RGB color sensor with ideal/reference XYZ values (measured with a spectrometer/colorimeter) under the same lighting conditions.

The following two examples show how to derive a correlation constant matrix.

As mentioned earlier, a correlation matrix will be derived from a 3 × 3 transformation matrix which, in turn, will be used to find equations that transform the color sensor's (MAX44005) response to their equivalent CIE tristimulus constants. To determine the correlation matrix constant, the tristimulus values (XYZ) in the 3 × 3 matrix are multiplied to the inverse of the color sensor's response (RGB) matrix (3 × 3) for three difference light colors (see Equation 3).

We use an Ocean Optics® USB4000 spectrometer to calculate the XYZ tristimulus values for a particular light. (For this step, one can use a KONICA MINOLTA® CL200 color meter as well). For this experiment, we picked standard red, green, and blue color light to cover the CIE gamut. The experimental setup is seen in **Figure 6**.

Thus, the correlation constant matrix is:

(Eq. 3) |

Where:

Based on the bench experiments, the matrix can be filled with following numbers:

(Eq. 4) |

Once the constant matrix is known, the final expression for transformation can be given as:

(Eq. 5) |

Thus, the equations for X, Y, Z become:

X = (228.75 × 10^{-6}.R) + (2.06 × 10^{-6}.G) + (-12.45 × 10^{-6}.B) |
(Eq. 6) |

Y = (54.65 × 10^{-6}.R) + (245 × 10^{-6}.G) + (-127.2 × 10^{-6}.B) |
(Eq. 7) |

Z = (-1.045 × 10^{-6}.R) + (-25.03 × 10^{-6}.G) + (181 × 10^{-6}.B) |
(Eq. 8) |

Testing the MAX44005 under standard red light gave counts of R = 3049, G = 649, and B = 149.

Plugging these numbers into Equations 6, 7, and 8 gives

X = 0.6969

Y = 0.3066

Z = 0.00754

Y = 0.3066

Z = 0.00754

The above X, Y, Z values can be used to calculate CIE x,y values, as outlined in Equations 1 and 2.

x = X/(X + Y + Z) | (Eq. 9) |

Therefore:

x = 0.6969/(0.6969+0.3066+0.00754) = 0.6892 | (Eq. 10) |

Similarly:

y = Y/(X + Y + Z) | (Eq. 11) |

Therefore:

y = 0.3066/(0.6969 + 0.3066 + 0.00754) = 0.3033 | (Eq. 12) |

The x,y value (0.6892,0.3033) on the x,y CIE plot shows the color red, which validates our experiment.

A brief digression on color temperature theory will be useful before we derive a constant matrix for the color temperature of light bulbs.

Color temperature is a characteristic of visible light, with the units measured in Kelvin (K). The CIE definition of color temperature is the temperature of a Planckian (perfect blackbody) radiator whose radiation has the same chromaticity as a given stimulus. Thus, the color temperature of a light source is the perceived color for an ideal blackbody radiator when heated to that particular temperature in Kelvin.^{4} This is similar to heating a blackbody or piece of metal which, once heated, steadily produces colors that follow the temperature rise (e.g., first red, then orange, yellow, and so on, following the increase in temperatures).

(Note that this is counter intuitive to human mind perception of higher temperatures with hot colors and blue or white with cooler or lower temperature colors).^{5, 6}

Recall that measuring color temperature is important for monitoring outside light conditions and then adjusting the backlight of LCD panels to enhance a viewer's experience. Our earlier example was a TV display, but color temperature information can be used for industrial instrumentation, process control, and medical applications.

Below is the example of mapping MAX44005 RGB outputs to the color temperature of three different lamps of different color temperatures. The lamps selected cover a wide range of color temperatures:

- 2800K = Philips® Halogena™ 50W (halogen incandescent)
- 3500K = EcoSmart-28930BD (soft white)
- 5000K EcoSmart-ESM27 (daylight)

Based on the procedure outlined above for color mapping, a correlation constant matrix is derived as:

(Eq. 13) |

Based on the bench experiments, the matrix can be filled with following values:

(Eq. 14) |

(Eq. 15) |

Thus, the equations for X, Y, Z become:

X = (-959.3 × 10^{-6}.R) + (1703.4 × 10^{-6}.G) + (-238.1 × 10^{-6}.B) |
(Eq. 16) |

Y = (-1004.9 × 10^{-6}.R) + (1573.7 × 10^{-6}.G) + (166.2 × 10^{-6}.B) |
(Eq. 17) |

Z = (-937.8 × 10^{-6}.R) + (775.7 × 10^{-6}.G) + (1497.2 × 10^{-6}.B) |
(Eq. 18) |

Testing the MAX44005 under a 2800K color temperature bulb gave counts of R = 3209, G = 2162, and B = 968.

Plugging these numbers into Equations 16, 17, and 18 gives:

X = 0.3738

Y = 0.3385

Z = 0.1169

Y = 0.3385

Z = 0.1169

Thus from Equations 1 and 2:

x = 0.3738/(0.3738 + 0.3385 + 0.1169) = 0.4508 | (Eq. 19) |

Similarly:

y = 0.3385/(0.3738 + 0.3385 + 0.1169) = 0.4081 | (Eq. 20) |

To calculate the color temperature, we apply the most widely used equation proposed by McCamy.^{5} Note that we should say "correlated" color temperature (CCT) rather than color temperature, although for all practical purpose the terms are interchangeable.^{7, 8}

As per the McCamy formula:

CCT = 449.0 × n³ + 3525.0 × n² + 6823.3 × n + 5520.33 | (Eq. 21) |

Where:

n = (x - Xe)/(Ye - y) | (Eq. 22) |

Xe = 0.3320

Ye = 0.1858

Ye = 0.1858

Plugging numbers for x and y from Equations 19 and 20 into Equation 22, we get:

CCT = 2812K | (Eq. 23) |

This is very close to the specified color temperature of 2800K.

A color sensor with R, G, and B channels can be configured for any three variables using the mapping process presented here. Moreover, all the possible colors in the CIE gamut chart within the triangle formed by red, green, and blue colors can be measured using an RGB sensor and color mapping. Similarly, an RGB sensor can be mapped to measure the color temperature of practical light sources and/or color content of LEDs.

- See related discussion of color temperature at the end of the section on tristimulus values.
- http://en.wikipedia.org/wiki/CIE_1931_color_space
- See the CIE website and description of tristimulus at http://www.cie.co.at/publications/colorimetry-part-3-cie-tristimulus-values-1.
- CIE, International Lighting Vocabulary, CIE Publication 17.4–1987, Vienna, Austria: CIE Central Bureau.
- www.handprint.com/HP/WCL/color12.html
- http://en.wikipedia.org/wiki/Color_temperature
- McCamy, C. S., "Correlated color temperature as an explicit function of chromaticity coordinates," Color Res. Appl., 17: 142–144 (1992). doi: 10.1002/col.5080170211
- The term "color temperature" is appropriate for sources producing light through heating (e.g., a blackbody radiator), correlated color temperature should be used for sources that produce light without a heating element—this follows the Planckian
*locus*. As shown in the CIE plot of Figure 4, the Planckian locus extends between temperatures from 1500K to 10,000K.