National Instruments IMAQTM Digital Camera User Manual


 
Chapter 5 Performing Machine Vision Tasks
© National Instruments Corporation 5-21 IMAQ Vision for Visual Basic User Manual
Background Information
Unique background information in a template improves search
performance and accuracy during the grayscale pattern matching phase.
This requirement could conflict with the “color information” requirement
because background colors may not be appropriate during the color
location phase. Avoid this problem by choosing a template with sufficient
background information for grayscale pattern matching while specifying
the exclusion of the background color during the color location phase.
Refer to the Training the Pattern Matching Algorithm section of this
chapter for more information about how to ignore colors.
Training the Color Pattern Matching Algorithm
After you have created a good template image, the color pattern
matching algorithm learns the important features of the template. Use
CWIMAQVision.LearnColorPattern to learn the template. The
learning process depends on the type of matching that you expect to
perform. By default, the color pattern matching algorithm learns only those
features from the template that are necessary for shift-invariant matching.
However, if you want to match the template at any orientation, the learning
process must consider the possibility of arbitrary orientations. Use the
CWIMAQLearnColorPatternOptions.LearnMode property to specify
which type of learning mode to use.
Exclude colors in the template that you are not interested in using during
the search phase. Typically, you should ignore colors that either belong to
the background of the object or are not unique to the template, reducing the
potential for incorrect matches during the color location phase. You can
learn the colors to ignore using
CWIMAQVision.LearnColor. Use the
CWIMAQLearnColorPatternOptions.IgnoreBlackAndWhite or
CWIMAQLearnColorPatternOptions.IgnoreColorSpectra
properties to ignore background colors.
The training or learning process is time-intensive because the
algorithm attempts to find optimal features of the template for the
particular matching process. However, you can train the pattern
matching algorithm offline, and save the template image using
CWIMAQVision.WriteImageAndVisionInfo.