CET4910 Lab7

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Lab 7: Filters in Frequency Domain

Objectives: 1.Undestand 1D Fourier Transform and 2D Fourier Transform; 2. Practice


lowpass filter on a given image in frequency domain. 3. Practice highpass filter on a
given image in frequency domain.

A complete lab report including the following:


• Summarized learning outcomes.
• Finish Exercises as results.
• MATLAB scripts should be reported properly as appendix.

Exercise 1: (1) Research Matlab commands, fft, fft2, ifft, ifft2, fftshift, ifftshift, mesh.
(2) Compute DFT of the function 𝑓𝑓(𝑡𝑡) = 2sin (4𝜋𝜋𝑡𝑡)cos (6𝜋𝜋𝑡𝑡), using sampling frequency at 10Hz
and 100Hz. Discuss the difference.
(3) Create the following patterns, all have size of 256 by 256, then computer 2D Fourier Transform
of these patterns, display the fourier spectrum, phase angle, and power spectrum.

Exercise 2: (1) Write a function H = lpFilterTF (type,P,Q,param) to generate a P × Q lowpass filter


transfer function, H, using the following filter transfer function. If type = 'ideal', param should be
a scalar equal to the cut-off frequency D0. If type = 'gaussian', param should be a scalar equal to
the standard deviation, D0. If type = 'butterworth', param should be a 1×2 array (vector) containing
the cutoff frequency and filter order,[ D0 , n],
Ideal lowpass filter:

Gaussian filter, where D0 is the standard deviation, D(u,v) is the distance from the center of the
P×Q frequency rectangle to any point, (u, v) :

Butterworht filter, where n is the order of filter, D0 is the cut-off frequency, D(u,v) is the distance
from the center of the P×Q frequency rectangle to any point, (u, v).

CET4910Lab 1
(2) Generate a lowpass ideal filter transfer function of size 512 × 512 with D0=96. Display your
result as an image.
(3). Generate a lowpass Gaussian filter transfer function of size 512 × 512 with D0=96. Display
your result as an image.
(4) Generate a lowpass Butterworth filter transfer function of size 512 × 512 with D0=96 and n=2.
Display your result as an image.

Exercise 3: (1) Write a function, g = dftFiltering (f, H, padmode) to filter image f with a given
filter transfer function H. Your function should implement the seven steps in the filtering algorithm
discussed in class. If padmode = 'replicate', then replicate padding should be used. If padmode =
'zeros', zero padding should be used.
(2) Read the image testpattern512.tif, filter it with a Butterworth lowpass filter with cutoff a
frequency of 32 and order 2. Display the result.
(3) Read the image testpattern1024.tif and lowpass filter it using a Gaussian filter, choose
parmeters so that the large letter “a” is barely readable, and the other letters are not.

Exercise 4: (1) Read the image blurry-moon.tif and sharpen it using unsharp masking. Use a
Gaussian lowpass filter of your choice for the blurring step in the frequency domain. Display your
final result.
(2) Improve the sharpness of your result using high-boost filtering. Display the final result.

CET4910Lab 2

You might also like