# jailton_Ex13

Autor: jailton 01/07/2009
``` 1 # iagaussian (ia636) - Generate a 2D Gaussian image.
2 # Synopsis - g = iagaussian( s, mu, sigma )
3 # Input:
4 #     s  -   Image[rows columns].Gray-scale (uint8 or uint16) or binary image (logical).
5 #     mu -   Image.Gray-scale (uint8 or uint16) or binary image (logical).
6 #            Mean vector. 2D point (x;y). Point of maximum value.
7 #     sigma- Image. Gray-scale (uint8 or uint16) or binary image (logical).
8 #            covariance matrix (square). [ Sx^2 Sxy; Syx Sy^2]
9 # Output
10 #     g  -  Image. Gray-scale (uint8 or uint16) or binary image (logical).
11 # Description
12 # A 2D Gaussian image is an image with a Gaussian distribution. It can be used to generate test
13 # patterns or Gaussian filters both for spatial and frequency domain. The integral of the gaussian function is 1.0.
14 # - Testando...estranho...
15 f = iagaussian([10.0,15.0], [4.0,5.0], [[2.0,0],[0,3.0]])
16 g = ianormalize(f, [0,15.0])
17 print "saída g" ; print g
```
```saída g
[[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]
[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]
[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]
[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]
[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]
[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]
[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]
[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]
[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]
[ 7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5  7.5
7.5]]
```
``` 1 # A função gaussian gera uma imagem em duas dimensões(x,y).
2
3 def gaussian( xsize, ysize, mx, my, sx, sy):
4    x, y = iameshgrid(arange(0,xsize), arange(0,ysize) )  # Associa x,y às dimensões da matriz(imagem)
5    x = x.astype(float)
6    y = y.astype(float)
7    F = 255*(exp(-0.5 *( ((x - mx)/sx)**2+((y - my)/sy)**2))).astype(float)
8    return F
9
10 coluna = 128     # Número de colunas da figura (xsize)
11 linha = 128       # Número de linas da figura (ysize)
12 mediax = 64      # Média da gaussiana(função normal) no eixo x (mx)
13 mediay = 32      # Média da guassian(função normal) no eixo y (my)
14 desvpadx = 20    # Desvio padrao da função normal no eixo x (sx)
15 desvpady = 15     # Desvio padrão da função normal no eixo y (sy)