03_01_PatMax_Logic
03_01_PatMax_Logic
PatMax Pattern & At the end of this section Participants will be able to:
Logic Tools - Apply the Property Sheet parameters and auto-inserted
Section 3 information of the PatMax Pattern tool to a sample image
- Configure the PatMax Pattern tools
- Create basic mathematical formulas using the If, And, InRange
and Not functions
Section 3 | Slide 2
In section three of the In-Sight Spreadsheet Standard class we will cover the PatMax At the end of this section Participants will be able to:
Pattern and Logic tools.
• Apply the Property Sheet parameters and auto-inserted information of the
The PatMax® Pattern tools offer high speed and high accuracy pattern matching using a PatMax Pattern tools to a sample image
feature-based representation. • Configure the PatMax Pattern tools
There are two PatMax Pattern tools that will be covered in this section: • Create basic mathematical formulas using the If, And, InRange and Not functions
• FindPatMaxPatterns which finds matches to a trained pattern using PatMax algorithms.
• TrainPatMaxPattern which extracts and trains a pattern from an image using PatMax
algorithms.
Logic functions provide Boolean algebra and conditional testing capabilities to the In-Sight
Spreadsheet. All bitwise functions perform the corresponding logical operation on each bit
position in the binary representation of the arguments and return the resulting binary
number in decimal form.
1
2
3
PatMax Tools
4 4 4
The PatMax® Pattern tools offer high speed and high accuracy pattern matching using a Over the course of this class we will use the tools learned to inspect the Cognex block.
feature-based representation.
To pass, the block must meet these tests:
There are two PatMax Pattern tools that will be covered in this section: 1. The Block must be present in the Field of View.
• FindPatMaxPatterns which finds matches to a trained pattern using PatMax algorithms. • Tools used TrainPatMaxPatterns and FindPatMaxPatterns.
• TrainPatMaxPattern which extracts and trains a pattern from an image using PatMax 2. The Block must not have the gouge.
algorithms. • Tool used ExtractHistogram.
3. The Block must be the correct length (within tolerance).
• Tool used FindSegment.
4. The Block must have 3 correctly sized holes (within tolerance).
• Tool used ExtractBlobs.
The goal of a vision application is to determine whether a part is Good or Bad, based on PatMax more closely resembles the way humans discern between similar things and
image analysis of the part. You need to define as precisely as possible what distinguishes a recognize familiar ones.
good part from a bad part in order to design an inspection system.
Consider the examples of remembering the faces of people you know well.
Considerations: Even if the faces change due to lighting, extra features, and fewer features, you will
• Which vision tools might you use for analysis? Sometimes only one tool will work, still likely recognize them if there is enough of the original detail intact.
sometimes there will be a choice.
• Do you require real world units of measure rather than pixels?
• How many cameras and which model(s) will you need to capture all of the
required detail?
• Variations in color can affect how the part appears to the vision system.
• If the parts move, will you require strobe lighting?
• For parts whose position varies, how will you locate and fixture the part?
• How will you trigger your system to acquire an image?
• What outputs will your system need to send results to external hardware, for
example, to reject a part?
• How will the operator interact with the system?
FindPatMaxPatterns
• Finds features in an image
based on the trained pattern
TrainPatMaxPattern
• Extracts and trains a pattern: a
trained geometric description
of an object you wish to find
The PatMax Pattern tool offers three key features that distinguish it from other pattern- The TrainPatMaxPattern function extracts and trains a pattern from an image for use with
location technologies in machine vision: the FindPatMaxPatterns function.
• High-speed location of objects whose appearance is rotated, scaled, and/or
stretched
• Location technology that is based on object shape, not greyscale values
• Very high accuracy
TrainPatMaxPattern
• Extracts and trains a pattern; a trained geometric description of an object you
wish to find
Algorithm
The Pattern Region, also known as the Region of Interest (ROI), specifies the region of The Pattern Settings specifies the settings for training the pattern.
the image that undergoes analysis and creates a rectangular image region that can be
transformed and rotated. The Algorithm specifies which algorithm to use for training the pattern.
• PatMax (default) – The PatMax algorithm offers higher accuracy than PatQuick but
Double-click the Pattern Region parameter and place the region where you would like the requires more time to execute.
tool to search. Notice the red rectangle around the Cognex logo. • PatQuick – The PatQuick algorithm offers lower accuracy than PatMax but requires less
time to execute.
Matching Polarity
Trained Pattern
Mismatched Polarity
Elasticity specifies the amount of perimeter deviation (0 to 10; 0 = default). Ignore Polarity specifies whether matches can be found that contain color-inverted match
features with respect to the trained pattern.
0 = No Tolerance
1 or Greater = Flexible Boundary 0 = Off (default) – Do not match color-inverted features.
1 = On – Allow color-inverted match features.
Ignoring polarity increases the variety of patterns that PatMax finds. The figure above
shows some examples of matched and mismatched polarities. If you configure PatMax to
ignore polarity, it finds all of the patterns shown in the figure. If you configure PatMax to
consider polarity, it might not find the pattern in the bottom row, or it might find them but
assign them lower scores than the patterns in the top row.
Granularity
Coarse Granularity
Fine Granularity
Notice the green outline around the logo that is showing us the granularity of the shapes of The TrainPatMaxPattern outputs a Patterns data structure containing a trained pattern, or
the letters. #ERR if any of the input parameters are invalid. The function is Disabled by default to avoid
accidently training a new pattern on the next acquisition.
Coarse Granularity specifies the coarse granularity as a pixel value. Coarse granularity is
used to find large features to find an approximate pattern match in a run-time image quickly When TrainPatMaxPatterns is initially inserted into a cell, the Trained status automatically
(0 to 10; 0 = default). appears in the adjacent cell to the right. If a pattern cannot be trained #ERR is inserted.
The function will return a 1 is the pattern has successfully trained, and a 0 if a pattern
Fine Granularity specifies the fine granularity as a pixel value. Fine granularity is used to cannot be trained.
find small features to determine the pattern location precisely (0 to 10: 0 = default).
NOTE: If a value of less than 1.0 is specified both Coarse Granularity and Fine Granularity
parameter values are calculated automatically.
The value for Fine Granularity cannot be greater than the value for Coarse Granularity.
The FindPatMaxPatterns function finds objects in an image based on a trained pattern. Find Region, also known as the Region of Interest (ROI) specifies the region of the image
FindPatMaxPatterns finds patterns within an image based on a trained pattern from a that undergoes analysis and creates a rectangular image region that can be transformed
Patterns structure. and rotated.
Double-click the Find Region parameter and place the region where you would like the tool
to search.
TIP: With this parameter selected you can click the Maximize Region button on the property
sheet’s toolbar to maximize the region and cover the entire image.
0 80 100
The Pattern parameter must reference a spreadsheet cell that contains a valid Patterns The Accept function specifies the acceptance threshold, which is the lowest score of a
data structure returned by the TrainPatMaxPattern function. valid instance. The score for a potential match must be greater than the value of the
acceptance threshold or that match will not be returned (0 to 100; default 50).
The Find Tolerances parameters specify the settings for finding patterns that are rotated The Algorithm parameter for the FindPatMaxPatterns tool specifies the algorithm to sue to
or scaled with respect to the trained pattern. process the image for the trained pattern.
• PatMax = The PatMax algorithm offers higher accuracy than PatQuick but
Angle Start – specifies the angle at which to begin searching for matches, in requires more time to execute.
degrees counter-clockwise (-180 to 180; default = -15) • PatQuick = The PatQuick algorithm offers lower accuracy then PatMax but
Angle End – specifies the angle at which to stop searching for matches in degrees requires less time to execute.
counter-clockwise (-180 to 180; default = 15) • Trained Pattern (default) = The FindPatMaxPatterns function uses the algorithm
Scale Start – specifies the scale at which to begin searching for matches (1 to (PatMax or PatQuick) specified in the Algorithm parameter of the
10000; default = 100) TrainPatMaxPattern function referenced in the Pattern parameter.
Scale End – specifies the scale at which to stop searching for matches (1 to 10000;
default = 100)
Aspect Ratio – limits match-finding to uniform-scale or allows aspect ratio change in
X or Y, in addition to uniform scale.
Aspect Start – specifies the minimum scale change at which to begin searching for
matches, as a percentage of the trained pattern (1 to 10000; default = 100)
Aspect End – specifies the maximum scale change at which to stop searching for
matches, as a percentage of the trained pattern (1 to 10000; default = 100)
GetRow($B$6,C6)
GetCol($B$6,C6)
GetAngle($B$6,C6)
GetScale($B$6,C6)
GetScore($B$6,C6)
The FindPatMaxPatterns function outputs a Patterns data structure containing a model and PatMax RedLine offers the pattern-matching excellence of PatMax, but is designed to
a list of pattern responses sorted by score, or #ERR if any of the input parameters are deliver blazing fast speeds, especially for high-resolution images. Best of all, there is no
invalid or no matching patterns could be found. loss of search accuracy or robustness. PatMax RedLine finds trained patterns in run-time
images no matter what combinations of transformations – in size, rotation, or location – the
When FindPatMaxPatterns is initially inserted into a cell, a result table is created in the pattern has undergone.
spreadsheet.
PatMax RedLine is ideal for industries and applications that require:
• Large fields of view (FOV) and regions of interest
• High Accuracy
• Large angle and scale tolerances
• Multiple targets
PatMax RedLine marries high performance with high-resolution analysis. With its fast and
accurate pattern-matching, PatMax RedLine eliminates the tradeoff between speed and
accuracy.
Logic Tools
In this section we will review a number of the Mathematical Logic Tools. In-Sight has an extensive set of Vision, Mathematical, and other types of functions. The
ultimate goal is to make a decision about an object being inspected using the information
returned by the vision tools.
- Logic
- Lookup
- Math
- Statistics
- Trigonometry
Logic functions provide Boolean algebra and conditional testing capabilities in the In-Sight
spreadsheet. All bitwise functions perform the corresponding logical operation on each bit
position in the binary representation of the arguments and return the resulting binary
number in decimal form.
Example: Example:
A1 = 200 A1 = 200
A2 = A1=128 A2 = A1<128
A2 contains 0 A2 contains 0
For the opposite use !=
Example: Example:
A1 = 200 A1 = 200
A2= If (A1<128, 1, 0) A2= If (A1<128, 1, 0)
A2 = If (A1<128, “Good”, “Bad”) A2 = If (A1<128, “Good”, “Bad”)
- A2 contains string of characters “Bad” - A2 contains string of characters “Bad”
Complete:
Section 3
Skills Journal
Section 3 | Slide 29
Complete:
Skills Journal (image designed by pngtree)
Lab Exercise
Section 3 | Slide 29