0% found this document useful (0 votes)
70 views6 pages

Objective

The document discusses demonstrating discrete Fourier transforms in image processing. It provides equations for the two-dimensional discrete Fourier transform (DFT) and inverse DFT, explaining that the DFT represents an image as a sum of complex exponentials in the frequency domain. Examples show the magnitude and logarithm of Fourier transforms for simple shapes like rectangles, helping to visualize the frequency content. MATLAB functions are introduced for computing the DFT and inverse DFT of images and displaying the Fourier spectrum.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views6 pages

Objective

The document discusses demonstrating discrete Fourier transforms in image processing. It provides equations for the two-dimensional discrete Fourier transform (DFT) and inverse DFT, explaining that the DFT represents an image as a sum of complex exponentials in the frequency domain. Examples show the magnitude and logarithm of Fourier transforms for simple shapes like rectangles, helping to visualize the frequency content. MATLAB functions are introduced for computing the DFT and inverse DFT of images and displaying the Fourier spectrum.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

OBJECTIVE:

To demonstrate Discrete Fourier transforms in image processing

THEORY:

The Fourier transform is a representation of an image as a sum of complex exponentials of varying


magnitudes, frequencies, and phases. The Fourier transform plays a critical role in a broad range of
image processing applications, including enhancement, analysis, restoration, and compression.

The general idea is that the image (f(x,y) of size M x N) will be represented in the frequency domain

(F(u,v)). The equation for the two-dimensional discrete Fourier transform (DFT) is:

Eq 1

The inverse of the above discrete Fourier transform is given by the following equation:

Eq 2

Thus, if we have F(u,v), we can obtain the corresponding image (f(x,y)) using the inverse, discrete Fourier
transform.

Fig.7.1 Magnitude image of a rectangular function

15
The mesh plot of the magnitude is a common way to visualize the Fourier transform.

The peak at the center of the plot is F (0,0), which is the sum of all the values in f(m,n) and is often called
the ‘DC component’. The plot also shows that F (ω1, ω2) has more energy at high horizontal frequencies
than at high vertical frequencies. This reflects the fact that horizontal cross sections of f(m,n) are narrow
pulses, while vertical cross sections are broad pulses. Narrow pulses have more high-frequency content
than broad pulses.

Another common way to visualize the Fourier transform is to display log|F(ω1, ω2)| as an image, as
shown in Fig.7.2.

Fig.7.2 Log of a Fourier transform of a rectangular function

Using the logarithm helps to bring out details of the Fourier transform in regions where F (ω1, ω2) is
very close to 0.

Examples of Fourier transform for other simple shapes are shown in Fig.7.3

16
Fig.7.3 Fourier transform of some simple shapes

There are two principal reasons for using discrete Fourier transform:

1. The input and output of the DFT are both discrete, which makes it convenient for computer
manipulations.
2. There is a fast algorithm for computing the DFT known as the fast Fourier transform (FFT).

MATLAB has three functions to compute the DFT:

fft -for one dimension (useful for audio)


fft2 -for two dimensions (useful for images)
fftn -for n dimensions

17
MATLAB has three related functions that compute the inverse DFT:

ifft
ifft2
ifftn

How to display Fourier spectrum using MATLAB?

The following table is meant to describe the various steps behind displaying the Fourier Spectrum.

MATLAB code Image produced


%Create a black 30x30 image
f=zeros(30,30);

%With a white rectangle in it.


f(5:24,13:17)=1;

imshow(f,'InitialMagnification', 'fit')

%Calculate the DFT.


F=fft2(f);

%There are real and imaginary parts to F.


%Use the abs function to compute the magnitude
%of the combined components.
F2=abs(F);

figure, imshow(F2,[], 'InitialMagnification','fit')

18
%To create a finer sampling of the Fourier
transform, you can add zero padding to f when
computing its DFT. Also note that we use a power
of 2, 2^256. This is because the FFT -Fast Fourier
Transform - is fastest when the image size has
many factors.
F=fft2(f, 256, 256);
F2=abs(F);
figure, imshow(F2, [])

%The zero-frequency coefficient is displayed in


the upper left hand corner. To display it in the
center, you can use the function fftshift.
F2=fftshift(F);
F2=abs(F2);
figure,imshow(F2,[])

%In Fourier transforms, high peaks are so high


they hide details. Log function comes in handy.
F2=log(1+F2);
figure,imshow(F2,[])

Table 7.1 Steps for displaying Fourier spectrum in MATLAB

19
Tasks:

1. What prod(size(imgFT)) function in MATLAB does. Apply it to above image and conclude on it.
2. The spectrum of DFT is complex. What does this complex spectrum contain?
3. The signs of real and imaginary part of spectrum are relevant in which calculation?
4. Why logarithmic is applied in calculating amplitude?
5. Select one image of natural scene and one image of texture. Compute their DFT in MATLAB as
well as their amplitude and phases. Which part of the spectrum contains the largest portion of
the energy
6. Does phase of the spectrum contains more information than magnitude of the spectrum?
7. If answer to task 6 is yes. Prove it by reading an image file and compute their magnitude and
phase versions of the image separately and plot them on a common plot. Discuss the plot
8. Task 7 is complicated. Refer MATLAB for help in different commands. Use MATLAB command
angle to compute the phase simply.

Open ended lab project:

Write a MATLAB code for reconstructing the full image based on the crossed images of magnitude and
phase.

Conclusion:

20

You might also like