Template matching by normalized correlation
C = imcorrcoef(Img, template)
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.
http://siptoolbox.sourceforge.net