fftshift and ifftshif of an image

7 vues (au cours des 30 derniers jours)
Marco
Marco le 16 Jan 2013
HI, i have loaded and calculate the FFT of a RGB image and do the FFTshift to center the spectrum. My problem is that if I pass the return of fft to fftshift, fftshift mix up the chromatic planes (the 3rd dimension), so I have to run the fftshift function on every color plane, one for red, another for blue, and another for green. Specifically what I do is:
F=fft2(IMG_gray);
S(:,:,1)=fftshift(F(:,:,1));
S(:,:,2)=fftshift(F(:,:,2));
S(:,:,3)=fftshift(F(:,:,3));
Is there a function that do not mix up the color planes?

Réponse acceptée

Matt J
Matt J le 16 Jan 2013
Modifié(e) : Matt J le 16 Jan 2013
What you're already doing seems fine. If the idea is to do things in a single statement, you could do
S=fftshift(fftshift(F,1),2);
  1 commentaire
Marco
Marco le 17 Jan 2013
that worked, thanks

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 16 Jan 2013
If you're taking the FFT of a gray image (like the red channel = f(:,:,1)), as you're doing in:
F=fft2(IMG_gray);
then I don't see why F would have three color channels. Can you explain?
  2 commentaires
Marco
Marco le 17 Jan 2013
don't care for the name, it was an old code that worked with gray images, i modified it to load an RGB image. so IMG_gray is an RGB image, despite of the name
Image Analyst
Image Analyst le 17 Jan 2013
When you were doing the modifying, you should have changed the name too, so it was less confusing. Keeping code maintainable and understandable is an important aspect of code development that should not be underestimated, at least in a business or professional environment.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by