[SciPy-User] fft convolutions

Alex Flint alex.flint at gmail.com
Thu Jun 30 08:00:18 EDT 2011


oops, I am actually using fft2/ifft2, I just forgot to write it in my pseudo
code

On Thu, Jun 30, 2011 at 4:35 AM, Sturla Molden <sturla at molden.no> wrote:

> Den 28.06.2011 20:17, skrev Alex Flint:
> > 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?
>
> You are not doing 2D convolution with the FFT. You want fft2 (or rfft2).
>
> Sturla
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110630/451e32c7/attachment.html>


More information about the SciPy-User mailing list