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.
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.
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.
![]() |
![]() |
---|---|
a) | b) |
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. You can see the output of the correlation in the image below:
![]() |
---|
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 size 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. You can also see that the detected point is not very robust as there are many other high value points that correlates with the template.
![]() |
![]() |
---|---|
a) | b) |
To help you determine exactly the location of the maximum points use the statistic operators.