IMCORRCOEF

NAME
SYNOPSIS
PARAMETERS
DESCRIPTION
EXAMPLE
AUTHORS
AVAILABILITY
SEE ALSO

NAME

imcorrcoef - template matching by normalized correlation

SYNOPSIS

C = imcorrcoef(Img, template)

PARAMETERS

Img
M x N Grayscale image in any range.
template
n x n matrix, n odd. A small object to be found in the image.
C
The correlation coefficient image. Its highest value occurs where the template matches exactly.

DESCRIPTION

Function imcorrcoef performs template matching by 2D correlation of a grayscale image and a template. This means the template is compared to the image pixel-by-pixel, for every possible translation of the template. The result is normalized to range from -1 to +1. You may also use the absolute value of this measure.
This is an expensive calculation, and should be used only for small templates. The object to be detected must appear in the image with very little variation of rotation and scale. This is useful if you can restrict the image capture to avoid those problems.

EXAMPLE

//
// Let's detect the letter "B" in a license plate
//
img = gray_imread(SIPDIR+'images/plate.jpg');
xbasc(),  imshow(img);
template = gray_imread(SIPDIR+'images/template.jpg');
xbasc(),  imshow(template);

C = imcorrcoef(img, template);

xbasc();
imshow(img+2*(C==maxi(C)),[]);  // letter is detected!!

AUTHORS

Ricardo Fabbri <rfabbri@if.sc.usp.br>

AVAILABILITY

The latest version of the Scilab Image Processing toolbox can be found at
http://siptoolbox.sourceforge.net

SEE ALSO

imconv, mkfilter, edge