# Function ialog

Laplacian of Gaussian image.

# Synopse

1D, 2D Laplacian of Gaussian image.

• g = ialog(s, mu, sigma)
• g: Image.
• s: Image. [rows cols], output image dimensions.
• mu: Image. [row0 col0], center of the function.
• sigma: Double. standart deviation.

# Description

Creates a Laplacian of Gaussian image with dimensions given by s, origin given by and standart deviation given by . This function is used in the Marr-Hildreth filter.

``` 1 import numpy as np
2
3 def ialog(s, mu, sigma):
4
5
6     mu = np.array(mu)
7     s  = np.array(s)
8     if np.product(np.shape(s)) == 1:
9        x = np.arange(s)
10        coord_center = (x-mu)**2
11     else:
12        (rr, cc) = np.indices( s)
13        coord_center = (rr-mu[0])**2  + (cc-mu[1])**2
14
15     gauss_factor = coord_center/(2.*sigma**2)
16
17     gauss_factor_r = np.ravel(gauss_factor)
18
19     exp_factor = np.exp(-gauss_factor_r)
20     exp_factor = exp_factor.reshape( np.shape(coord_center))
21
22     g = -(((1 - gauss_factor )/ (sigma**4 * np.pi)) * exp_factor)
23
24
25     return g
```

# Examples

## Example 1D

Numerical exemple:

``` 1 import ia636 as ia
2
3 s = 5
4 mu = 3
5 sigma = 0.8
6
7 print 'image dimensions = ',s
8 print 'center of function = ',mu
9 print 'spread factor =', sigma
10
11 F = ia.ialog(s, mu, sigma)
12
13 print 'Laplacian of Gaussian image : \n',F.round(2)
```
```image dimensions =  5
center of function =  3
Laplacian of Gaussian image :
[ 0.    0.07 -0.08 -0.78 -0.08]
```

Image exemple:

``` 1 s = 256
2 mu = 128
3 sigma = 8
4
5 print 'image dimensions = ',s
6 print 'center of function = ',mu
7 print 'spread factor =', sigma
8
9 F = ia.ialog(s, mu, sigma)
10
```
```image dimensions =  256
center of function =  128
```

## Example 2D

Numerical exemple.

``` 1 s = [5,7]
2 mu = [3,4]
3 sigma = 0.5
4
5
6 print 'image dimensions = ',s
7 print 'center of function = ',mu
8 print 'spread factor =', sigma
9
10 F = ia.ialog(s, mu, sigma)
11
12 print 'Laplacian of Gaussian image : \n',F.round(2)
```
```image dimensions =  [5, 7]
center of function =  [3, 4]
Laplacian of Gaussian image :
[[ 0.    0.    0.    0.    0.    0.    0.  ]
[ 0.    0.    0.    0.    0.01  0.    0.  ]
[ 0.    0.    0.    0.28  0.69  0.28  0.  ]
[ 0.    0.    0.01  0.69 -5.09  0.69  0.01]
[ 0.    0.    0.    0.28  0.69  0.28  0.  ]]
```

Generating a image 2D 128x128, centered at 64x64 and sigma 4:

``` 1 s = [128,128]
2 mu = [64,64]
3 sigma = 4
4
5 print 'image dimensions = ',s
6 print 'center of function = ',mu
7 print 'spread factor =', sigma
8
9 F = ia.ialog(s, mu, sigma)
10
```
```image dimensions =  [128, 128]
center of function =  [64, 64]
```

Generating a image 2D 256x256, centered at 128x128 and sigma 20

``` 1 s = [256,256]
2 mu = [128,128]
3 sigma = 20
4
5 print 'image dimensions = ',s
6 print 'center of function = ',mu
7 print 'spread factor =', sigma
8
9 F = ia.ialog(s, mu, sigma)
10
```image dimensions =  [256, 256]