[SciPy-Dev] scipy.signal.correlate2d extremely slow
Travis Oliphant
travis@continuum...
Sun Mar 11 17:16:21 CDT 2012
scipy.ndimage uses a faster algorithm than scipy.signal.correlate2d (scipy.signal.correlate might even be faster).
The problem is that scipy.signal.correlate2d has a bunch of if-statements in the inner-most loop which is not-good for modern hard-ware.
Also, if you are doing correlation with two matrices that are the same size you should try FFT-based correlation instead. scipy.signal.fftconvolve (you will need to flip the second input in both dimensions to get the equivalent of correlation).
-Travis
On Mar 5, 2012, at 10:57 AM, Malcolm Reynolds 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@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
More information about the SciPy-Dev
mailing list