[SciPy-user] ndimage.convolve behaviour?

David Warde-Farley dwf@cs.toronto....
Tue Jun 23 04:45:48 CDT 2009


Try as I might I can't seem to figure out why this behaviour might be  
happening:

In [352]: X.shape
Out[352]: (20, 20)

In [353]: fm.filter.shape
Out[353]: (5, 5)

In [354]: ndimage.convolve(X, fm.filter, mode='constant', cval=0)[2,2]
Out[354]: -1.4177409721087026

In [355]: (X[:5, :5] * fm.filter).sum() # which should be [2,2] in the  
convolved image, no?
Out[355]: 0.33535125912538849

I get roughly the same answer with scipy.signal.convolve2d(X,  
fm.filter, mode='same'). Am I missing something fundamental? Does my  
kernel need to be separable or something like that?

Regards,

David


More information about the SciPy-user mailing list