[SciPy-User] Using scipy.signal.fftconvolve() and scipy.signal.convolve()

Chris Rodgers chris.rodgers at berkeley.edu
Tue Jan 18 21:21:37 EST 2011


While the output from the convolution statements looks qualitatively
correct to me, I always have difficulty interpreting them because I
don't know the "lags" associated with each value. By lag I mean the
amount by which one signal was delayed before calculating the dot
product of the two signals. In Matlab for example, the conv function
returns both the values and a separate array called "lags" of the same
size, which is very helpful.

The scipy documentation is not very clear on this point. Does anyone
know a good resource documenting the lags in each of the 3 modes of
operation ('same', 'valid', 'full')? I tried convolving dummy
sequences ([0,1,0,0] etc) but I couldn't figure it out.

Thanks!!
Chris



On Tue, Jan 18, 2011 at 1:19 PM, David Baddeley
<david_baddeley at yahoo.com.au> wrote:
> What you're getting form fftconvolve looks about right - with ordinary convolve
> I suspect your problem might be that you're using 8 bit ints and it's
> overflowing & thus giving you the random noise pattern. Ffts cast their inputs
> to double first. I'd suggest casting your image to float - ie:
> a = a.astype('f')
> before doing the standard convolutions.
>
> cheers,
> David
>
>
> ----- Original Message ----
> From: Ábel Dániel <abli at freemail.hu>
> To: scipy-user <scipy-user at scipy.org>
> Sent: Wed, 19 January, 2011 8:58:28 AM
> Subject: [SciPy-User] Using scipy.signal.fftconvolve() and
> scipy.signal.convolve()
>
> [apologies if this might get duplicated, it appears my first
> submission didn't show up on the mailling list]
>
> Hi!
>
> I would like to ask some help with the use of scipy.signal.convolve
> and scipy.signal.fftconvolve. (On a greyscale 2d image.)
>
> Based on the documentation of fftconvolve (which is simply 'See
> convolve.'), I am assuming that they should give (mostly) the same
> result. (I.e. the result won't be exactly identical since they are
> using different methods, but they shouldn't be too different.)
>
> However, I am getting drastically different results: using convolve
> results in basically random noise, while fftconvolve gives a very
> sharp peak.
>
> I uploaded a short program with the input and the results I am getting
> to http://hal.elte.hu/~abeld/scipy_signal_issue/
>
> Am I doing something wrong? Should there be such a difference in the
> output of these functions? What is causing the difference?
>
> (I am using Ubuntu Lucid, version of python-scipy package is
> 0.7.0-2ubuntu0.1)
>
> Thanks in advance,
> Daniel Abel
> abli at freemail.hu
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list