scipy.stsci.convolve.convolve2d

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

convolve2d does 2d convolution 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’
>>> a = np.arange(20*20)
>>> a = a.reshape((20,20))
>>> b = np.ones((5,5), dtype=np.float64)
>>> rn = convolve2d(a, b, fft=0)
>>> rf = convolve2d(a, b, fft=1)
>>> np.alltrue(np.ravel(rn-rf<1e-10))
True