Demo iagenimages

Illustrate the generation of different synthetic images

Description

The examples below show many ways to create pattern images.

Script

Gaussian images

A gaussian image is controled by its mean and variance.

```01. import numpy as np
02. from ia636 import iagaussian
03. from ia636 import ianormalize
04. from ia636 import iagshow
05.
06. f1 = iagaussian((256,256), transpose([[128,128]]), [[50*50,0],[0,80*80]])
07. f1m = f1.max()
08. vs = exp(-1./2) * f1m
09. fbin = f1 >= vs
10. adshow(ianormalize(f1))
11. adshow(iagshow(ianormalize(f1),fbin) )
12. cc_min = np.asarray(fbin.nonzero()).min(axis=1)
13. print 'f1 max:', f1m, 'f1 min:', f1.min()
14. print 'cc_min=',cc_min
15. print 'cc_min should be=', [(128-50), (128-80)]
16. print 'integral of f1:', f1.sum()```
```f1 max: 3.9788735773e-05 f1 min: 4.17606303246e-07
cc_min= [78 48]
cc_min should be= [78, 48]
integral of f1: 0.881074530604
```

Difference of two Gaussian images

The difference of two gaussian images gives a Laplacian image.

```1. f2 = iagaussian((256,256), transpose([[128,128]]), [[25*25,0],[0,40*40]])
2. fn2 = ianormalize(f2, [0,255])
3. f = f1 - f2/5.
4. fn = ianormalize(f, [0,255])
5. adshow(fn2)
6. adshow(fn)
7. adshow(fn > 230)```

Sinusoidal images

A bidimensional sinusoidal image depends on its period, phase, and direction of the wave.

```1. from ia636 import iacos
2.
3. f1 = iacos([128,256], 100, pi/4, 0)
4. fn = ianormalize(f1, [0,255])
5. adshow(fn)
6. adshow(fn > 128)```

Multiplication of two sinusoidal images

The multiplication of two sinusoidal images gives a kind of a grid of hills and depressions.

```1. f2 = iacos([128,256], 40, pi/8, 0)
2. fn2 = ianormalize(f2, [0,255])
3. f = f1 * f2
4. fn = ianormalize(f, [0,255])
5. adshow(fn2)
6. adshow(fn)
7. adshow(fn > 128)```

Another example of multiplication of two sinusoidal images

In this case, the waves are orthogonal to each other.

```1. f3 = iacos([128,256], 40, (pi/8)+(pi/2), 0)
2. fn2 = ianormalize(f3, [0,255])
3. f = f2 * f3
4. fn = ianormalize(f, [0,255])
5. adshow(fn2)
6. adshow(fn)
7. adshow(fn > 190)```

Maximum of two sinusoidal images

The maximum of two sinusoidal images gives a kind of a surface of the union of both waves. They look like pipes

```1. f = maximum(f1, f2)
2. fn = ianormalize(f)
3. adshow(fn)
4. adshow(fn > 200)```

Sinusoidal where x and y are multiplied

If the arguments of the cos are multiplied instead of added as before, we have a rather interesting pattern. It is important to remember that the proper sinusoidal image that are related to Fourier transforms are the bidimensional sinusoide shown earlier.

```1. rr,cc = meshgrid(arange(256), arange(512), indexing='ij')
2. f = cos((2*pi*rr/256) * (2*pi*cc/512))
3. fn = ianormalize(f)
4. adshow(fn)
5. adshow(fn > 200)```

Sinusoidal with varying period

If the arguments of the cos are taking at the power of a number, we have a varying period effect

```1. rr,cc = meshgrid(arange(150), arange(300), indexing='ij')
2. f = cos(2*pi* (rr/80. + cc/300.)**3)
3. fn = ianormalize(f)
4. adshow(fn)
5. adshow(fn > 200)```

Sinusoidal with sinusoidal period

In this case the arguments of the cos are the multiplication of cc and cos(rr)

```1. rr,cc = meshgrid(arange(150), arange(300), indexing='ij')
2. f = cos(2*pi*(rr/80.) * cos(2*pi*(cc/300.)))
3. fn = ianormalize(f)
4. adshow(fn)
5. adshow(fn > 200)```

Saddle point function

The multiplication of x and y gives a surface with saddle point

```1. from ia636 import iaisolines
2. rr,cc = meshgrid(arange(-75,75), arange(-100,100), indexing='ij')
3. f = rr * cc
4. fn = ianormalize(f).astype(uint8)
5. adshow(fn)
6. adshow(iaisolines(fn,9))```