2

I have to obtain the frequency spectrum of a grayscale image using FFT in MATLAB and plot the spectrum. I used fft2() and plotted the output.

I watched a tutorial on plotting frequency spectrum and in that, they perform fftshit(), take the absolute value, apply a log transformation, scale pixels using mat2gray() and then convert into uint8 before plotting the spectrum. im2uint8(mat2gray(log(abs(fft_shifted)+1)))

My question is, is that necessary to perform all those steps before plotting the frequency spectrum? I know fftshift() is used to center the spectrum around 0th frequency coefficient. What is the use of performing other functions?

I plotted the frequency spectrum without shifting, after shifting, and after applying the above-mentioned steps.

Outputs

After this, I have to apply a low pass filter to the grayscale image and compare frequency spectrums. (This is a homework question)

lauren
  • 33
  • 3
  • `abs` gives you the *magnitude* of the complex FFT output, and using a log scale gives you much more dynamic range when displaying the magnitudes using 8 bit grey scale pixels. – Paul R Nov 06 '21 at 13:58
  • The first two images you show have a lot of clipped values—many different values are all shown as white, and many others as black. If you linearly stretch the values from max=white to min=black, you will see only one pixel white, and the rest will be black or nearly black. The log transform allows viewing values with such large difference in magnitude. – Cris Luengo Nov 06 '21 at 15:43
  • @CrisLuengo Thank you for the explanation. Could you please explain to me what is represented by axes in the final plot? Do the x-axis display frequency and the y-axis display amplitude? – lauren Nov 06 '21 at 15:47
  • 1
    The gray value (intensity) is the amplitude. You compute the FFT of a 2D array, and so have two different spatial frequencies (frequency along x and along y), which are plotted along the new x and y. – Cris Luengo Nov 06 '21 at 15:48

0 Answers0