[SciPy-user] convolve2d.. or Numeric to numarray conversion
Todd Miller
jmiller at stsci.edu
Fri Feb 14 10:35:23 EST 2003
Kasper Souren wrote:
>Hi!
>
>the reverse would also be handy to have, but that's for later.)
>
>Or is there another simple way to do a 2D convolution of Numeric arrays?
>
>
I just worked through some of this for one of our developers so
numarray's Convolve.convolve2d now has an "fft" mode. The short answer
is, use the convolution theorem and Numeric's FFT module:
Fdata = FFT.real_fft2d(data)
Fkernel = FFT.real_fft2d(kernel)
multiply(Fdata, Fkernel, Fdata)
convolved = inverse_real_fft2d( Fdata)
The edges can be a little tricky, but other than that, it's mostly
already implemented (in Numeric) in the form of 2d Fourier transforms.
If the kernel you want to use is bigger than about 15x15, the FFT is
also an increasingly faster way of convolving than the brute force
approach in numarray-0.4.
Todd
More information about the SciPy-User
mailing list