Correlation


Correlation in 1D is defined by the following equation

It is very similar to the convolution equation, and in practice it can be seen as the convolution of the complex conjugate of f (image) with a kernel h (filter). Note that the kernel is not reflected as in convolution. This can be extended to the 2D case.

        p(x,y) o q(x,y) <---> conjugate[P(u,v)] Q(u,v)
or
        conjugate[p(x,y)] q(x,y) <---> P(u,v) o Q(u,v)

where "o" indicates correlation and 
"<--->" Fourier transform pairs

Similar to convolution, correlation also has a theorem that relates spatial domain processing with frequency domain processing via the Discrete Fourier Transform (DFT). Thus, correlation can be performed either in the spatial domain or frequency domain. Correlation is used to determine the degree of similarity between data sets.

Experiment: Template Matching by Normalized Correlation

One application of correlation is to perform template matching. The idea is to find the position where a best match exists between a small pattern (template) and a set of patterns in a larger image.

In this experiment we will use the gull image as the larger image and a small portion (10x10) around its eye as the pattern image or template.

--
Left: larger image, Right: zoomed pattern or template (region of the eye)

The correlation of the image with the 10x10 template does not yield the expected result. The maximum points occur at the location width=199 and height=100 and do not correspond to the position where the eye is. Note that the template behaves as a lowpass filter blurring the image. Also, the maximum point will depend on the amount of white (high pixel values) present.

To solve this problem we have to use the normalized correlation procedure defined below for the 1D case

where i is a constant kernel where each pixel has value 1 and with the same dimensions as the correlation pattern. The denominator is known as the normalization factor for correlation.

Now, the maximum of the normalized correlation is at the gull's eye.

--
Left: normalized factor for correlation, Right; normalized correlation (maximum at the gull's eye

To help you determine exactly the location of the maximum points use statistic operators.



DIP Feedback Form

Copyright © 1995 KRI, ISTEC, Ramiro Jordán, Roberto Lotufo. All Rights Reserved.