ClassesClasses | | Operators

exhaustive_matchexhaustive_matchExhaustiveMatchExhaustiveMatch (Operator)

Name

exhaustive_matchexhaustive_matchExhaustiveMatchExhaustiveMatch — Matching of a template and an image.

Signature

exhaustive_match(Image, RegionOfInterest, ImageTemplate : ImageMatch : Mode : )

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)

void ExhaustiveMatch(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

static void HOperatorSet.ExhaustiveMatch(HObject image, HObject regionOfInterest, HObject imageTemplate, out HObject imageMatch, HTuple mode)

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

Description

The operator exhaustive_matchexhaustive_matchExhaustiveMatchExhaustiveMatchExhaustiveMatch matches ImageTemplateImageTemplateImageTemplateImageTemplateimageTemplate and ImageImageImageImageimage within the region of interest RegionOfInterestRegionOfInterestRegionOfInterestRegionOfInterestregionOfInterest. Hereby the ImageTemplateImageTemplateImageTemplateImageTemplateimageTemplate will be moved over all points of ImageImageImageImageimage which lie within the RegionOfInterestRegionOfInterestRegionOfInterestRegionOfInterestregionOfInterest. With regard to the parameter ModeModeModeModemode, a matching criterion will be calculated. The result values will be stored in ImageMatchImageMatchImageMatchImageMatchimageMatch.

The following matching criteria (ModeModeModeModemode) are available:

'norm_correlation'

whereby X[i][j] indicates the grayvalue in the ith column and jth row of the image X. (l,c) is the center of the region of ImageTemplateImageTemplateImageTemplateImageTemplateimageTemplate. u and v are chosen so that all points of the template will be reached, i,j run across the RegionOfInterestRegionOfInterestRegionOfInterestRegionOfInterestregionOfInterest. At the image frame only those parts of ImageTemplateImageTemplateImageTemplateImageTemplateimageTemplate will be considered which lie inside the image (i.e. u and v will be restricted correspondingly). Range of values: 0 - 255 (best fit).

'dfd'

Calculating the average "displaced frame difference":

The terms are the same as in 'norm_correlation'. AREA ( X ) means the area of the region X. Range of value 0 (best fit) - 255.

To calculate the normalized correlation as well as the “displaced frame difference” is (with regard to the area of ImageTemplateImageTemplateImageTemplateImageTemplateimageTemplate) very time consuming. Therefore it is important to restrict the input region (RegionOfInterestRegionOfInterestRegionOfInterestRegionOfInterestregionOfInterest 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' is faster by a factor of about 3.5.

Execution Information

Parameters

ImageImageImageImageimage (input_object)  singlechannelimage(-array) objectHImageHImageHobject (byte)

Input image.

RegionOfInterestRegionOfInterestRegionOfInterestRegionOfInterestregionOfInterest (input_object)  region objectHRegionHRegionHobject

Area to be searched in the input image.

ImageTemplateImageTemplateImageTemplateImageTemplateimageTemplate (input_object)  singlechannelimage objectHImageHImageHobject (byte)

This area will be “matched” by ImageImageImageImageimage within the RegionOfInterestRegionOfInterestRegionOfInterestRegionOfInterestregionOfInterest.

ImageMatchImageMatchImageMatchImageMatchimageMatch (output_object)  image(-array) objectHImageHImageHobject * (byte)

Result image: values of the matching criterion.

ModeModeModeModemode (input_control)  string HTupleHTupleHtuple (string) (string) (HString) (char*)

Desired matching criterion.

Default value: 'dfd' "dfd" "dfd" "dfd" "dfd"

List of values: 'dfd'"dfd""dfd""dfd""dfd", 'norm_correlation'"norm_correlation""norm_correlation""norm_correlation""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)

Example (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);

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)

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)

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)

Result

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

Possible Predecessors

draw_regiondraw_regionDrawRegionDrawRegionDrawRegion, draw_rectangle1draw_rectangle1DrawRectangle1DrawRectangle1DrawRectangle1

Possible Successors

local_maxlocal_maxLocalMaxLocalMaxLocalMax, thresholdthresholdThresholdThresholdThreshold

Alternatives

exhaustive_match_mgexhaustive_match_mgExhaustiveMatchMgExhaustiveMatchMgExhaustiveMatchMg

Module

Foundation


ClassesClasses | | Operators