assignment -3 - qil.uh.edu -3 1. dft implementation a. forward fourier transform b. inverse fourier...
Post on 21-May-2020
13 Views
Preview:
TRANSCRIPT
Assignment -3
1. DFT Implementation
a. Forward Fourier transform
b. Inverse Fourier transform
c. Discrete Cosine transform
d. Magnitude of DFT
2. Frequency filtering
a. Ideal (Low and High Pass)
b. Butterworth (Low and High Pass)
c. Gaussian (Low and High Pass)
Due Date: Apr 7th , 11:59 PM
DFT Implementation
1. Input a matrix of integers (15X15)1. Compute forward Fourier transform
2. Compute inverse Fourier transform
3. Compute Discrete Cosine transform
4. Compute magnitude of DFT
Forward Fourier transform
Input 15X15 matrix (πΌ) Output DFT 15X15 matrix (πΉ)
i u
j v
DFT
Complex values
Forward Fourier transform
πΉ π’, π£ =
π=0
πβ1
π=0
πβ1
πΌ π, π πβ β12ππ(π’π+π£π) , π = 15
πΉ π’, π£ =
π=0
πβ1
π=0
πβ1
πΌ π, π [cos2π
ππ’π + π£π β β1 sin
2π
ππ’π + π£π ]
In python, β1 = 1π
Forward Fourier transform
πΉ π’, π£ =
π=0
πβ1
π=0
πβ1
πΌ π, π πβ β12ππ(π’π+π£π) , π = 15
πΉ π’, π£ =
π=0
πβ1
π=0
πβ1
πΌ π, π [cos2π
ππ’π + π£π β β1 sin
2π
ππ’π + π£π ]
u = {0,..14}, v = {0,..14}
Inverse Fourier transform
Input 15X15 matrix (πΌ) Output DFT 15X15 matrix (πΉ)
i u
j v
IDFT
Complex values
Inverse Fourier transform
πΌ π, π =
π’=0
πβ1
π£=0
πβ1
πΉ π’, π£ π β12ππ(π’π+π£π) , π = 15
πΌ π, π =
π’=0
πβ1
π£=0
πβ1
πΉ π’, π£ [cos2π
ππ’π + π£π + β1 sin
2π
ππ’π + π£π ]
i = {0,..14}, j = {0,..14}
End up getting complex numbers
Discrete Cosine transform
πΉ π’, π£ =
π=0
πβ1
π=0
πβ1
πΌ π, π [cos2π
ππ’π + π£π ]
No complex part
Magnitude of DFT
πΉ π’, π£ =
π=0
πβ1
π=0
πβ1
πΌ π, π [cos2π
ππ’π + π£π β β1 sin
2π
ππ’π + π£π ]
π = |πΉ(π’, π£)|
Please compute magnitude in the function. Do not use abs function.
Frequency filtering
β’ Input Image
11
Computation of the DFTβ’ Fast algorithms for the DFT are collectively referred to as
Fast Fourier Transform (FFT) algorithms.
β’ We will not delve into the design of these, as they are available in most math library programs.β’ Divide and conquer
β’ Exploit Symmetry
β’ Reduces complexity from π(π2) to π(π log π)
Forward Fourier transform
1. Compute the Fourier transform (numpy has fftand opencv both has dft)
2. Compute the shift (Ex. Numpy has fftshift)
Note: Numpy represents real part and imaginary part in a single matrix, however, opencv uses two matrices to represent the same.
Displaying dft
β’ Dft is one of the images that needs to be save.
β’ However the magnitude of the dft could be large values
β’ In order to save as an image that is visible,
1. Do a logarithmic compression (Ex. np.log(mag(dft))
2. Convert to uint8 to save it as greyscale image
Example
Mask
β’ Write functions to compute six masks
1. Ideal Low Pass (one parameter: cutoff frequency)
2. Ideal High Pass (one parameter: cutoff frequency)
3. Butterworth Low Pass (Two parameters: cutoff and order)
4. Butterworth High Pass (Two parameters: cutoff and order)
5. Gaussian Low Pass (one parameter: cutoff frequency)
6. Gaussian High Pass(one parameter: cutoff frequency)
Mask
Filtering
β’ Filter the image using convolution theorem
β’ Filtered DFT is one of the images that needs to be saved.
β’ Follow same process as before (DFT image)
Filtered DFT
Inverse Fourier transform
β’ Compute the inverse shift (Ex. Numpy fft library has ifftshift)
β’ Compute the inverse fourier transform (opencv has idft and numpy has ifft)
Filtered Image
β’ The inverse Fourier transform will give complex numbers.
β’ To transform into a meaningful image
1. Compute the magnitude
2. Do a full scale contrast stretch (to greyscale values)
3. Take negative if needed
Assignment -3
1. DFT Implementation(4 Pts)
2. Frequency filtering (11 Pts)
Total: 15 Pts.
Submission Instructions
Must use the starter code available in Github
Submission allowed only through Github
You will receive an email with invitation to join
Github classroom
Start by reading the readme.md file.
Instructions are available here
Github will automatically save the last commit
as a submission before the deadline
top related