Demo iadftdecompose

Illustrate the decomposition of the image in primitive 2-D waves.

Description

This demonstration illustrates the decomposition of a step function image into cossenoidal waves of increasing frequencies.

Script

Step function image

The image is created using.

1. import ia636 as ia
2. 
3. f = 50*ones((128,128))
4. f[:,     : 32] = 200
5. f[:,64+32:   ] = 200
6. adshow(f)

Discrete Fourier Transform

The DFT is computed and displayed

1. F = ia.iadft(f)
2. E = ia.iadftview(F)
3. adshow(E)
4. i = arange(128)
5. adshow(ia.iaplot(F.real[0,(i-64)%128]),'Real')
6. adshow(ia.iaplot(F.imag[0,(i-64)%128]),'Imag')

Real

Imag

Reconstruction of f from F

1. u = arange(1,64,2)
2. tc = 128./u
3. for t in tc:
4.   H = ia.iabwlp(F.shape,t,1000)
5.   #adshow(ia.iadftview(H))
6.   G = F * H
7.   #adshow(ia.iadftview(G))
8.   g = ia.iaidft(G)
9.   adshow(ia.iapad(ia.ianormalize(abs(g)).astype(uint8)),'u <= %d' % ( 128/t, ))

u <= 1

u <= 3

u <= 5

u <= 7

u <= 9

u <= 11

u <= 13

u <= 15

u <= 17

u <= 19

u <= 21

u <= 23

u <= 25

u <= 27

u <= 29

u <= 31

u <= 33

u <= 35

u <= 37

u <= 39

u <= 41

u <= 43

u <= 45

u <= 47

u <= 49

u <= 51

u <= 53

u <= 55

u <= 57

u <= 59

u <= 61

u <= 63