[SciPy-dev] scipy.signal.convolve2d significantly slower than matlab

Tom Waite twaite at berkeley.edu
Mon Jun 16 18:40:43 EDT 2008


Do you require the filter kernel to be non-separable for your application?


On Mon, Jun 16, 2008 at 7:47 AM, Joel Schaerer <joel.schaerer at insa-lyon.fr>
wrote:

> Hi all,
>
> I've found that the 2D convolution code in scipy is significantly slower
> than
> matlab's. The following code:
>
> --------------------------------------------------------------------
> #!/usr/bin/python
>
> import scipy.io as io
> import scipy.signal
>
> aa=io.loadmat('input.mat')
> seq=aa["seq"]
>
> seq_f=[]
>
> kernel=scipy.randn(21,21)
> for k in xrange(seq.shape[2]):
>    seq_f.append(scipy.signal.convolve2d(seq[:,:,k],kernel,'same'))
> --------------------------------------------------------------------
>
> Executes about 8 times slower than the following matlab code (executed with
> matlab7 on 32bit linux):
>
> --------------------------------------------------------------------
> clear all
> close all
> clc
>
> load input.mat
>
> g=randn(21,21);
>
> seq_f=zeros(size(seq));
> for p=1:size(seq,3),
>    seq_f(:,:,p)=conv2(seq(:,:,p),g,'same');
> end
> --------------------------------------------------------------------
>
> I've traced the convolve code in scipy to the pylab_convolve2D function in
> firfilter.c. It contains the nice following warning:
>
> /* This could definitely be more optimized... */
>
> ...
>
> Anyways, convolution is crucial for some applications,
> so I wanted to report this. I also tried to look for
> some good open source convolution code so that it
> might be incorporated into scipy, but couldn't find any.
> Would anyone know of one?
>
> Totally unrelated question to the scipy devs: do you plan
>  to add a hierarchical data structure such as kd-trees to
>  scipy? With a nice API, it would be a great feature.
>
>
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20080616/aaf0a2d9/attachment.html>


More information about the SciPy-Dev mailing list