I have searched Google for circular cross correlation using Matlab, and I have found it only for one dimensional signals.
Could you please help me implementing circular cross correlation between two images using MATLAB?
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It only takes a minute to sign up.
Sign up to join this communityI have searched Google for circular cross correlation using Matlab, and I have found it only for one dimensional signals.
Could you please help me implementing circular cross correlation between two images using MATLAB?
Cross correlation can be implemented in the frequency domain using FFT by multiplying signals.
For a cyclic cross correlation you can use:
cc = ifft(fft(x).*conj(fft(y)));
You can also calculate the linear cross correlation using FFT by zero-padding the signals before the FFT.
Related: Cross correlation with FFT and fftshift
Edit:
In order to calculate the cross correlation of two images you have 2 options:
x
and y
should be the grayscale representation of the imagesx
and y
are a single channel (r,g or b) from each imageFor 1D signals MATLAB has the function cconv()
.
In order to apply correlation and not convolution just flip the signals:
c = cconv(a, b(end:-1:1));
For 2D, in case you the Image Processing toolbox you may use imfilter()
. Its default mode is correlation:
c = imfilter(a2D, b2D);
c = imfilter(a2D, b2D, 'corr'); % Equals to the above