# FindPatMaxPatterns

Finds objects in an image based on a trained pattern. (A trained (internal) geometric description of an object you wish to find.) FindPatMaxPatterns finds patterns within an image based on a trained pattern from a Pattern structure.

## FindPatMaxPatterns Inputs

Parameter | Description
Image | This parameter must reference a spreadsheet cell that contains an Image data structure. By default, this parameter references cell A1 . This parameter can also reference other Image data structures, such as those returned by the Image Vision Data Access functions or Coordinate Transforms Functions.
Fixture | Defines the Find Region relative to a Fixture input or the output of a 2D Vision Tools function's image coordinate system. Setting the ROI relative to a Fixture ensures that if the Fixture is rotated or translated, the ROI will be rotated or translated in relation to the Fixture. The default setting is (0,0,0), the top leftmost corner of the image.
X | The X-offset, in image coordinates.
Y | The Y-offset, in image coordinates.
Theta | The rotation from the image X-axis, in the image coordinate system. (+/-360 degrees clockwise)
Find Region | Also known as the Region of Interest (ROI), specifies the region of the image that undergoes analysis. Double-click on the Region parameter to create an Interactive Graphics Mode that you can transform and rotate. Select this parameter and press the Maximize Region button on the Job Edit toolbar of the property sheet to automatically stretch the region to cover the entire image.
X | The X-offset of the origin, in fixture coordinates.
Y | The Y-offset of the origin, in fixture coordinates.
Width | The dimension along the X-axis of the region.
Height | The dimension along the Y-axis of the region.
Angle | The orientation, in fixture coordinates.
Curve | The angular deviation between the x-axis and the opposing boundary line of the region.
External Region | This parameter uses Cell References to an Annulus, Circle, Region, EditAnnulus, EditCircle, EditCompositeRegion, EditPolygon, and EditRegion. When this parameter is used, the function ignores the Region and Fixture settings and inspects the image area specified by referenced region. If an EditCompositeRegion control is referenced, the inspection area can be a mix of shapes. Each shape in the composite region can be assigned as added to or subtracted from (masking) the inspection area. Note: If this parameter has been set as a reference to an external region, to use the internal Region of the function, this parameter must be manually set to zero by entering the value 0 in place of the cell reference. Otherwise, the function continues to reference the external region.
Pattern | This argument must reference a spreadsheet cell that contains a valid Patterns data structure returned by a TrainPatMaxPattern function.
Number to Find | Specifies the maximum number of pattern matches to return (1 to 1024; default = 1).
Accept | Specifies the acceptance threshold, which is the lowest score of a 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).
Contrast | Specifies the lowest contrast of a valid instance. The contrast for a potential match must be greater than the value of the Contrast Threshold or that instance will not be considered (0 to 255; default = 10). A low contrast threshold is used for low-contrast images; a high contrast threshold is used for high-contrast images.
Clutter in Score | Specifies whether missing or occluded pattern features will reduce the response score(s).
0 = OFF | Do not include the effect of clutter in score.
1 = ON (default) | Include the effect of clutter in score.
Outside Region | Specifies the percentage of pattern features that may be found outside the Find Region without degrading the pattern response score (0 to 100; default = 0).
Find Tolerances | Specifies the settings for finding patterns that are rotated or scaled with respect to the trained pattern.
Angle Start | Specifies the angle at which to begin searching for matches, in degrees counter-clockwise (-180 to 180; default = -15).
Angle End | Specifies the angle at which to stop searching for matches, in degrees counter-clockwise (-180 to 180; default = 15).
Scale Start | Specifies the scale at which to begin searching for matches (1 to 10000; default = 100).
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 only or allows aspect ratio change in X or Y, in addition to a uniform scale. Note: The Aspect Start and Aspect End parameters are disabled if Uniform Scale Change is selected.
0 = Uniform Scale Change
1 = Uniform and X Scale Change
2 = Uniform and Y Scale Change
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).
Find Overlapping | Specifies the settings for finding patterns that overlap each other with respect to position, rotation and scale.
XY Overlap | Specifies the expected position difference between multiple overlapping patterns in roughly the same X,Y location, as a percentage of the trained pattern size (0 to 100; default = 80). Note: Increasing this value allows finding multiple overlapping matches of the same pattern.
Angle Overlap | Specifies the expected angle between multiple rotated overlapping patterns in roughly the same X,Y location. A (0 to 360; default = 360). Note: The Angle Overlap parameter is disabled if the values for the Angle Start and Angle End parameters are equal to each other. Increasing this value allows finding multiple overlapping matches of the same pattern.
Scale Overlap | Specifies the expected uniform scale difference between multiple overlapping patterns in roughly the same X,Y location, as a percentage of the trained pattern size (1 to 10000; default = 140). Note: The Scale Overlap parameter is disabled if the values for the Scale Start and Scale End parameters are equal to each other. Increasing this value allows finding multiple overlapping matches of the same pattern.
Aspect Overlap | Specifies the expected aspect scale difference between multiple overlapping patterns in roughly the same X,Y location, as a percentage of the trained pattern size (1 to 10000; default = 140). Note: The Aspect Overlap parameter is disabled if Uniform Scale Change is selected for the Aspect Ratio parameter or if the if the values for the Aspect Start and Aspect End parameters are equal to each other. Increasing this value allows finding multiple overlapping matches of the same pattern.
Timeout | Specifies the amount of time, in milliseconds (0 to 30000), that the function will search for patterns before execution is halted and an #ERR is returned. Setting the value to 0 will disable the setting and a timeout will not be applied.
Algorithm | Specifies the algorithm that will be used to process the image for the trained pattern.
0 = PatMax | The PatMax algorithm offers higher accuracy than PatQuick, but requires more time to execute.
1 = PatQuick | The PatQuick algorithm offers lower accuracy than PatMax, but requires less time to execute.
2 = Trained Pattern (default) | The FindPatMaxPatterns function will use the algorithm (PatMax or PatQuick) specified in the Algorithm parameter of the TrainPatMaxPattern function referenced in the Pattern parameter.
Show | Specifies the display mode for graphical overlays on top of the image.
0 = hide all (default) | All graphics will be hidden, except when the cell containing the FindPatMaxPatterns function is the active cell in the spreadsheet.
1 = result graphics only | A cross will be displayed for each found pattern at all times.
2 = input and result graphics | Both the input image region and a cross for each found pattern will be displayed at all times.
3 = show all: input, result, and match features | The input image region, a cross for each found pattern, and the PatMax® match features will be displayed at all times. Note: Match features are not shown when PatQuick is selected for the TrainPatMaxPattern's Algorithm parameter. Green match features = 67 to 100 percent match. Yellow match features = 20 to 66 percent match. Red match features = less than 20 percent match.

## FindPatMaxPatterns Outputs

Returns | A Patterns data structure containing a model and a list of pattern responses sorted by score, or #ERR if any of the input parameters are invalid or no matching patterns could be found.
Results | When FindPatMaxPatterns is initially inserted into a cell, a result table is created in the spreadsheet. Note: While in the function's property sheet, supplemental information strings are provided as suggestions for better finding patterns. For a list of possible information strings: [Value] result(s) discarded due to low contrast. [Value] result(s) discarded due proximity to more accurate results. [Value] result(s) discarded due to excess clutter. Trained pattern contains too few features for current parameter settings. To insert information strings into the spreadsheet, use the GetInfoString Vision Data Access function.

## FindPatMaxPatterns Vision Data Access functions

The following Patterns Vision Data Access functions are automatically inserted into the spreadsheet to create the result table:

Label | Function | Description
X | GetX(Patterns, Index) | The x-coordinate of the pattern position.
Y | GetY(Patterns, Index) | The y-coordinate of the pattern position.
Angle | GetAngle(Patterns, Index) | The orientation of the pattern position.
Scale | GetScale(Patterns, Index) | The size of the pattern found compared to the trained model, as a percentage of the model size.
Score | GetScore(Patterns, Index) | The pattern response score.