[SciPy-Dev] scipy.signal.correlate2d extremely slow

Frédéric Bastien nouiz at nouiz.org
Fri Mar 9 16:47:37 EST 2012


Hi,

>From memory, scipy.signal.correlate2d call the same c code as the
convolution2d. As we have shown in a paper[1], this is not a fast
version. In Theano, we have a much faster version, but don't support
all option of the scipy version. If you go look at the c code of this
function in scipy, you will see that it was done to be ultra
generic(same c code for all dtype!, ...). It was not done for speed.
The version in Theano allow to do in C batch and stack of image and
filter as used in neural network. So this also save some overhead.

So if my memory is right and that correlate2d call the same c code,
you probably can use the Theano code for it by passing it the right
parameter. It you do so, we would like to add it to Theano itself.

[1] http://www.iro.umontreal.ca/~lisa/publications2/index.php/publications/show/461

Otherwise, there is the opencv project that have a python binding and
could implement what you want in a faster way.

HTH

Fred

On Mon, Mar 5, 2012 at 11:57 AM, Malcolm Reynolds
<malcolm.reynolds at gmail.com> wrote:
> Hi,
>
> I've been compiling numpy and scipy from source for a while, and as
> far as I was aware everything was configured correctly. However I
> noticed today that scipy.signal.correlate2d is enormously slow,
> several orders of magnitude slower in that it takes many minutes to
> compute the correlation for two 216x384 matrices. For the same size
> matrices, matlab's normxcorr2 (which I know is not entirely
> equivalent, due to the added normalisation, but much of the
> computation is analogous surely?) takes under half a second.
>
> Is this a known issue with the underlying algorithm, or does it
> indicate that my scipy has not linked correctly with some optimised
> routines from atlas / blas / etc, or that I have made some other
> mistake in the compilation?
>
> Any help on this issue would be appreciated, I was relying on being
> able to compute 2d cross correlations pretty fast.. Thanks!
>
> Malcolm
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev



More information about the SciPy-Dev mailing list