Training the color pattern matching algorithm, Training the color pattern matching algorithm -20 – National Instruments IMAQ Vision for Measurement Studio User Manual

Page 66

Advertising
background image

Chapter 5

Machine Vision

IMAQ Vision for LabWindows/CVI User Manual

5-20

ni.com

Feature Detail

A template with relatively coarse features is less sensitive to variations in
size and rotation than a model with fine features. However, the model must
contain enough detail to identify it.

Positional Information

A template with strong edges in both the x and y directions is easier to
locate.

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 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, reducing 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()

.

Advertising