0% found this document useful (0 votes)
14 views

03_01_PatMax_Logic

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

03_01_PatMax_Logic

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Objectives

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.

Section 3 | Slide 1 Section 3 | Slide 2


Block Inspection

1
2
3
PatMax Tools

4 4 4

Section 3 | Slide 3 Section 3 | Slide 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.

Section 3 | Slide 3 Section 3 | Slide 4


Pattern Applications Why Does It Work?

Section 3 | Slide 5 Section 3 | Slide 6

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?

Section 3 | Slide 5 Section 3 | Slide 6


How Does PatMax Work? TrainPatMaxPattern

PatMax uses two tools:

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

Section 3 | Slide 7 Section 3 | Slide 8

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

PatMax uses two tools:


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

Section 3 | Slide 7 Section 3 | Slide 8


Pattern Region Pattern Settings

Algorithm

Section 3 | Slide 9 Section 3 | Slide 10

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.

Section 3 | Slide 9 Section 3 | Slide 10


Pattern Settings Pattern Settings

Elasticity Ignore Polarity

Matching Polarity

Trained Pattern

Mismatched Polarity

Trained Pattern Elastic Change on Part

Section 3 | Slide 11 Section 3 | Slide 12

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.

Section 3 | Slide 11 Section 3 | Slide 12


Pattern Settings TrainPatMaxPatterns Results

Granularity

Coarse Granularity

Fine Granularity

Section 3 | Slide 13 Section 3 | Slide 14

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.

Section 3 | Slide 13 Section 3 | Slide 14


FindPatMaxPatterns Find Region

Section 3 | Slide 15 Section 3 | Slide 16

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.

Section 3 | Slide 15 Section 3 | Slide 16


Pattern Accept Threshold

0 80 100

Not Valid Accept Valid


Matches Threshold Matches

Section 3 | Slide 17 Section 3 | Slide 18

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).

Section 3 | Slide 17 Section 3 | Slide 18


Find Tolerances Algorithm

Section 3 | Slide 19 Section 3 | Slide 20

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)

Section 3 | Slide 19 Section 3 | Slide 20


FindPatMaxPatterns Results PatMax RedLine

GetRow($B$6,C6)

GetCol($B$6,C6)

GetAngle($B$6,C6)

GetScale($B$6,C6)

GetScore($B$6,C6)

Section 3 | Slide 21 Section 3 | Slide 22

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.

Section 3 | Slide 21 Section 3 | Slide 22


Mathematical Functions

Logic Tools

Section 3 | Slide 23 Section 3 | Slide 24

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

In this section we will focus on Logic functions.

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.

For all Logic functions:


- False = 0
- True = any non-zero result

Section 3 | Slide 23 Section 3 | Slide 24


Mathematical Operators: = Mathematical Operators: >, <, >=, <=

Value = Value Value (Symbol) Value

• If both numbers are equals returns 1 • If the condition is true, returns 1


• Otherwise returns 0 • Otherwise returns 0

Example: Example:
A1 = 200 A1 = 200
A2 = A1=128 A2 = A1<128
 A2 contains 0  A2 contains 0
For the opposite use !=

For string comparisons use Exact(Value, Value)

Section 3 | Slide 25 Section 3 | Slide 26

When functions evaluate numbers: When functions evaluate numbers:


- False = 0 - False = 0
- True = any other number (for example -5, -345, 1, 34 are all true) - True = any other number (for example -5, -345, 1, 34 are all true)

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”

Section 3 | Slide 25 Section 3 | Slide 26


Logic: If Summary

If (condition, true_value, false_value)


- Property Sheets make it easy to specify parameters for
a function
• If condition is True, cell gets true_value
• If condition is False, cell gets false_value - Auto-inserted functions are the most commonly needed
results from a tool
Example: - PatMax can be used to locate trained models when the
A1 = 200 appearance of the models is adversely affected
A2 = If (A1<128, 10, 20) - In-Sight has an extensive set of Logic functions that
 A2 contains 20 can be used to help make decisions about an
inspection
A2 = If (A1<128, “Good”, “Bad”)
 A2 contains string of characters “Bad”

Section 3 | Slide 27 Section 3 | Slide 28

When functions evaluate numbers: In this section we covered the following:


- False = 0 • Property Sheets make it easy to specify parameters for a function
- True = any other number (for example -5, -345, 1, 34 are all true) • Auto-inserted functions are the most commonly needed results from a tool
• PatMax can be used to locate trained models when the appearance of the
Example: models is adversely affected
A1 = 200 • In-Sight has an extensive set of Logic functions that can be used to help make
A2= If (A1<128, 1, 0) decisions about an inspection
A2 = If (A1<128, “Good”, “Bad”)
- A2 contains string of characters “Bad”

Section 3 | Slide 27 Section 3 | Slide 28


Skills Journal Lab Exercise

Complete:
Section 3
Skills Journal

Section 3 | Slide 29

Complete:
Skills Journal (image designed by pngtree)
Lab Exercise

Section 3 | Slide 29

You might also like