The image files are imported as uint8, so they should be converted to double arrays before doing the FFTs. Below are the images that were used in this example, a Greek church on the island of Santorini and Aishwarya Rai. Imagesc can also be used to display the images. This function works well for original images, but when the Fourier transform of an image, or any other significant image processing, is performed, color limits should be adjusted to display a sufficient amount of detail in the data. Imshow is one of several functions that plots images, but this function automatically eliminates the axes, displaying the images nicely. In this example, imshow is used to display the images. This function can handle most of the standard image file formats, such as bmp, jpg, tiff and png. Notice that imread is used to import the images into Matlab. %Display switched images figure, imshow(abs(imageC), ), colormap grayįigure, imshow(abs(imageD), ), colormap gray %Calculate limits for plotting cmin = min(min(abs(imageC))) %Perform inverse 2D FFTs on switched images imageC = ifft2(fftC) %Switch magnitude and phase of 2D FFTs fftC = abs(fftA).*exp(i*angle(fftB)) %Display magnitude and phase of 2D FFTs figure, imshow(abs(fftshift(fftA)),), colormap grayįigure, imshow(angle(fftshift(fftA)),), colormap grayįigure, imshow(abs(fftshift(fftB)),), colormap grayįigure, imshow(angle(fftshift(fftB)),), colormap gray %Perform 2D FFTs fftA = fft2(double(imageA)) %Import images imageA = imread('greekchurch','jpg') Here is the code for this example: %2D FFT Demo This exercise will hopefully provide some insight into how to perform the 2D FFT in Matlab and help you understand the magnitude and phase in Fourier domain. In the following example, I will perform a 2D FFT on two images, switch the magnitude and phase content, and perform 2D IFFTs to see the results. The formulas for the 2D Digital Fourier Transform and Inverse Transform, courtesy of Rice University, are as follows: The 2D Inverse Fourier Transform is just the inverse Fourier Transform performed over both dimensions of the data. The 2D Fourier Transform is simply a Fourier Transform over one dimension of the data, followed by a Fourier Transform over the second dimension of the data. In Fourier Optics, the 2D Fourier Transform is used to calculate the propagation of electromagnetic waves and through space and optical elements. Additionally, the far-field pattern of a 2D antenna can be calculated using a 2D Fourier Transform. In radar, the 2D Fourier Transform is used as a fast way to create a map from a series of coherent radar pulses. In image processing, the 2D Fourier Transform allows one to see the frequency spectrum of the data in both dimensions and lets one visualize filtering operations more easily. The 2D Fourier Transform is an indispensable tool in many fields, including image processing, radar, optics and machine vision. In today’s post, I will show you how to perform a two-dimensional Fast Fourier Transform in Matlab.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |