Map Colors of a CIE Plot and Color Temperature Using an RGB Color Sensor
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.
Introduction
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.
Maintaining and Correcting Color; Measuring Color Temperature
Figure 1 shows a system with RGB LED-based backlight control for display illumination. A color sensor provides the actual R, G, and B contents of the light emitted from the display; its output dynamically adjusts the R, G, and B LED current independently, thereby maintaining the reference white color output. This dynamic color adjustment helps to maintain the color or white point tracking.
Figure 1. A color sensor is used for white point tracking in a backlighting system with RGB LEDs.
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 temperature1 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.
Figure 2. An RGB color sensor used for color temperature measurement adjusts an LCD display according to ambient light conditions.
Color Gamut and CIE Color Tristimulus Values
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 spectrum2.
Thus:
X = f(x'), Y = f(y'), and Z = f(z')
Figure 3. The CIE standard color-matching function.
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)
y = Y/(X + Y + Z)
Figure 4. This CIE gamut chart shows the x,y chromaticity coordinates and color temperature locus. The triangular area covers the gamut of colors defined by standard green, red, and blue colors.
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).
Calculate Tristimulus Values with a Color Sensor
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 I2C lines. Figure 5 shows the spectral response for the R, G, and B channels of the MAX44005.
Figure 5. Spectral responses of the MAX44005 color sensor's R, G, B, and IR channels.
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.
Mapping the Matrix
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.
Example 1. Mapping of RGB sensor outputs for three primary colors
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.
Figure 6. Setup for mapping the MAX44005 R, G, and B values for the color gamut covered by standard red, green, and blue colors. As the LED colors are varied, the R, G, and B counts of the MAX44005 change and the x,y location on the CIE plot reflects this change. Similarly, a different matrix has been used in the setup to cover the color temperature locus from 2800K to 5000K.
Thus, the correlation constant matrix is:
Where:
Xred, Xgreen, Xblue, Yred, Ygreen, Yblue, and Zred, Zgreen, Zblue are responses from the USB4000 colorimeter under red, green, and blue color light.
Rred, Rgreen, Rblue, Gred, Ggreen, Gblue, and Bred, Bgreen, Bblue are the responses from the MAX44005's red, green, and blue output channels under red, green, and blue color light.
Based on the bench experiments, the matrix can be filled with following numbers:
Once the constant matrix is known, the final expression for transformation can be given as:
Thus, the equations for X, Y, Z become:
X = (228.75 × 10-6.R) + (2.06 × 10-6.G) + (-12.45 × 10-6.B)
Y = (54.65 × 10-6.R) + (245 × 10-6.G) + (-127.2 × 10-6.B)
Z = (-1.045 × 10-6.R) + (-25.03 × 10-6.G) + (181 × 10-6.B)
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
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)
Therefore:
x = 0.6969/(0.6969+0.3066+0.00754) = 0.6892
Similarly:
y = Y/(X + Y + Z)
Therefore:
y = 0.3066/(0.6969 + 0.3066 + 0.00754) = 0.3033
The x,y value (0.6892,0.3033) on the x,y CIE plot shows the color red, which validates our experiment.
Example 2. Mapping of RGB sensor outputs for different color temperature light bulbs
p 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).
Figure 7 shows that at lower temperatures (2700K), the color looks dark red. As the temperature rises, the color loses its saturation and appears yellowish at temperatures around 3500K (the color temperature of a typical tungsten lamp). Further increase in temperature leads to an apparent white color around 5000K (i.e., daylight) or bluish white around 6500K (i.e., a bright sunny day).
(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
Figure 7. Color temperatures for various light sources.
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:
Based on the bench experiments, the matrix can be filled with following values:
Thus, the equations for X, Y, Z become:
X = (-959.3 × 10-6.R) + (1703.4 × 10-6.G) + (-238.1 × 10-6.B)
Y = (-1004.9 × 10-6.R) + (1573.7 × 10-6.G) + (166.2 × 10-6.B)
Z = (-937.8 × 10-6.R) + (775.7 × 10-6.G) + (1497.2 × 10-6.B)
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
Thus from Equations 1 and 2:
x = 0.3738/(0.3738 + 0.3385 + 0.1169) = 0.4508
Similarly:
y = 0.3385/(0.3738 + 0.3385 + 0.1169) = 0.4081
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
Where:
n = (x - Xe)/(Ye - y)
Xe = 0.3320
Ye = 0.1858
Plugging numbers for x and y from Equations 19 and 20 into Equation 22, we get:
CCT = 2812K
This is very close to the specified color temperature of 2800K.
Conclusion
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.
{{modalTitle}}
{{modalDescription}}
{{dropdownTitle}}
- {{defaultSelectedText}} {{#each projectNames}}
- {{name}} {{/each}} {{#if newProjectText}}
-
{{newProjectText}}
{{/if}}
{{newProjectTitle}}
{{projectNameErrorText}}