Given that we can perform a Fourier transform of an image by using fft2 in MATLAB, what do the values in the output image indicate? How can these values be used to detect high or low frequency features?
fft2 will give the frequency components in a low to high order where the left top pixel is the dc value (i.e. zero frequency) and higher frequency components are arranged in a zigzag manner. For the convenience of visualization, we use fftshift so that the zero frequency value is now in the center.
Implement the following code to have a better understanding:
To experiment how these high or low frequency works, you can try an experiment by applying a circular filter on the image and then apply ifft2. You will see a smooth image, which is an effect of discarding the high frequency components.
As Fareh has pointed out, if you use the fft2 you will get the frequency components in a low to high order and this is where the top left pixel will resemble the dc value and this is known as the standard transformation. For the convenience of visualization, we use fftshift so that the zero frequency value is now in the center and this is known as the optical transformation. One of the reason for this and this is because most of the data of natural image are in the low frequency components.
Code:
RGB=imread;(‘Image Path’); % Read image
RF_1=fftshift(fft2(R)); // apply 2-D frequency response in and center it
figure(1), imshow(mat2gray((log(1+abs(RF_1))))); // display the magnitude of 2-D frequency response using log transformation
figure(2), imshow(angle(RF_1));// display the phase of 2-D frequency response