Open In App

Forward and Inverse Fourier Transform of an Image in MATLAB

In this article, we shall apply Fourier Transform on images. Fourier Transform is a mathematical technique that helps to transform Time Domain function x(t) to Frequency Domain function X(ω). In this article, we will see how to find Fourier Transform in MATLAB.

Properties of Fourier Transform:

The image chosen for the experiment in this article is a famous cameraman image.



Figure: Input image

Equation for DFT: 

Equation for IDFT: 



Steps:

Function Used:

Example:

% MATLAB code for Forward and 
% Inverse Fourier Transform
  
% FORWARD FOURIER TRANSFORM
k=imread("cameraman.jpg");
  
% Apply fourier transformation.
f=fft2(k);
  
% Take magnitude of FT.
f1=abs(f);
  
% Take log of magnitude of FT.
f2=log(abs(f));
  
% Shift FT from corners to central part.
f3=log(abs(fftshift(f)));
  
% Display all three FT images.
imtool(f1,[]); 
imtool(f2,[]);
imtool(f3,[]);
  
% Remove some frequency from FT.
f(1:20, 20:40)=0;
imtool(log(abs(f)),[]);

                    

Output:

 

Figure 1:Absolute of the fourier transformed image

Figure 2: Log of the absolute of FT of image

 Figure 3:Centered spectrum of FT image

Figure 4: Some frequencies blocked in FT image

Code Explanation:

Example:

% MATLAB code for INVERSE FOURIER TRANSFORM
% apply inverse FT on FTransformed image.
% we get original image in this step.
j=ifft2(f);
  
% Take log of original image.
j1=log(abs(j));
  
% Shift corners to center.
j2=fftshift(j);
  
% Again shift to get original image.
j3=fftshift(j2);
  
% Remove some frequency from FT image.
f(1:20, 20:40)=0;
  
% Apply inverse FT.
j4=ifft2(f);
  
% Display all 4 images.
imtool(j,[]);
imtool(j1,[]); 
imtool(j2,[]);
imtool(j3,[]);%j and j3 are same.
imtool(abs(j4),[]);

                    

Output:

 

Figure 1:Original Input Image was obtained by taking the Inverse FT of the FT image

 

Figure 2: log of absolute Inverse Fourier Transformed Image

 

Figure 3: Corners shifted to center

 

Figure 4: Inverse FT after removing some frequencies from Freq Domain

Code Explanation: 

Properties:

 


Article Tags :