NI Vision for LabVIEW

IMAQ Learn Pattern 6

  • Updated2023-02-21
  • 13 minute(s) read
Requires: NI Vision Development Module

Creates a description of the template image which you want to search during the matching phase of pattern matching. This description data is appended to the input template image. During the matching phase, the template descriptor is extracted from the template image and used to search for the template in the inspection image.

For more information on Pattern Matching, refer to Advanced Pattern Matching Concepts.

IMAQ Learn Pattern 6

ci32.gif

Algorithm specifies the pattern matching algorithm to use to search the Template Image in Image.

Refer to the NI Vision Concepts Help for in-depth information about each algorithm.

Low Discrepancy Sampling (0)

Uses a low discrepancy sampling algorithm. This algorithm extracts the most significant information to represent an image. Use one of the pyramidal matching algorithms instead if your template contains large regions of similar grayscale information, has a wide aspect ratio, or if it is very small.

Grayscale Value Pyramid (1)

Uses a grayscale value pyramid algorithm. This algorithm uses normalized gray values as features. It is useful when the template does not contain structured information but has intricate textures for dense edges.

Gradients Pyramid (2)

Uses a gradient pyramid algorithm. This algorithm uses filtered edge pixels as features. It is more resistant to occlusion and intensity changes as compared to the Grayscale Value Pyramid, and is often faster because of smaller amount of data. However, the strength and reliability of edges reduces at very low resolutions. This method requires the user to work at higher resolutions as compared to the Grayscale Value Pyramid method.

Geometric Pattern (3)

Geometric Matching locates regions ina grayscale image that match a model or template of a reference pattern. Geometric Matching is specialized to locate templates that are characterized by distinct geometric or shape information. When using Geometric Matching, you create a template that represents the object for which you are searching. The Machine Vision application then searches for instances of the template in each inspection imageand calculates a score for each match. The score relates how closely the template resembles the located matches. Geometric Matching finds template matches regardless of lighting variation, blur, noise, occlusion, and geometric transformations such as shifting, rotation, or scaling of the template.

cgenclasstagrefflat.gif

Image is a reference to the template image for which you want to search in the inspection image.

cgenclasstagrefflat.gif

Mask is an optional mask image. This image must be a U8 image. The VI learns only those pixels in the source image whose corresponding pixels in the mask are zero. Non-zero pixels are ignored. Do not set this parameter to learn the whole image.

cgenclasstagrefflat.gif

Weight Map is the image to specify weights to suppress noise and false defects in the defect map. Pixels with lower weights are enhanced and pixels with higher weights are suppressed in the defect map. Weight Map is used with the IMAQ Calculate Defect Map VI.

cnclst.gif

Angle Range specifies the range of angles for which the template should be learned. Passing an empty array will cause the VI to only search for shift-invariant matches.

csgl.gif

Start Angle specifies the starting angle of the template.

csgl.gif

End Angle specifies the ending angle of the template.

cerrcodeclst.gif

error in (no error) describes the error status before this VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurred before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.

cbool.gif

status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE.

ci32.gif

code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.

cstr.gif

source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.

c1dnclst.gif

Advanced Options sets a variety of algorithm-related options to use during the learning phase.

cu16.gif

Item determines the option you want to use during the learning phase of matching. The following values are possible:

LD Sampling - Search Strategy Support (0)

Specifies the aggressiveness of the search strategy available during the matching phase. Three types of search strategies are available. The default is 2.

  1. Conservative—Extracts template information for Conservative matching only.
  2. Balanced—Extracts template information for Balanced and Conservative matching.
  3. Aggressive—Extracts template information for Aggressive, Balanced, and Conservative matching.
LD Sampling - Initial Step Size (1)

Specifies the largest number of image pixels to shift the sample across the inspection image during the initial phase of matching. The default values are 5 for the Balanced search strategy and 3 for the Conservative search strategy. If the step size is not an odd integer, the VI coerces it to the next smaller odd integer.

Note  The Aggressive search strategy does not support the Initial Step Size option.
LD Sampling - Initial Sample Size (2)

Specifies the number of template pixels that you want to include in a sample for the initial phase of matching. The default is 0, which allows the algorithm to compute the Initial Sample Size. For optimal speed, the VI coerces sizes that are less than 240 to an integer multiple of 12 and coerces sizes greater than 240 to an integer multiple of 60.

LD Sampling - Initial Sample Size Factor (3)

Specifies the size of the sample for the initial phase of rotation-invariant matching as a percent of the template size, in pixels. The default is 0, which causes the VI to use the Initial Sample Size. If you provide values for both the Initial Sample Size Factor and the Initial Sample Size, the VI uses the Initial Sample Size. For optimal speed, the VI coerces sizes that are less than 240 to an integer multiple of 12 and coerces sizes greater than 240 to an integer multiple of 60.

LD Sampling - Initial Angular Accuracy (4)

Initial Angular Accuracy sets the angle accuracy, in degrees, to use during the initial phase of matching. The default is 6 degrees. The VI coerces the angle to the largest integer smaller than it that evenly divides 360. This option is not used in conjunction with the Aggressive search strategy.

LD Sampling - Final Sample Size (5)

Specifies the number of template pixels you want to add to the Initial Sample Size for the final phase of matching. These additional points include edge points. The default is 0, which allows the algorithm to compute the Final Sample Size. For optimal speed, the VI coerces sizes that are less than 240 to an integer multiple of 12 and coerces sizes greater than 240 to an integer multiple of 60.

LD Sampling - Final Sample Size Factor (6)

Specifies the size of the sample for the final phase of matching as a percent of the edge points in the template, in pixels. The default is 0, which causes the VI to use the Final Sample Size. If you provide values for both the Final Sample Size Factor and the Final Sample Size, the VI uses the Final Sample Size. For optimal speed, the VI coerces sizes that are less than 240 to an integer multiple of 12 and coerces sizes greater than 240 to an integer multiple of 60.

LD Sampling - Final Angular Accuracy (7)

Sets the angle accuracy, in degrees, to use during the final phase of the matching. The default is 1 degree. Use subpixel accuracy to achieve angle accuracy less than the default. This value must be no greater than the value for Initial Angular Accuracy. The VI coerces the angle to the largest integer smaller than it that evenly divides 360. This option is not used in conjunction with the Aggressive search strategy.

LD Sampling - Subpixel Sample Size (8)

Specifies the number of template pixels that you want to include in a sample for the subpixel phase of matching. The default is 0, which allows the algorithm to compute the Subpixel Sample Size. For optimal speed, the VI coerces sizes that are less than 240 to an integer multiple of 12 and coerces sizes greater than 240 to an integer multiple of 60.

LD Sampling - Subpixel Sample Size Factor (9)

Specifies the size of the sample for the subpixel phase of matching as a percent of the template size, in pixels. The default is 0, which causes the VI to use the Subpixel Sample Size. For optimal speed, the VI coerces sizes that are less than 240 to an integer multiple of 12 and coerces sizes greater than 240 to an integer multiple of 60.

LD Sampling - Match Offset X Position (10)

Specifies the number of pixels the VI shifts the origin of the template from the center of the template image. The match offset is used by the IMAQ Match Pattern 4 VI to set the Position element of the resulting Matches cluster for each template match within a target image. The default value is (0, 0), which sets the center of the template image as the origin of the template.

LD Sampling - Match Offset Y Position (11)

Specifies the number of pixels the VI shifts the origin of the template from the center of the template image. The Match offset is used by the IMAQ Match Pattern 4 VI to set the Position element of the resulting Matches cluster for each template match within a target image. The default value is (0, 0), which sets the center of the template image as the origin of the template.

LD Sampling - Match Offset Angle (12)

Specifies the angle by which each match is rotated round the origin of the template. The angle offset is used by the IMAQ Match Pattern 4 VI to set the Angle element of the resulting Matches cluster for each template match within a target image. The default value is 0 which does not change the angle of the matches.

Pyramid - Subpixel Sample Size (100)

Specifies the number of template pixels that you want to include in a sample for the subpixel phase of matching. The default is 0, which allows the algorithm to compute the Subpixel Sample Size. For optimal speed, the VI coerces sizes that are less than 240 to an integer multiple of 12 and coerces sizes greater than 240 to an integer multiple of 60.

Pyramid - Subpixel Sample Size Factor (101)

Specifies the size of the sample for the subpixel phase of matching as a percent of the template size, in pixels. The default is 0, which causes the VI to use the Subpixel Sample Size. For optimal speed, the VI coerces sizes that are less than 240 to an integer multiple of 12 and coerces sizes greater than 240 to an integer multiple of 60.

Pyramid - Match Offset X Position (102)

Specifies the number of pixels the VI shifts the origin of the template from the center of the template image. The match offset is used by the IMAQ Match Pattern 4 VI to set the Position element of the resulting Matches cluster for each template match within a target image. The default value is (0, 0), which sets the center of the template image as the origin of the template.

Pyramid - Match Offset Y Position (103)

Specifies the number of pixels the VI shifts the origin of the template from the center of the template image. The Match offset is used by the IMAQ Match Pattern 4 VI to set the Position element of the resulting Matches cluster for each template match within a target image. The default value is (0, 0), which sets the center of the template image as the origin of the template.

Pyramid - Match Offset Angle (104)

Specifies the angle by which each match is rotated round the origin of the template. The angle offset is used by the IMAQ Match Pattern 4 VI to set the Angle element of the resulting Matches cluster for each template match within a target image. The default value is 0 which does not change the angle of the matches.

Pyramid - Max Pyramid Level To Store (105)

Specifies the pyramid level up to which data is stored in a learned template when rotated templates are to be learned. The template data for pyramid levels less than this value is stripped away. A value of 0 implies that no data has been stripped, making the template the largest, while progressively higher values up to the computed Max Pyramid Level result in progressively smaller templates. The default value is 2, which means data for levels 1 and 0 is stripped. When learning a large template for a large angle range, the amount of data generated can be fairly significant and this parameter can be used to control the size. However, all the removed data needs to be re-computed by IMAQ Match Pattern 4, which increases match times. A trade-off needs to be made between a smaller template size and faster match times. Learning for Shift is not affected by this parameter.

Pyramid - Pre Process (106)

Specifies whether to pre-process the template image and the input image while learning and matching. The default value for this option is 0 indicating no pre-processing.

  • 0 - No Processing
  • 1 - Sobel and log transform. Template and match image are processed with sobel filter and log transform lookup table.
  • 2 - Sobel. Template and Match Image are processed with Sobel filter.
  • 3 - Non Linear Diffusion Filter. template and Match Image Pyramids are processed with Non Linear Diffusion (Anisotropic Diffusion) filter. This option reduces noise and improves edge contrast.
Pyramid - Percent of Pixels to keep for Gradient Template (107)

Specifies the percentage of gradient values that needs to be stored as part of the template. The default value is -1. The value -1 indicates an optimal value for the threshold will be computed. The minimum value is 5. The maximum value is 80.

cdbl.gif

Value is the value of the option you want to use during the learning phase.

igenclasstagrefflat.gif

Template Image Out is a reference to the template. This template image contains the data that defines the template pattern for the matching phase.

inclst.gif

Template Report contains information describing the parameters used while learning the template.

ii32.gif

Template Contrast gives the contrast value for the template used for learning.

ii32.gif

Grayvalue Max Pyramid Level shows the maximum pyramid level the template was learned when using the Grayscale Value Pyramid algorithm.

ii32.gif

Grayvalue Optimal Pyramid Level shows the optimal pyramid level as computed by the algorithm at which matching should be carried out when using the Grayscale Value Pyramid algorithm.

ii32.gif

Gradient Max Pyramid Level shows the maximum pyramid level the template was learned when using the Graidents Pyramid algorithm.

ii32.gif

Gradient Optimal Pyramid Level shows the optimal pyramid level as computed by the algorithm at which matching should be carried out when using the Graidents Pyramid algorithm.

ierrcodeclst.gif

error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out indicator on the front panel and select Explain Error from the shortcut menu for more information about the error.

ibool.gif

status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred.

ii32.gif

code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.

istr.gif

source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.

Log in to get a better experience