is my code correct for this question? Get the Fourier transform of image3 using the fft2() command. If the result does not seem to be interesting, center the spectrum of the r

1 view (last 30 days)
Get the Fourier transform of image3 using the fft2() command.
If the result does not seem to be interesting, center the spectrum of the result using the fftshift() command.
A=fft2(img3)
X=fftshift(img3)
image3=abs(A)
plot(image3)
imshow(image3,[])
image32=abs(X)
plot(image32)
imshow(image32,[])

Answers (1)

Varun
Varun on 24 Mar 2023
Hello!
As per my understanding, you want to apply the 2D fast Fourier transform using “fft2” on your image and then call the “fftshift” function to centre the spectrum. I think there’s an error in your code. The input argument to the “fftshift” function must be the result of the “fft2” that has been called in the previous line. So, insteading of passing "img3" to "fftshift",
X=fftshift(A)
should do the job. As for plotting the image, plot only works for 2D data, while the image you may be using this on can be 3D, so that can lead to an error. But imshow()should be sufficient to display the image. You can pass the resulting image ‘X’ as the input argument after each step to see the outcome.
imshow(X,[])
You may refer to the following documentation for more details:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!