Color is one of the most important visual cues that humans have for inspecting objects. Yet, color is a subjective value that depends on an object’s illumination and viewing environment as well as its spectral properties. To automate color-based inspection, a machine vision system must model after the behavior of human eyesight.

The color of objects and surrounding light affects one’s mood and his overall opinion of the things he sees every day. A package that is mis-colored in comparison to the surrounding packages, for example, may cause customers to think that an item is old or defective. Machine vision systems can leverage the strength of such color cues to help determine whether products will sell and whether or not the end customer will be satisfied.

Lighting conditions can cause objects to look the same even when their colors are different, a condition known as metamerism. The image shows four blue patches under white LED (top) and quartz-halogen lighting (bottom). Source: Edmund Optics

Cameras do not see color, however; they only detect levels of integrated spectral information. Spectral information becomes a specific color only when a human observer views it under some set of lighting conditions. Because every human observer sees and describes color differently, and lighting conditions affect color perception, automated color inspection requires more than a simple camera. The image needs to be processed using a standard model of human visual perception in order to provide appropriate color matching.

Lighting conditions can cause objects to look the same even when their colors are different, a condition known as metamerism. The image shows four blue patches under white LED (top) and quartz-halogen lighting (bottom). Source: Edmund Optics

The goal of the visual color matching system should not be confused with other color measurement systems, such as simple color sorting. Color sorting systems only need to be able to distinguish among various, often quite different, colors. A crayon manufacturer, for instance, can use a simple color sorting system to ensure that there is one and only one red crayon in each box. If the crayon manufacturer wants to guarantee that the red crayon in each color-assorted box will look identical to that same crayon in every other box, however, it will need a visual color matching system. Only color matching is able to determine whether two red crayons will look the same to a customer.

Light sources with strong spectral lines can alter the color appearance of an object, compromising color measurements. The image shows the spectral characteristics of “white” light from fluorescent (top), LED (middle) and metal-halide (bottom) sources. Source: Edmund Optics

Use the Right Lighting

Visual color matching systems must judge color in the same way that humans do. One way to make this judgment is to use the “golden reference” strategy. Start by choosing an ideal, or “golden” unit, one that is as close to perfect as possible, from the pilot production runs. If the ideal color is a certain red, the golden reference unit should be as close to that red as possible. The inspection system will then use relative color analysis to measure visual color differences between each unit under test (UUT) and the golden reference unit. This provides the information needed to ensure that every production unit will visually match the reference.

Because human perceptions depend on the lighting conditions, the test conditions must model the final viewing conditions. Lighting and how it interacts with UUTs should be the first consideration. Light source intensity stability, spectral characteristics and geometry all affect color-difference measurements. To provide consistent results, then, test conditions such as light sources, object characteristics, color models, detecting devices and environmental conditions must not vary between tests.

Light sources with strong spectral lines can alter the color appearance of an object, compromising color measurements. The image shows the spectral characteristics of “white” light from fluorescent (top), LED (middle) and metal-halide (bottom) sources. Source: Edmund Optics

One important lighting parameter is intensity stability, meaning that the total amount of light emitted from the source should be constant over time. Ensuring this stability requires control over the environmental conditions. Even the slightest variation in ambient temperature can dramatically change light-source characteristics. For example, some fluorescent lights change intensity 5 to 10% when the ambient temperature shifts as little as 10%.

The source’s flicker rate can affect measurement stability as well. A fluorescent lamp’s output, for example, changes in time with AC power cycles. The AC frequency must therefore be higher than the machine vision system’s sampling rate, or the intensity will vary from one color measurement to the next. Too low a power line frequency can play havoc with tests using fast acquisition times on an assembly line.

Measurement precision depends on the source’s spectral characteristics. If a UUT is blue and the light source does not have sufficient blue emission, realistic measurement results are impossible to obtain. Using continuous-spectrum “white” lights in color testing systems avoids such problems. The light source needs to include adequate emission at every wavelength within the visible range-380 to 720 nanometers.

The spectral characteristics of the light source also are important in avoiding metamerism, where two UUTs look the same under one light source but look different under another light source. Metamerism occurs because human visual systems cannot distinguish detailed wavelength information, only broad ranges. Thus, two UUTs can have different spectral curves but still look the same under the right lighting conditions. Many cameras also do not detect detailed spectral information, so they will be affected by metamerism in the same manner as humans.

Metamerism commonly occurs when the light sources include line spectra, that is, sharp intensity peaks at specific wavelengths. Many common light sources, including fluorescent and metal halide lamps, emit line spectra in addition to or instead of continuous emission. Two objects that have different spectral curves may appear to match in color under one light source because the light’s line spectra have masked the differences. When illuminated by a different light source, the spectral differences between the objects may be emphasized, causing their differences to be noticeable by a human.

The placement and type of lighting required in a machine vision system depends on the surface characteristics of the unit under test. Glossy surfaces need low light positions to avoid glare that masks subtle color variations. Source: Edmund Optics

Because the final viewing light may differ from the test light, the ideal test system provides color data independent of the test light. Canceling out the test light-“zeroing” the system-provides relative spectral and colorimetric results that are independent of the lighting. Zeroing the system also accounts for different color sensitivities between detectors. The standard approach to zeroing the system is called “white balancing.” Most vision cameras offer some level of white balancing capability.

White balancing requires the use of a white reflectance standard, which has a known amount of reflection at each wavelength across the visible spectrum, to measure the characteristics of the lighting system so that they can be subtracted out of the measurements on the UUT. White reflective standards can be made from Spectrolan, which is a durable, washable and often NIST-traceable material, but fairly expensive. A less expensive alternative is Kodak’s 90% white reflectance test card. Acceptable results also can be obtained with high quality white copy paper, but the results are not NIST traceable. Note that while white balancing can improve the results from a good, stable white source, it will not help a light with stability problems or solve metamerism.

Geometry is the final lighting factor to consider. Geometry describes the alignment between the source, the UUT and the detector. The optimum geometry will depend on the UUT’s physical characteristics, which affect the reflection, transmission, scattering, absorption and emission of light.

Lighting geometry is important. Take, for example, a highly glossy surface that has high reflectivity and produces mirror-like specular reflections. A high illumination source can thus generate glare that compromises the vision system. Placing the source at a low angle to the surface and adding a diffuser to reduce specular reflections will help in the detection of small visual differences on such surfaces. Another option for inspecting such a flat, shiny material would be to use an integrating sphere. Color difference measurements will vary whether specular reflections are included or excluded from the system.

Deeply textured products require a different lighting approach. Texture differences can affect color appearance, so for these surfaces the lighting must be even and sufficiently diffuse to provide consistent measurements. Other surfaces may require other approaches, so knowing the UUT’s surface qualities is essential in developing a color vision inspection system. The International Commission on Illumination (CIE) provides recommended lighting geometries for a variety of surfaces through their Web site atwww.cie.co.at/cie.

White balancing helps remove the spectral characteristics of the test illumination from color measurement, but cannot solve problems with metamerism. Source: Edmund Optics

Choose Appropriate Color Standards

When color matching is used solely for pass-fail inspections, the way in which the system quantifies the color is unimportant. If the system is to quantify mismatches for the purposes of correcting the production process, however, the choice of color description schemes becomes important. Some standard color spaces, such as the RGB (red-green-blue) description, are great for specifying how a camera should detect a color, but provide no insight into how a person will perceive it.

The XYZ color space is another color scheme, designed to describe a color based on a standard human observer. While comparing XYZ values can quickly tell how closely one UUT matches the golden reference unit, however, if the values differ they provide no information on how the colors differ or whether the difference will be visually noticeable.

In order to provide color feedback, then, the vision system needs to use a color space that can be use to evaluate colors in a manner similar to human perception. The CIElab color standard is one such color space. This standard uses opponent theory, which relies on the fact that in human perception an object cannot look red and green at the same time, nor can it look yellow and blue at the same time.

White balancing helps remove the spectral characteristics of the test illumination from color measurement, but cannot solve problems with metamerism. Source: Edmund Optics

The CIElab system uses three values: L*, a* and b*, to quantify a color. The first, L*, quantifies perceived brightness, such as gray level. The second, a*, represents how red or green the object looks. Positive a* values represent reddish colors and negative values indicate greenish ones. The third parameter, b*, indicates yellowish vs. bluish colors. Positive b* indicates yellow and negative b* indicates blue.

The CIElab color space is perceptually uniform, that is, equal differences in the color space represent equal human-perceived color differences. This representation simplifies the correction of color errors. If a product looks too bluish, fixing the problem becomes very easy.

A more intuitive color space is the HCL-Hue, Chroma and Lightness-standard. In this representation, a given color appears as a point located in a 3-D color space defined by the HCL axes. Hue describes how red, green, blue or yellow the color appears. Chroma represents the color’s departure from gray, which humans perceive as saturation or vividness. Lightness describes how dark or light an object is. The Lightness scale runs from black to white with gray in the middle.

These two color standards map onto one another. CIElab values translate uniquely to the HCL color space. Hue and Chroma can be calculated from a* and b* values. Lightness is the same in either scale. Thus, a system that can work in one representation can work in both, providing information that will help evaluate and correct color errors.

The CIElab color space describes colors by leveraging the human perception that something cannot look both red and green or both blue and yellow. Source: Edmund Optics

Measuring Color

In order to evaluate a color using these standards, the system must first quantify the color by making a colorimetric measurement. Spectrometers provide the most complete colorimetric measurements, quantifying the UUT’s relative spectral properties in sufficient detail to predict metamerism. Most off-the-shelf spectrometers look only at a small area on the UUT, however. Such spot-checking of color is ideal for some applications, but others require the use of integrated measurements over a larger area. Custom lighting and optical systems may need to be designed to illuminate and measure large areas on UUTs with a spectrometer.

Colorimeters are another measuring tool, determining color directly as a set of XYZ color space measurements that can then be used to calculate CIElab values. Colorimeters are faster than spectrometers, reducing the data collection and calculation times required to make a measurement. Colorimeter measurements require the same attention to lighting and observation area as spectrometers, however.

Color cameras also can make colorimetric measurements, working directly in the RGB color space. Computerized systems can then estimate CIElab values from the RGB measurements. What cameras provide that the other instruments cannot, however, is spatial information. Cameras can measure colors on many parts of the UUT simultaneously. They have the added benefit of being able to perform additional tasks-such as optical character recognition, particle analysis and gaging-while collecting colorimetric information.

One problem with color cameras is that they are not as precise as spectrometers or colorimeters. Two cameras from the same manufacturer may differ in spectral response by up to 10%. Nonetheless, when the cameras are correctly calibrated and white balanced, color difference measurements can be remarkably consistent.

The intuitive HCL color space describes colors with hue, saturation (chroma), and lightness,which maps uniquely onto the CIElab color space. Source: Edmund Optics

System Considerations

When creating a vision-based color-measuring system, it is important to test the system in an environment similar to that in which it will be used. One key reason is that detectors tend to change sensitivity and noise levels with shifts in ambient temperature. Whether the detector is a spectrometer, colorimeter or camera, each has its own relation to noise and changes in temperature. Some manufacturers of three-chip cameras, for instance, recommend operating the instruments at below 40 C to reduce noise. This temperature sensitivity can create problems if the system’s environment is not stable requiring frequent recalibration of the system or even the installation of a thermoelectric cooler for the detector to prevent inconsistent measurements.

The entire system also should be tested to ensure that it is sensitive enough to detect the smallest color differences of interest. One way to perform this test is to have a batch of visually acceptable UUTs and a batch of visually unacceptable ones to compare to the reference unit. If the system can reliably distinguish between the good and bad test UUTs, it should also work well in production.

A final consideration when using color measurement systems is establishing what kinds of color errors are acceptable. Using too narrow a definition will limit manufacturing productivity. Too broad a definition will fail to achieve consistency.

Determining the tolerances, however, brings color back to a subjective evaluation. A CIElab system can do an impressive job of predicting color differences, but whether or not those differences are significant can only be evaluated by a human. Thus, calculated color measurements need to be validated by real field experience. Most engineers set their measurement tolerance levels empirically, correlating real-world observations to the test data to determine tolerance bands.

With appropriate color tolerance bands, machine vision systems can automate color inspection with great reliability. To get the system running, however, developers should spend time up front getting to know the target UUT, so that they can choose the best lighting for that target. The system should work in a color space that mimics human perception so that measurements can be meaningful and correlate with customer perceptions. After all, machines just detect spectral information. Only humans see color.