Training the color pattern matching algorithm, Training the color pattern matching algorithm -21 – National Instruments IMAQ Vision for LabWindows TM /CVI User Manual

Page 73

Advertising
background image

Chapter 5

Performing Machine Vision Tasks

© National Instruments Corporation

5-21

IMAQ Vision for LabWindows/CVI 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 desirable 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 Color 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

imaqLearnColorPattern()

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

learnMode

element of the

imaqLearnColorPattern()

options parameter 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, to reduce the
potential for incorrect matches during the color location phase. You can
ignore certain predefined colors using the

ignoreMode

element of the

options parameter. To ignore other colors, first learn the colors to ignore
using

imaqLearnColor()

. Then set the

colorsToIgnore

element of the

options parameter to the resulting

ColorInformation

structure from

imaqLearnColor()

.

The learning process is time-intensive because the algorithm attempts to
find unique features of the template that allow for fast, accurate matching.
However, you can train the pattern matching algorithm offline, and save the
template image using

imaqWriteVisionFile()

.

Advertising