beautypg.com

National Instruments IMAQ Vision for Measurement Studio User Manual

Page 63

background image

Chapter 5

Machine Vision

© National Instruments Corporation

5-17

IMAQ Vision for LabWindows/CVI User Manual

However, there may be applications in which the assumptions used in the
algorithm are not optimal. Knowing your particular application and the
images you want to process is useful in selecting the pattern matching
parameters. The following are parameters the influence the IMAQ Vision
pattern matching algorithm.

Match Mode

You can set the match mode to control how the pattern matching algorithm
treats the template at different orientations. If you expect the orientation of
valid matches to vary less than ±5

° from the template, set the

mode

element

of the options parameter to

IMAQ_MATCH_SHIFT_INVARIANT

. Otherwise,

set the mode element to

IMAQ_MATCH_ROTATION_INVARIANT

.

Shift-invariant matching is faster than rotation-invariant matching.

Minimum Contrast

You can set the minimum contrast to potentially increase the pattern
matching algorithm’s speed. Contrast is the difference between the smallest
and largest pixel values in a region. The pattern matching algorithm ignores
all image regions where contrast values fall beneath a set minimum contrast
value. If the search image has high contrast but contains some low contrast
regions, you can set a high minimum contrast value. By using a high
minimum contrast value, you exclude all areas in the image with low
contrast, significantly reducing the region in which the pattern matching
algorithm must search. If the search image has low contrast throughout, set
a low minimum contrast parameter to ensure that the pattern matching
algorithm looks for the template in all regions of the image. Use the

minContrast

element of the

imaqMatchPattern()

options parameter

to set the minimum contrast.

Rotation Angle Ranges

For matching objects that may rotate in the image, the pattern matching
algorithm, by default, allows any orientation between 0

° to 360°. If the

pattern rotation in your application is restricted to a certain range (for
example, from –15

° to 15°), you can provide this information to the pattern

matching algorithm by setting the

angleRanges

element of the

imaqMatchPattern()

options parameter. This information improves

your search time because the pattern matching algorithm looks for the
pattern at fewer angles.