Demo iadftexamples

Demonstrate the DFT spectrum of simple synthetic images.

Script

Constant image

The DFT of a constant image is a single point at F(0,0), which gives the sum of all pixels in the image.

1. from ia636 import *
2. 
3. f = ones((100, 200))
4. F = iadft(f)
5. print F.round(4)
[[ 20000.+0.j     -0.+0.j     -0.+0.j ...,      0.-0.j      0.-0.j
       0.-0.j]
 [    -0.-0.j      0.-0.j      0.-0.j ...,     -0.+0.j     -0.+0.j
      -0.+0.j]
 [    -0.-0.j      0.+0.j      0.+0.j ...,     -0.-0.j     -0.-0.j
      -0.-0.j]
 ..., 
 [    -0.+0.j      0.-0.j      0.-0.j ...,     -0.+0.j     -0.+0.j
      -0.+0.j]
 [    -0.+0.j     -0.-0.j     -0.-0.j ...,      0.+0.j      0.+0.j
       0.+0.j]
 [    -0.+0.j     -0.-0.j     -0.-0.j ...,      0.+0.j      0.+0.j
       0.+0.j]]

Square

The DFT of a square image is a digital sync.

1. f = zeros((128, 128))
2. f[63:63+5,63:63+5] = 1
3. adshow(ianormalize(f))
4. F = iadft(f)
5. Fv = iadftview(F)
6. adshow(Fv)

Pyramid

The DFT of a pyramid is the square of the digital sync.

1. f = zeros((128, 128))
2. k = array([[1,2,3,4,5,6,5,4,3,2,1]])
3. k2 = dot(k.T, k)
4. f[63:63+k2.shape[0], 63:63+k2.shape[1]] = k2
5. adshow(ianormalize(f))
6. F = iadft(f)
7. Fv = iadftview(F)
8. adshow(Fv)

Gaussian

The DFT of a Gaussian image is a Gaussian image.

1. f = iagaussian((128,128),transpose([[65,65]]),[[3*3,0],[0,5*5]])
2. fn = ianormalize(f).astype(uint8)
3. adshow(fn)
4. F = iadft(f)
5. Fv = iadftview(F)
6. adshow(Fv)

Impulse

The DFT of an impulse image is an impulse image.

1. from ia636 import iacomb
2. 
3. f = iacomb((128,128), (4,4), (0,0))
4. fn = ianormalize(f)
5. adshow(fn)
6. F = iadft(f)
7. Fv = iadftview(F)
8. adshow(Fv)