<< FilterBySize IPD - Image Processing Design GetVideoInfo >>

IPD - Image Processing Design >> IPD - Image Processing Design > FindBestMatches

FindBestMatches

searches the positions where a template image is most similar to a source image

Calling Sequence

MatchList = FindBestMatches(Match, TemplateImageSize, Method);

Parameters

Match

2D matrix of type double, is the result of MatchTemplate

TemplateImageSize

vector with two elements, specifies the numbers of rows and columns of template image

Method

constant of type uint8, the following values are possible:

  • MATCH_LEAST_SQUARES: sum of quadratic gray value differences between source and template pixels

  • MATCH_CORRELATION: correlation between template image and covered part of source image

  • MATCH_LEAST_SQUARES_NORM: normalized sum of quadratic gray value differences between source and template pixels

  • MATCH_CORRELATION_NORM: normalized correlation between template image and covered part of source image

MatchList

matrix with two columns, each line contains the coordinates of a pixel. The first elements specifies the x coordinate, the second specifies the y coordinate

Description

This function earches the positions where a template image is most similar to a source image. The coordinates of the found pixels are re-calculated according to the size of the source image.

Examples

global MATCH_CORRELATION_NORM;

global IPD_PATH;

SourceColorImage = ReadImage(IPD_PATH + 'demos\teaset.png');

SourceImage = RGB2Gray(SourceColorImage);

TemplateColorImage = ReadImage(IPD_PATH + 'demos\cropped_image.png');

TemplateImage = RGB2Gray(TemplateColorImage);

Match = MatchTemplate(SourceImage, TemplateImage, MATCH_CORRELATION_NORM);
                      
MatchList = FindBestMatches(Match, size(TemplateImage), MATCH_CORRELATION_NORM);
                            
SquareList = list();
                            
for n = 1 : size(MatchList, 1)
  
 SquareList($ + 1) = struct('BoundingBox', cat(2, MatchList(n, :) - [1 1], [3 3])');
  
end;                            

SourceHandle = figure();
                            
ShowColorImage(SourceColorImage, 'Image with Marked Match Positions');

DrawBoundingBoxes(SquareList, [0 1 0], SourceHandle);

TemplateHandle = figure();

ShowColorImage(TemplateColorImage, 'Template Image');

See Also

<< FilterBySize IPD - Image Processing Design GetVideoInfo >>