[iaellipse] [Up] [iacomb] | Image Creation |
Implemented in Python.
g | Image. Gray-scale (uint8 or uint16) or binary image (logical). |
Creates a Laplacian of Gaussian image with dimensions given by s, origin given by c and spreading factor given by sigma. This function is used in the Marr-Hildreth filter.
>>> F = ialog([5,7], [3,4], 1)
>>> print Numeric.array2string(F, precision=4, suppress_small=1)
[[-0. -0.0006 -0.0053 -0.0172 -0.0248 -0.0172 -0.0053] [-0.0003 -0.0053 -0.035 -0.0784 -0.0862 -0.0784 -0.035 ] [-0.001 -0.0172 -0.0784 0. 0.1931 0. -0.0784] [-0.0015 -0.0248 -0.0862 0.1931 0.6366 0.1931 -0.0862] [-0.001 -0.0172 -0.0784 0. 0.1931 0. -0.0784]]
def ialog(s, mu, sigma): from Numeric import array, product, shape, arange, ravel, reshape, pi, exp def test_exp(x,sigma): from Numeric import exp try: return (exp(-(x / (2. * sigma**2)))) except: return 0 mu = array(mu) if product(shape(s)) == 1: x = arange(s) r2 = (x-mu)**2 else: (x, y) = iameshgrid(range(s[1]), range(s[0])) r2 = (x-mu[1])**2 + (y-mu[0])**2 r2_aux = ravel(r2) aux = reshape(map(test_exp, r2_aux, 0*r2_aux+sigma), r2.shape) g = -(((r2 - 2 * sigma**2) / (sigma**4 * pi)) * aux) return g
[iaellipse] [Up] [iacomb] | |