[iaellipse] [Up] [iacomb] Image Creation

ialog
Laplacian of Gaussian image.

Synopsis

g = ialog( s, mu, sigma )

Implemented in Python.

Input

s Image. Gray-scale (uint8 or uint16) or binary image (logical).

[rows cols], output image dimensions.

mu Image. Gray-scale (uint8 or uint16) or binary image (logical).

[row0 col0], center of the function.

sigma Double. Non-negative integer.

spread factor.

Output

g Image. Gray-scale (uint8 or uint16) or binary image (logical).

Description

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.

Examples

>>> 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]]

>>> h = ialog([200,300], [100,150], 20)

              
>>> iashow(h)
(200, 300) Min= -0.000215392793018 Max= 0.00159154943092 Mean=0.000 Std=0.00
>>> g,d = iaplot(h[100,:])
>>> 
h h[100,:]

Source Code

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] http://www.python.org