Is my code correct?
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,[])

 Réponse acceptée

Walter Roberson
Walter Roberson le 8 Déc 2022

0 votes

You should rarely plot an image. plot() is for creating line plots.
Your code will produce plots with one line for each column in A or X. It is not forbidden ... it just is seldom a good idea. Too difficult to make any sense out of the resulting plot.

5 commentaires

Hind Aljallaf
Hind Aljallaf le 8 Déc 2022
Do you think that I should go with this same code, but just delete the plotting commands?
Steven Lord
Steven Lord le 8 Déc 2022
It depends. Can you explain in more detail exactly what you're trying to do? Knowing that may help us offer better suggestions for how to achieve your goal.
Walter Roberson
Walter Roberson le 8 Déc 2022
I think "Get the" through "if the result" is the wording of the assignment.
Hind Aljallaf
Hind Aljallaf le 8 Déc 2022
i dont understand what you are saying
Steven is indicating that he does not see a statement from you of what you are trying to achieve, and so cannot make a recommendation as to whether your code is acceptable or should be changed. And I replied that it looks to me as if your lines
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.
are the statement of what you want to do.
I find your code a bit awkward but it looks like it would work.
Hint:
a = randi([-9 9], 1,5) + 1i*randi([-9 9],1,5);
mat2str(a)
ans = '[4+8i -4-8i -2+8i 7+3i -4-1i]'
out1 = fftshift(abs(a));
out2 = abs(fftshift(a));
mat2str(out1)
ans = '[7.61577310586391 4.12310562561766 8.94427190999916 8.94427190999916 8.24621125123532]'
mat2str(out2)
ans = '[7.61577310586391 4.12310562561766 8.94427190999916 8.94427190999916 8.24621125123532]'
out1 == out2
ans = 1×5 logical array
1 1 1 1 1

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by