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:
- Linearity: The addition of two functions corresponding to the addition of the two frequency spectrum is called linearity. If we multiply a function by a constant, the Fourier transform of the resultant function is multiplied by the same constant. The Fourier transform of the sum of two or more functions is the sum of the Fourier transforms of the functions.
- Scaling: Scaling is the method that is used to change the range of the independent variables or features of data. If we stretch a function by the factor in the time domain then squeeze the Fourier transform by the same factor in the frequency domain.
- Differentiation: Differentiating function with respect to time yields to the constant multiple of the initial function.
- Convolution: It includes the multiplication of two functions. The Fourier transform of a convolution of two functions is the point-wise product of their respective Fourier transforms.
- Frequency Shift and Time Shift: Frequency is shifted according to the coordinates. There is a duality between the time and frequency domains and frequency shift affects the time shift. The time variable shift also affects the frequency function. The time-shifting property concludes that a linear displacement in time corresponds to a linear phase factor in the frequency domain.
The image chosen for the experiment in this article is a famous cameraman image.
Equation for DFT:
Equation for IDFT:
- Read the image.
- Apply forward Fourier transformation.
- Display log and shift FT images.
- imread( ) inbuilt function is used to image.
- fft2( ) inbuilt function is used to apply forward fourier transform on 2D signal.
- ifft2( ) inbuilt function is used to apply inverse Fourier transform on 2D signal.
- fftshift( ) inbuilt function is used to shift corners to center in FT image.
- log( ) inbuilt function is used to evaluate logarithm of FT complex signal.
- imtool( ) inbuilt function is used to display the image.
- k=imread(“cameraman.jpg”); This line reads the image.
- f=fft2(k); This line computes fourier transformation.
- f1=abs(f); This takes magnitude of FT.
- f2=log(abs(f)); This line takes log of magnitude of FT.
- f3=log(abs(fftshift(f))); This line shifts FT from corners to central part.
- f(1:20, 20:40)=0; This line remove frequencies from FT.
- j=ifft2(f); This line computes inverse FT of FT image.
- f(1:20, 20:40)=0; This line removes some frequency from FT image.
- j4=ifft2(f); This line computes inverse FT after removing some frequencies.
- imtool(abs(j4),); This line displays modified image which contains some ringing artefacts.
- There is no one-to-one correspondence between the cameraman image and the Fourier transform image.
- The cameraman image represents the intensities in the spatial domain.
- Fourier transformed image represents frequency in the frequency domain.
- Lower frequency represents the smooth part of the image while higher frequency represents the shape components like edges of an image.
- If the low-frequency part is removed from the frequency domain image then the spatial domain image will get blurred.
- If the anyone frequency value is removed (made 0) in the frequency domain image, that particular frequency will be removed (subtracted) from every intensity value in the spatial domain image.