Color Spectrum

NI Vision 2015 Concepts Help

Edition Date: June 2015

Part Number: 372916T-01

»View Product Info
Download Help (Windows Only)

The color spectrum represents the 3D color information associated with an image or a region of an image in a concise 1D form that can be used by many of the NI Vision color processing functions. Use the color spectrum for color matching, color location, and color pattern matching applications with NI Vision.

The color spectrum is a 1D representation of the 3D color information in an image. The spectrum represents all the color information associated with that image or a region of the image in the HSL space. The information is packaged in a form that can be used by the color processing functions in NI Vision.

Color Space Used to Generate the Spectrum

The color spectrum represents the color distribution of an image in the HSL space, as shown in the following figure. If the input image is in RGB format, the image is first converted to HSL format and the color spectrum is computed from the HSL space. Using HSL images directly—those acquired with an image acquisition device with an onboard RGB to HSL conversion for color matching—improves the operation speed.

HSL Color Space

Colors represented in the HSL model space are easy for humans to quantify. The luminance—or intensity—component in the HSL space is separated from the color information. This feature leads to a more robust color representation independent of light intensity variation. However, the chromaticity—or hue and saturation—plane cannot be used to represent the black and white colors that often comprise the background colors in many machine vision applications. Refer to the color pattern matching section for more information about color spaces.

Generating the Color Spectrum

Each element in the color spectrum array corresponds to a bin of colors in the HSL space. The last two elements of the array represent black and white colors, respectively. The following figure illustrates how the HSL color space is divided into bins. The hue space is divided into a number of equal sectors, and each sector is further divided into two parts: one part representing high saturation values and another part representing low saturation values. Each of these parts corresponds to a color bin—an element in the color spectrum array.

1  Sector                 2  Saturation Threshold 3  Color Bins

The color sensitivity parameter determines the number of sectors the hue space is divided into. Figure A shows the hue color space when luminance is equal to 128. Figure B shows the hue space divided into a number of sectors, depending on the desired color sensitivity. Figure C shows each sector divided further into a high saturation bin and a low saturation bin. The saturation threshold determines the radius of the inner circle that separates each sector into bins.

The following figure illustrates the correspondence between the color spectrum elements and the bins in the color space. The first element in the color spectrum array represents the high saturation part in the first sector; the second element represents the low saturation part; the third element represents the high saturation part of the second sector and so on. If there are n bins in the color space, the color spectrum array contains n  + 2 elements. The last two components in the color spectrum represent the black and white color, respectively.

 Element #1
 Element #2
 Element #3
  
 
 
 
 
BlackElement #(n+1)
WhiteElement #(n+2)
AB 

A color spectrum with a larger number of bins, or elements, represents the color information in an image with more detail, such as a higher color resolution, than a spectrum with fewer bins. In NI Vision, you can choose between three color sensitivity settings—low, medium, and high. Low divides the hue color space into seven sectors, giving a total of 2 × 7 + 2 = 16 bins. Medium divides the hue color space into 14 sectors, giving a total of 2 × 14 + 2 = 30 bins. High divides the hue color space into 28 sectors, giving a total of 2 × 28 + 2 = 58 bins.

The value of each element in the color spectrum indicates the percentage of image pixels in each color bin. When the number of bins is set according to the color sensitivity parameter, the machine vision software scans the image, counts the number of pixels that fall into each bin, and stores the ratio of the count and total number of pixels in the image in the appropriate element within the color spectrum array.

The software also applies a special adaptive learning algorithm to determine if pixels are either black or white before assigning it to a color bin. Figure B represents the low sensitivity color spectrum of figure A The height of each bar corresponds to the percentage of pixels in the image that fall into the corresponding bin.

The color spectrum contains useful information about the color distribution in the image. You can analyze the color spectrum to get information such as the most dominant color in the image, which is the element with the highest value in the color spectrum. You also can use the array of the color spectrum to directly analyze the color distribution and for color matching applications.

A B

WAS THIS ARTICLE HELPFUL?

Not Helpful