Lista de Alunos | Cap.4c | Cap.6

Cap5. Transformada de Fourier

Funções da toolbox

iadft - Discrete Fourier Transform

iaidft - Inverse Discrete Fourier Transform

Demonstrações da toolbox

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

iacosdemo- Illustrate discrete cosine wave and its DFT showing its periodic nature.

iadftexamples- Demonstrate the DFT spectrum of simple synthetic images.

 1 from ia636 import *
 2 from numpy import *
 3 f = adread('db1_a/57_7.tif')
 4 adshow(f)
 5 print iaimginfo(f)
 6 F = iadft(f)
 7 print 'F=',F
 8 mag = abs(F)
 9 ang = angle(F)
10 print 'mag=',mag
11 print 'ang=',ang
12 adshow(ianormalize(log(mag)))
13 adshow(ianormalize(iaptrans(log(mag),array(mag.shape)/2)))
14 f1 = iaidft(F)
15 print 'real=',iaimginfo(real(f1))
16 print 'imag=',iaimginfo(imag(f1))
17 adshow(real(f1))
18 print 'diferença máxima entre f e f1=',(f-f1).max()
19 
20 f2 = f[:,:-5]
21 adshow(f2)
22 F2=iadft(f2)
23 adshow(iadftview(F2))
(374, 388) uint8 1.000000 254.000000
F= [[  3.25802050e+07     +0.j           2.52315099e+06-942771.69990772j
   -2.80831293e+05+298859.37905614j ...,  -4.13696081e+05-314840.3540203j
   -2.80831293e+05-298859.37905613j   2.52315099e+06+942771.69990834j]
 [  1.50731152e+06-498824.98263415j  -6.76090462e+05+491705.90199855j
    5.22637659e+03  +1009.16503199j ...,   4.21620409e+05+110170.04309547j
   -1.64690597e+05+215807.83747207j  -1.06741801e+06-123849.59603973j]
 [  2.37440260e+05-255763.32063409j  -3.33325463e+04+220009.47385878j
   -7.32112732e+04  +5919.33256032j ...,   7.86200049e+03 -59793.13651423j
    2.05875816e+05 +53374.16765667j  -3.22433581e+05 +98033.38040914j]
 ..., 
 [  9.91900479e+04 +25714.93058691j   5.22509548e+03 +30855.65112308j
   -6.08349109e+04 +21862.80922779j ...,  -1.38174584e+05  -3766.27421008j
    9.09266207e+04+104887.34889192j  -1.12211511e+05-134772.27241277j]
 [  2.37440260e+05+255763.32063412j  -3.22433581e+05 -98033.38040927j
    2.05875816e+05 -53374.1676566j  ...,   4.43517508e+04+106154.52509812j
   -7.32112732e+04  -5919.33256037j  -3.33325463e+04-220009.47385878j]
 [  1.50731152e+06+498824.98263425j  -1.06741801e+06+123849.59603931j
   -1.64690597e+05-215807.83747214j ...,   5.77162340e+04 -19096.63861j
    5.22637659e+03  -1009.16503202j  -6.76090462e+05-491705.90199871j]]
mag= [[  3.25802050e+07   2.69353103e+06   4.10101382e+05 ...,   5.19873923e+05
    4.10101382e+05   2.69353103e+06]
 [  1.58770727e+06   8.35986248e+05   5.32291521e+03 ...,   4.35776557e+05
    2.71470100e+05   1.07457896e+06]
 [  3.48988185e+05   2.22520173e+05   7.34501806e+04 ...,   6.03077957e+04
    2.12682048e+05   3.37007356e+05]
 ..., 
 [  1.02469133e+05   3.12949330e+04   6.46441708e+04 ...,   1.38225904e+05
    1.38812846e+05   1.75371003e+05]
 [  3.48988185e+05   3.37007356e+05   2.12682048e+05 ...,   1.15047212e+05
    7.34501806e+04   2.22520173e+05]
 [  1.58770727e+06   1.07457896e+06   2.71470100e+05 ...,   6.07934641e+04
    5.32291521e+03   8.35986248e+05]]
ang= [[ 0.         -0.35758531  2.32510502 ..., -2.49106164 -2.32510502
   0.35758531]
 [-0.31959221  2.51279274  0.19074332 ...,  0.25558676  2.22265121
  -3.02608189]
 [-0.8225322   1.72115788  3.0609154  ..., -1.44005964  0.25366935
   2.84643166]
 ..., 
 [ 0.25366458  1.40304772  2.79658665 ..., -3.11434204  0.8565736
  -2.26510217]
 [ 0.8225322  -2.84643166 -0.25366935 ...,  1.17503679 -3.0609154
  -1.72115788]
 [ 0.31959221  3.02608189 -2.22265121 ..., -0.31953298 -0.19074332
  -2.51279274]]
real= (374, 388) float64 0.999990 253.999998
imag= (374, 388) float64 -0.000000 0.000000
diferença máxima entre f e f1= (1.22006688059e-05+1.57670452175e-09j)