[SciPy-User] 2d convolution
Sat Mar 20 06:51:44 CDT 2010
I'm trying to compute the the convolution if s 2D array, and I see
that there are several ways in SciPy to do that. As the original data
C and the kernel R are about the same size in my case, I'd profit from
an FFT-based implementation, which I see right now is given by
scipy.signal.fftconvolve( C, R,
scipy.stsci.convolve.convolve2d( data=C, kernel=R,
The second method is much faster than the first, and as far as I can
see it would spit out the the same results.
Now, when the kernel is actually larger than the data, the resulting
array would have the shape of the kernel. Is there any way to restrict
the computations to the size of the data? At first, I thought that was
what "mode='same'"" is for.
I tried cutting the extra data off of the resulting array, but I'm not
quite sure which is the part that I would like to get rid of.
Any hints here?
More information about the SciPy-User