import numpy as np
def makeGaussian(size, fwhm = 300):
""" Make a square gaussian kernel.
size is the length of a side of the square
fwhm is full-width-half-maximum, which
can be thought of as an effective radius.
"""
x = np.arange(0, size, 1, np.float32)
y = x[:,np.newaxis]
x0 = y0 = size // 2
return np.exp(-4*log(2) * ((x-x0)**2 + (y-y0)**2) / fwhm**2)
g = makeGaussian(300, 30)
kernel = g[100:150,100:150]
figure()
imshow(g)
figure()
imshow(kernel)
figure()
imshow(scipy.signal.correlate2d(g, kernel))
io.embed()
/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/scipy/signal/signaltools.py:466: ComplexWarning: Casting complex values to real discards the imaginary part return sigtools._convolve2d(in1, in2, 0, val, bval, fillvalue)