0% found this document useful (0 votes)
79 views

Assignment 2

This document discusses the discrete Fourier transform (DFT) and image filtering in the frequency domain. It contains the following instructions: 1) Load an image, compute its DFT using fft2, take the inverse to get the original image back, and display the DFT using log10 and absolute value scales. 2) Create filtering masks to keep or eliminate central DFT values, multiply the masks with the DFT, and take the inverse to observe the effects of low-pass, high-pass, and band-pass filtering. 3) Explain the advantages of filtering images in the frequency domain compared to the spatial domain.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Assignment 2

This document discusses the discrete Fourier transform (DFT) and image filtering in the frequency domain. It contains the following instructions: 1) Load an image, compute its DFT using fft2, take the inverse to get the original image back, and display the DFT using log10 and absolute value scales. 2) Create filtering masks to keep or eliminate central DFT values, multiply the masks with the DFT, and take the inverse to observe the effects of low-pass, high-pass, and band-pass filtering. 3) Explain the advantages of filtering images in the frequency domain compared to the spatial domain.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

University 

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

You might also like