EasyMatch - Matching Area Patterns
EasyMatch learns a pattern and finds exact matches:
1. | The pattern is learned by defining an ROI that contains the object to be matched. This ROI is created after iteratively learning from several images which contain the object. |
2. | The parameters are tuned to ensure the pattern is found reliably. |
3. | Images can now be searched for one or more occurrences of the pattern, which may be translated, rotated or scaled. |
Learning and Matching a pattern

Learning workflow
Matching workflow

Select an image containing the pattern/ROI to be searched for and call LearnPattern.
The resulting pattern can be saved as a model for later use. You can repeat this process to search for and save multiple patterns.
Best pattern characteristics
● | repeatable, you need to know if it can translate or rotate or scale. |
● | represent the object to be located. |
It should:
□ | Keep the same appearance whatever the lighting conditions. |
□ | Remain at a fixed location with respect to the part. |
□ | Be rigid and not change shape. |
● | exhibit good contrast in small and large scale. It should be distinctly visible from a distance, and on a reduced image. |
● | not be invariant under the degrees of freedom to be measured. For instance, a pattern of black and white horizontal stripes cannot detect horizontal translation; a cog wheel cannot help measure large rotations. |
● | have a neutral background. If objects around the pattern in the ROI may change, this area should be neutralized by means of "don't care" pixels or a mask. |
● | have contrasted margin around the objects so that foreground and background intensities are seen. |
Customize Parameters
Parameters can be tuned to minimize processing time, but it still takes longer than EasyFind as the entire selected area is matched.
● | DontCareThreshold: If don't care areas are required, the corresponding pixels must hold a value below the DontCareThreshold. If all the background can be ignored, merely adjusting the DontCareThreshold to the right thresholding value can do. Otherwise, when the don't care area is unrelated to the threshold pattern image, the DontCareThreshold should be set to 1 and all pixels belonging to the don't care area should be set to black (value 0). |
● | MinReducedArea: To improve time performance, EasyMatch sub-samples the pattern. This parameter stipulates the minimum size of the pattern (as its area in pixels) during sub-sampling. The smaller the value, the faster the matching process, but, set too low, it decreases the matching process reliability. The value of MinReducedArea is computed automatically if AdvancedLearning is enabled (default behavior). Setting explicitly MinReducedArea will disable AdvancedLearning. A value of 64 is usually a good compromise. |
● | AdvancedLearning: If the pattern is defined as a ROI of an image, AdvancedLearning optimizes learning parameters, such as MinReducedArea, by using the whole image context. AdvancedLearning is enabled by default, as it leads to better results in case of tiled or periodic images. If MinReducedArea is set explicitly, AdvancedLearning is disabled. Please note that as AdvancedLearning changes the number of pixels in the pattern, it can have a significant impact on the matching process duration. |
● | FilteringMode: If the image has sharp gray-level transitions, it is better to choose a low-pass kernel instead of the usual uniform kernel. |
Learning a pattern

For each new image, one or more occurrences of the pattern is searched for, allowing it to translate, rotate or scale, using a single function call:
□ | Match: receives the target image/ROI as its argument and locates the desired occurrences of the pattern. |
You can set these parameters:
□ | Rotation range: MinAngle, MaxAngle. |
□ | Scaling range: MinScale, MaxScale. |
□ | Anisotropic scaling range: MinScaleX, MaxScaleX, MinScaleY, MaxScaleY. |
The following functions return the result of the matching:
□ | NumPositions returns the number of good matches found. A good match is defined as having a score higher than prescribed value (the MinScore threshold value). |
□ | GetPosition returns the coordinates of the N-th good match. The positions are sorted by decreasing score. |
If you want to match several patterns against the same image, create an EMatcher object for each pattern.
Matching a pattern

The best way to speed up this process is to minimize rotation and scaling, and limit the number of occurrences searched for.
● | Learning time: |
□ | Optimize number of searches: Searching all positions takes too long, so a sequence of searches is performed at various scales (reductions). The coarsest reduction is quick and approximate. Subsequent reductions work in a close neighborhood to improve location, drastically reducing the number of positions to be tried. The location accuracy is given by 2K, where K is the reduction number. |
□ | MinReducedArea. Indicates how small the pattern can be made for rough location. |
● | Matching time: |
□ | Correlation mode (way to compare the pattern and the image): CorrelationMode. Can be standard, offset-normalized, gain-normalized and fully normalized: the correlation is computed on continuous tone values. Normalization copes with variable light conditions, automatically adjusting the contrast and/or intensity of the pattern before comparison. |
□ | Contrast mode (way to deal with contrast inversions): ContrastMode. Lighting effects can cause an object to appear with inverted contrast, you can choose whether to keep inverted instances or not, and whether to match positive occurrences only, negative occurrences only or both. |
□ | Maximum positions (expected number of matches): MaxPositions, MaxInitialPositions. You can compel EasyMatch to consider more instances than needed at the coarse stage using the MaxInitialPositions parameter (this number is progressively reduced to reach MaxPositions in the final stage). |
□ | Minimum score (under which match is considered as false and is discarded): MinScore, InitialMinScore. |
□ | Sub-pixel accuracy: Interpolate. The accuracy with which the pattern is measured can be chosen (the less accurate, the faster). By default, the position parameters for each degree of freedom are computed with a precision of a pixel. Lower precision can be enforced. One tenth-of-a-pixel accuracy can be achieved. |
□ | Number of reduction steps: FinalReduction. Can speed up matching when coarse location is sufficient, range [0...NumReductions-1]. |
□ | Non-square pixels: GetPixelDimensions, SetPixelDimensions. When images are acquired with non-square pixels, rotated objects appear skewed. Taking the pixel aspect ratio into account can compensate for this effect. |
□ | "Don't care" pixels (ignored for correlation score) below the DontCareThreshold value. When the pattern is inscribed in a rectangular ROI, some parts of the ROI can be ignored by setting the pixels values below a threshold level. The same feature can be used if parts of the template change from sample to sample. |