# Synopse

Discrete 1D/2D/3D Fourier Transform.

• F: Output Image.
• f: Original Image.

# Function Code

```01. from numpy import *
02.
05.     f = asarray(f).astype(float64)
06.     if (len(f.shape) == 1):
07.         m = len(f)
09.         F = sqrt(m) * dot(A, f)
10.     elif (len(f.shape) == 2):
11.         (m, n) = f.shape
14.         F = sqrt(m * n) * dot(dot(A, f), B)
15.     else:
16.         (p,m,n) = f.shape
20.         Faux = dot(A,f)
21.         Faux = dot(Faux,B)
22.         F = sqrt(p)*sqrt(m)*sqrt(n)*dot(C,Faux)
23.     return F```

# Examples

## Numeric Example: comparing proposed with numpy function

```01. from ia636 import *
02. from numpy import *
03.
04. f = arange(24).reshape(2,3,4) # original image with generic axis
05. F = iadft(f)   # proposed dft
06. F1 = fft.fftn(f) # numpy dft
07.
09. print 'fft.fftn:','\n',F1.round(2),'\n'
10. print 'Equal Results? (max error)',abs(F1-F).max()```
```ia636.iadft:
[[[ 276. +0.j    -12.+12.j    -12. -0.j    -12.-12.j  ]
[ -48.+27.71j    0. +0.j      0. +0.j     -0. +0.j  ]
[ -48.-27.71j    0. +0.j     -0. +0.j     -0. +0.j  ]]

[[-144. -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  ]]]

fft.fftn:
[[[ 276. +0.j    -12.+12.j    -12. +0.j    -12.-12.j  ]
[ -48.+27.71j    0. +0.j      0. +0.j      0. +0.j  ]
[ -48.-27.71j    0. +0.j      0. +0.j      0. +0.j  ]]

[[-144. +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  ]]]

Equal Results? (max error) 8.10143365796e-14
```

## Image example: 2d circle

```1. from ia636 import *
2. from numpy import *
3.
4. f = 255 * iacircle([256,256], 10, [129,129])

## Image example: 3d square

```1. from ia636 import *
2.
3. f = zeros((25,30,40))
4. f[10:15,20:26,21:27] = 1

# Comparison with other implementations

```01. import numpy as np
02. import time
03. import ia636 as ia
04.
06. t = time.time()
08. t1 = time.time() - t
09. t = time.time()
10. F2 = np.fft.fft2(f)
11. t2 = time.time() - t
12. print 'Max difference is:', np.abs(F1-F2).max()
13. print 'iadft: %d ms' % (int(t1*1000),)
14. print 'fft2: %d ms' % (int(t2*1000),)```
```Max difference is: 1.80847080852e-07
fft2: 5 ms
```