Справочник Пользователя для National Instruments IMAQ Vision for LabWindows TM /CVI

Скачать
Страница из 119
Chapter 3
Making Grayscale and Color Measurements
© National Instruments Corporation
3-9
Comparing Colors
You can use the color matching capability of IMAQ Vision to compare or 
evaluate the color content of an image or regions in an image.
Complete the following steps to compare colors using color matching:
1.
Select an image containing the color information that you want to use 
as a reference. The color information can consist of a single color or 
multiple dissimilar colors, such as red and blue.
2.
Use the entire image or regions in the image to learn the color 
information using 
imaqLearnColor()
, which outputs a color 
spectrum that contains a compact description of the color information 
in an image or ROI. Use the color spectrum to represent the learned 
color information for all subsequent matching operations. 
Refer to Chapter 14, Color Inspection, of the IMAQ Vision Concepts 
Manual
 for more information about color learning.
3.
Define an entire image, a region, or multiple regions in an image as the 
inspection or comparison area.
4.
Use 
imaqMatchColor()
 to compare the learned color information to 
the color information in the inspection regions. This function returns 
an array of scores that indicates how close the matches are to the 
learned color information.
5.
Use the color matching score as a measure of similarity between the 
reference color information and the color information in the image 
regions being compared.
Learning Color Information
Choose the color information carefully when learning color information.
Specify an image or regions in an image that contain the color or color 
information that you want to learn.
Select the level of detail you want the for the learned color information.
Choose colors that you want to ignore during matching.
Specifying the Color Information to Learn
Because color matching only uses color information to measure similarity, 
the image or regions in the image representing the object must contain only 
the significant colors that represent the object, as shown in Figure 3-6a. 
Figure 3-6
b illustrates an unacceptable region containing background 
colors.