Skip to content

exhaustive_matchexhaustive_matchExhaustiveMatchExhaustiveMatchexhaustive_matchexhaustive_match🔗

Short description🔗

exhaustive_matchexhaustive_matchExhaustiveMatchExhaustiveMatchexhaustive_matchexhaustive_match — Matching of a template and an image.

Signature🔗

exhaustive_match( image Image, region RegionOfInterest, image ImageTemplate, out image ImageMatch, string Mode )exhaustive_match( Image, RegionOfInterest, ImageTemplate : ImageMatch : Mode : )void ExhaustiveMatch( const HObject& Image, const HObject& RegionOfInterest, const HObject& ImageTemplate, HObject* ImageMatch, const HTuple& Mode )static void HOperatorSet.ExhaustiveMatch( HObject image, HObject regionOfInterest, HObject imageTemplate, out HObject imageMatch, HTuple mode )def exhaustive_match( image: HObject, region_of_interest: HObject, image_template: HObject, mode: str ) -> HObject

Herror exhaustive_match( const Hobject Image, const Hobject RegionOfInterest, const Hobject ImageTemplate, Hobject* ImageMatch, const char* Mode )

Herror T_exhaustive_match( const Hobject Image, const Hobject RegionOfInterest, const Hobject ImageTemplate, Hobject* ImageMatch, const Htuple Mode )

HImage HImage::ExhaustiveMatch( const HRegion& RegionOfInterest, const HImage& ImageTemplate, const HString& Mode ) const

HImage HImage::ExhaustiveMatch( const HRegion& RegionOfInterest, const HImage& ImageTemplate, const char* Mode ) const

HImage HImage::ExhaustiveMatch( const HRegion& RegionOfInterest, const HImage& ImageTemplate, const wchar_t* Mode ) const (Windows only)

HImage HImage.ExhaustiveMatch( HRegion regionOfInterest, HImage imageTemplate, string mode )

Description🔗

The operator exhaustive_matchExhaustiveMatch matches ImageTemplateimageTemplateimage_template and Imageimageimage within the region of interest RegionOfInterestregionOfInterestregion_of_interest. Hereby the ImageTemplateimageTemplateimage_template will be moved over all points of Imageimageimage which lie within the RegionOfInterestregionOfInterestregion_of_interest. With regard to the parameter Modemodemode, a matching criterion will be calculated. The result values will be stored in ImageMatchimageMatchimage_match.

The following matching criteria (Modemodemode) are available:

  • ‘norm_correlation’

    \[\begin{eqnarray*} \textrm{ImageMatch}[i][j] = 255 \cdot \frac{ \sum_{u,v} {( \textrm{Image}[i-u][j-v] \cdot \textrm{ImageTemplate}[l-u][c-v])} } {\sqrt{ \sum_{u,v}{(\textrm{Image}[i-u][j-v]^2)} \cdot \sum_{u,v}{(\textrm{ImageTemplate}[l-u][c-v]^2)}} } \end{eqnarray*}\]

    whereby \(X[i][j]\) indicates the gray value in the \(i\)-th column and \(j\)-th row of the image \(X\). \((l,c)\) is the center of the region of ImageTemplateimageTemplateimage_template. \(u\) and \(v\) are chosen so that all points of the template will be reached, \(i,j\) run across the RegionOfInterestregionOfInterestregion_of_interest. At the image frame only those parts of ImageTemplateimageTemplateimage_template will be considered which lie inside the image (i.e. \(u\) and \(v\) will be restricted correspondingly). Higher values returned in ImageMatchimageMatchimage_match, represent better matches.

    Range of values: [00 … 255255 (best fit)].

  • ‘dfd’ Calculating the average “displaced frame difference”:

    \[\begin{eqnarray*} \textrm{ImageMatch}[i][j] = \frac{\sum_{u,v} {|\textrm{Image}[i-u][j-v] - \textrm{ImageTemplate}[l-u][c-v]|}} {AREA ( ImageTemplate )} \end{eqnarray*}\]

    The terms are the same as in 'norm_correlation'"norm_correlation". \(AREA(X)\) means the area of the region \(X\). Lower values returned in ImageMatchimageMatchimage_match, represent better matches.

    Range of values: [00 (best fit) .. 255255].

To calculate the normalized correlation as well as the ``displaced frame difference’’ is (with regard to the area of ImageTemplateimageTemplateimage_template) very time consuming. Therefore it is important to restrict the input region (RegionOfInterestregionOfInterestregion_of_interest if possible, i.e. to apply the filter only in a very confined “region of interest”.

As far as quality is concerned, both modes return comparable results, whereby the mode 'dfd'"dfd" is faster by a factor of about 3.5.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on internal data level.

Parameters🔗

Imageimageimage (input_object) singlechannelimage(-array) → object (byte)object (byte)HObject (byte)HImage (byte)HObject (byte)Hobject (byte)

Input image.

RegionOfInterestregionOfInterestregion_of_interest (input_object) region → objectobjectHObjectHRegionHObjectHobject

Area to be searched in the input image.

ImageTemplateimageTemplateimage_template (input_object) singlechannelimage → object (byte)object (byte)HObject (byte)HImage (byte)HObject (byte)Hobject (byte)

This area will be “matched” by Imageimageimage within the RegionOfInterestregionOfInterestregion_of_interest.

ImageMatchimageMatchimage_match (output_object) image(-array) → object (byte)object (byte)HObject (byte)HImage (byte)HObject (byte)Hobject * (byte)

Result image: values of the matching criterion.

Modemodemode (input_control) string → (string)(string)HTuple (HString)HTuple (string)strHtuple (char*)

Desired matching criterion.

Default: 'dfd'"dfd"
List of values: 'dfd', 'norm_correlation'"dfd", "norm_correlation"

Example🔗

(HDevelop)


read_image(Image,'monkey')
dev_display(Image)
draw_rectangle2(WindowHandle,Row,Column,Phi,Length1,Length2)
gen_rectangle2(Rectangle,Row,Column,Phi,Length1,Length2)
reduce_domain(Image,Rectangle,Template)
exhaustive_match(Image,Image,Template,ImageMatch,'dfd')
invert_image(ImageMatch,ImageInvert)
local_max(Image,Maxima)
union1(Maxima,AllMaxima)
add_channels(AllMaxima,ImageInvert,FitMaxima)
threshold(FitMaxima,BestFit,230.0,255.0)
dev_display(BestFit)
(C)
read_image(&Image,"monkey")\;
disp_image(Image,WindowHandle)\;
/* mark one eye */
draw_rectangle2(WindowHandle,&Row,&Column,&Phi,&Length1,&Length2)\;
gen_rectangle2(&Rectangle,Row,Column,Phi,Length1,Length2)\;
reduce_domain(Image,Rectangle,&Template)\;
exhaustive_match(Image,Image,Template,&ImageMatch,'dfd')\;
invert_image(ImageMatch,&ImageInvert)\;
local_max(ImageInvert,&Maxima)\;
union1(Maxima,&AllMaxima)\;
add_channels(AllMaxima,ImageInvert,&FitMaxima)\;
threshold(FitMaxima,&BestFit,230.0,255.0)\;
disp_region(BestFit,WindowHandle)\;

Result🔗

If the parameter values are correct, the operator exhaustive_matchExhaustiveMatch returns the value 2 (H_MSG_TRUE). If the input is empty (no input images are available) the behavior can be set via set_system('no_object_result',<Result>). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

draw_regionDrawRegion, draw_rectangle1DrawRectangle1

Possible successors

local_maxLocalMax, thresholdThreshold

Alternatives

exhaustive_match_mgExhaustiveMatchMg

Module🔗

Foundation