[SciPy-dev] Old numarray convolve2d fft=1 option

Stefan van der Walt stefan at sun.ac.za
Wed May 2 20:54:21 EDT 2007


On Wed, May 02, 2007 at 01:32:09PM -0400, Anne Archibald wrote:
> On 02/05/07, David O'Sullivan <dosu004 at sges.auckland.ac.nz> wrote:
> 
> > I'm relatively new to this, and certainly no expert on the underlying
> > math of all this stuff, but I'm trying to do relatively large kernel
> > convolutions on large 2d matrices.  The kernels might be 160x160 while
> > the matrices themselves might be 2500x2500.  They're also likely to be
> > sparse matrices, but I'll worry about that later - for now I'm just
> > scoping things out.
> 
> > This option doesn't seem to be in the current scipy.signal.convolve2d
> > function.  Presumably it would speed 2d convolutions up a lot?
> 
> Basically, yes. FFTs are fairly fast and they turn convolutions into
> elementwise multiplication.
> 
> It would not be terribly difficult to implement from scratch: you take
> a two-dimensional real FFT of each array, padding appropriately,
> multiply the FFTs, and take an inverse two-dimensional real FFT. You
> may have to fiddle with normalizations a bit.

Or try scipy.signal.fftconvolve...

Cheers
Stéfan



More information about the SciPy-Dev mailing list