SIP - Scilab Image Processing Toolbox >> SIP - Scilab Image Processing Toolbox > imcorrcoef
Template matching by normalized correlation
C = imcorrcoef(Img, template)
- M x N Grayscale image in any range.
- n x n matrix, n odd. A small object to be found in the image.
- The correlation coefficient image. Its highest value occurs where the template matches exactly.
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.
img = gray_imread(SIPDIR+'images/plate.gif');
template = gray_imread(SIPDIR+'images/template.jpg');
C = imcorrcoef(img, template);
- Ricardo Fabbri <ricardofabbri (AT) users DOT sf DOT net>
The latest version of the Scilab Image Processing toolbox can be found at