[SciPy-User] fft convolutions

Alex Flint alex.flint at gmail.com
Tue Jun 28 14:17:59 EDT 2011


I am trying to perform 2d convolutions between a large 2d array A and a
bunch of small 2d arrays B1...Bn. My approach is roughly:

a = fft(A,size)
for b in bs:
   ans = ifft(fft(b,size)*A)
   slow = convolve2d(A, b, 'same')

However, as implemented above, ans is offset an inconsistent amount from the
answer produced by convolve2d, presumably because convolve2d is treating b
as if the origin is in the center whereas fft treats b as if the origin is
at the top left (but it doesn't seem to be quite as simple as this). What am
I missing?

Also, I'm not using fftconvolve at the moment because I want to compute the
fft of A just once, then use it repeatedly for each b.

Cheers,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110628/c3a3fbb9/attachment.html>


More information about the SciPy-User mailing list