Hi guys, I have a problem concerning MATLAB's fft2 function. I am trying to understand the results and how to get the actual frequences and the connected amplitudes. In my code, I create a rect-like signal with the first five harmonics of a sine wave and sum them up. Then I put it through fft and, of course, get peaks at zero (dc part because I wanted no negative values), one, three, etc. After normalizing the output by dividing with the actual length of the signal, I also get the correct amplitudes.

Now the 2D case: I use the exact same signal, and create an image with the signal's luminance values. As it is an image now, I use fft2 because it is two dimensional. And here starts my problem: I cannot understand the magnitude of both amplitudes and frequencies. In my 1D example, the DC part is as big as the the first harmonic. That is not the case for the 2D one.

I save the created image to a file, because the purpose is going the read actual images into the script and have them evaluated. But first, I need to understand what I have to expect from real files by understanding artificial ones.

I understand that you use the "fft2" function to analyze an artificial image. The image is created by summing up the first five harmonics of a sine wave and expand it to the image height. The result shows difference in magnitudes between the DC component and the first harmonic. In addition, the result seems not to match the output from directly using the "fft" function on the 1D sine wave.

In the 1D example, you actually scale the result of the "fft" function to match the magnitudes of the DC component and the first harmonic, using:

>> P1(2:end-1) = 2*P1(2:end-1);

For the 1D example, you can directly display the result of the "fft" function and shift it using the "fftshift" function. The result should be very similar to the result of the 2D situation. The results from the "fft" function and the "fft2" function actually match. This is because the command

>> fft2(X)

is equivalent to

>> fft(fft(X).').'

For more details about the "fft2" function, refer to the following page:

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic. By continuing to use this website, you consent to our use of cookies. Please see our Privacy Policy to learn more about cookies and how to change your settings.