0
$\begingroup$

So I am using scipy.ndimage.filters.convolve function. I understood how it works for 2D matrices from the documentation. But when I apply this to 3D matrices it is giving results which I cannot interpret. For example:

In[80]: a = np.array([[[1,2,3], [1,2,3], [1,2,3]],[[1,2,3], [1,2,3], [1,2,3]],[[1,2,3], [1,2,3], [1,2,3]]])


In[81]: b = np.array([[[1,2,3], [1,2,3], [1,2,3]],[[1,2,3], [1,2,3], [1,2,3]],[[1,2,3], [1,2,3], [1,2,3]]])

In[82]: scimg.convolve(a, b, output = None, mode = 'constant')

Out[83]: 
array([[[ 16,  40,  48],
        [ 24,  60,  72],
        [ 16,  40,  48]],

       [[ 24,  60,  72],
        [ 36,  90, 108],
        [ 24,  60,  72]],

       [[ 16,  40,  48],
        [ 24,  60,  72],
        [ 16,  40,  48]]])

I understood convolution from this post. So according to me the (0, 0, 0) index should be 8. Similarly (0, 0, 1) should be 20. Where am I going wrong in the understanding?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.