Professional Documents
Culture Documents
of Gondar
Department of Computer Science
Digital Image Processing and Computer Vision
( Code hint shown is in Matlab)
Assignment 2: Discrete Fourier Transform (DFT) December 20, 2012
Load the image “cameraman.tif” and convert its type to double.
1. Understanding the DFT of an Image
Compute the DFT of the image (fft2).
Compute the inverse (ifft2, real) and display it using subplot, imagesc, log10 and abs.
Did you get the original image back?
Why do we apply a logarithmic scale log10 to display the DFT image?
Why do we have to use the absolute value when displaying the DFT?
Display the centralized DFT by applying fftshift. It has index (0,0) in the middle of the image.
Where, in the centralized DFT, do you find the low frequency values and where do you find the high
frequency values?
2. Filtering in the Frequency Domain
a) Keeping the central values of the centralized DFT
Create a filtering mask using the following code.
[x,y]=meshgrid(‐127:128,‐127:128);
z=sqrt(x.^2+y.^2);
filMask1=(z<20); % radius of the mask
Display the image filMask1 and see what it looks like.
Perform pixel‐wise multiplication of filMask1 and the centralized DFT image, and display the result,
say “filDFT1”.
Perform the inverse process of fftshift (using ifftshift) on “filDFT1” to take indices back to their
original locations, and then apply ifft2 to get the image in spatial domain.
Page 1 of 2
Describe the resultant image by inspecting the operations that you have performed. Justify your
answer by changing the radius of the mask to 5, 10, 50, 100.
b) Eliminating the central values of the centralized DFT
Repeat Question a) above by changing the filtering mask to:
filMask2=(z>20); % radius of the mask
c) Keeping the middle values of the centralized DFT
Repeat Question a) above by changing the filtering mask to:
filMask3=((z>20)&(z<50)); % radii of the mask
Here, you should justify your answer by changing one or both radii, but the first radius should be
less than the second.
3. Spatial Domain vs. Frequency Domain
Discuss the advantages of filtering in the frequency domain as compared to doing it in the spatial
domain.
Page 2 of 2