[SciPy-Dev] conv2 and normxcorr2

Luke Pfister luke.pfister at gmail.com
Tue Dec 31 10:07:51 EST 2013


I *believe* that Matlab is calling either the Intel MKL or Intel IPP
convolution routines, which is why they are so much faster.

I ran into a situation where I needed to perform many, many small 2D
convolutions, and wound up writing a Cython wrapper to call the IPP
convolution.  I seem to remember getting speedups of ~200x when
convolving an 8x8 kernel with a 512x512 image.

I'm not familiar with how the Scipy convolution functions are
implemented under the hood.  Do they use efficient algorithms for
small convolution sizes (ie, overlap-add, overlap-save)?

--
Luke

On Tue, Dec 31, 2013 at 8:49 AM, Aaron Webster <awebster at falsecolour.com> wrote:
> On Tue, Dec 31, 2013 at 2:42 PM, Ralf Gommers <ralf.gommers at gmail.com>
> wrote:
>>
>>
>>
>> On Tue, Dec 31, 2013 at 1:43 PM, awebster at falsecolour.com
>> <awebster at falsecolour.com> wrote:
>>> I noticed a couple of popular matlab functions - conv2 and
>>> normxcorr2 were not present in the scipy.signal packages.  I would
>>> like to submit them for addition.  Can anyone point me on
>>> instructions on how to write such a thing?  Below are examples.
>>>
>>
>> Hi Aaron, isn't conv2 the same as signal.convolve2d? And can what
>> normxcorr2 does be done with signal.correlate2d?
>>
> I did a quick test and it seems that you are correct: signal.convolve2d
> appears to generate basically the same output as conv2, and following
> normxcorr2 can be done with signal.correlate2d.  However, I noticed
> while doing this that both signal.convolve2d and signal.correlate2d are
> *extremely* slow.  For example, on my computer with a random 100x100
> matrix signal.correlate2d takes 4.73 seconds while normxcorr2 take
> 0.253 seconds.  The results are similar for signal.convolve2d and conv2.
>
> As a practical matter, would it make most sense to fix
> signal.correlate2d and signal.convolve2d, or implement new functions?
>
> --
> Aaron Webster
>
> _______________________________________________
> 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