scipy.stsci.convolve.correlate2d

scipy.stsci.convolve.correlate2d(data, kernel, output=None, mode='nearest', cval=0.0, fft=0)

correlate2d does 2d correlation of ‘data’ with ‘kernel’, storing the result in ‘output’.

supported ‘mode’s include:
‘nearest’ elements beyond boundary come from nearest edge pixel. ‘wrap’ elements beyond boundary come from the opposite array edge. ‘reflect’ elements beyond boundary come from reflection on same array edge. ‘constant’ elements beyond boundary are set to ‘cval’

If fft is True, the correlation is performed using the FFT, else the correlation is performed using the naive approach.

>>> a = np.arange(20*20)
>>> a = a.reshape((20,20))
>>> b = np.ones((5,5), dtype=np.float64)
>>> rn = correlate2d(a, b, fft=0)
>>> rf = correlate2d(a, b, fft=1)
>>> np.alltrue(np.ravel(rn-rf<1e-10))
True