Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between scipy.ndimage.interpolate convolve and correlate

Tags:

python

scipy

I'm just trying to get familiar with scipy.ndimage and I can't figure out how interpolate.convolve and interpolate.correlate are different.

In [24]: a
Out[24]: 
array([[  0.,   1.,   2.],
       [  3.,   4.,   5.],
       [  6.,   7.,   8.],
       [  9.,  10.,  11.]])
In [25]: filt=array([[0,1,0],[1,2,1],[0,1,0]])
In [26]: convolve(a,weights=filt)
Out[26]: 
array([[  4.,   9.,  14.],
       [ 19.,  24.,  29.],
       [ 37.,  42.,  47.],
       [ 52.,  57.,  62.]])
In [27]: correlate(a,weights=filt)
Out[27]: 
array([[  4.,   9.,  14.],
       [ 19.,  24.,  29.],
       [ 37.,  42.,  47.],
       [ 52.,  57.,  62.]])
In [28]: correlate == convolve
Out[28]: False

Are they exactly the same?

like image 853
arwright3 Avatar asked May 12 '26 10:05

arwright3


1 Answers

convolution [f(x), g(x)] = correlation [f(x), g(-x)]

Correlation is happens when you simply move a kernel over an image.

Convolution is a mathematical concept (also used in physics), playing a role for instance in Fourier Transformation or when calculating the probability density of quantum mechanical particles/wave.

like image 112
Markus Dutschke Avatar answered May 15 '26 00:05

Markus Dutschke