Effacer les filtres
Effacer les filtres

Convolution vs Correlation - what is the main difference?

14 vues (au cours des 30 derniers jours)
Zamani Md Sani
Zamani Md Sani le 20 Avr 2020
Modifié(e) : Mehmed Saad le 20 Avr 2020
Hi, I'm still confused on the correlation vs convolution. The difference is only the position of the kernel at 180 degree rotation whereas the rest are the same. In most of the convolution example, the image is directly multiply and sum from the kernel. No rotation is performed? Is there a rotation in the first place prior to given kernel?
In image processing the correlation is used to check the similarity of the images. Why convolution cannot be used to measure too?
Thanks

Réponses (1)

Mehmed Saad
Mehmed Saad le 20 Avr 2020
Modifié(e) : Mehmed Saad le 20 Avr 2020
Take a complex number as an example
s = [1+1j 2-2j];
How convolution is performed (i am convolving s with itself)
you take the time reversal of the your signal and shift it,move it on the other signal from left to right while summing them
conv(s,s)
ans =
0.0000 + 2.0000i 8.0000 + 0.0000i 0.0000 - 8.0000i
In correlation you take the conjugate of your signal and shift it,,move it on the other signal from left to right while summing them
xcorr(s,s)
ans =
0.0000 + 4.0000i 10.0000 + 0.0000i 0.0000 - 4.0000i
what convolution did is it expresses how the shape of one signal is modified by the other
what correlation did is it maximizes the output value
How to Perform Correlation through Convolution
In convolution we flip the signal,shift it and move
In correlation we conj the signal shift it and move
so the difference is one flips it and the other conjugates it
In order to perform Correlation through convolution
  1. flip the signal by yourself
  2. take conjugate of signal by yourself
conv(s,fliplr(conj(s)))
ans =
0.0000 + 4.0000i 10.0000 + 0.0000i 0.0000 - 4.0000i
same result as correlation
when you flip the signal and feed it to convolution block, it flips it again (as it is a part of convolution) .
Hope this was helpfull for you

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by