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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With