Magnitude not showing up

1 vue (au cours des 30 derniers jours)
u-will-neva-no
u-will-neva-no le 18 Nov 2012
Hey everyone, I found this code on a website and a simplified version is:
%2D FFT Demo
close all;
clear all;
%Import images
imageA = imread('greekchurch.jpg');
%Display images
figure, imshow(imageA)
title('Image A - Greek Church')
%Perform 2D FFTs
fftA = fft2(double(imageA));
%Display magnitude and phase of 2D FFTs
figure, imshow(abs(fftshift(fftA)),[24 100000]), colormap gray
title('Image A FFT2 Magnitude')
When I run it, the image output is white. Anyone know whats wrong?

Réponse acceptée

Image Analyst
Image Analyst le 18 Nov 2012
Try
imshow(abs(fftshift(fftA)),[]);
Or, to compress the scale,
imshow(log(abs(fftshift(fftA))), []);
  3 commentaires
Image Analyst
Image Analyst le 18 Nov 2012
Modifié(e) : Image Analyst le 18 Nov 2012
Your DC component is probably so huge you don't see it. Try this code and see a working version:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
%2D FFT Demo
%Import images
myImage = imread('cameraman.tif');
[rows columns numberOfColorChannels] = size(myImage)
if numberOfColorChannels > 1
myImage = rgb2gray(myImage);
end
%Display images
subplot(2, 2, 1);
imshow(myImage)
title('Original Gray Scale Image', 'FontSize', fontSize)
%Perform 2D FFTs
fftA = fft2(double(myImage));
shiftedFFT = fftshift(fftA);
subplot(2, 2, 2);
imshow(real(shiftedFFT));
title('Real Part of Spectrum', 'FontSize', fontSize)
subplot(2, 2, 3);
imshow(imag(shiftedFFT));
title('Imaginary Part of Spectrum', 'FontSize', fontSize)
%Display magnitude and phase of 2D FFTs
subplot(2, 2, 4);
imshow(log(abs(shiftedFFT)),[]);
colormap gray
title('Image A FFT2 Magnitude');
title('Log Magnitude of Spectrum', 'FontSize', fontSize)
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
u-will-neva-no
u-will-neva-no le 18 Nov 2012
Perfect. Thanks so much!

Connectez-vous pour commenter.

Plus de réponses (1)

Yusef
Yusef le 14 Mai 2013
Modifié(e) : Yusef le 14 Mai 2013
I had the same problem, just need
I=imread('image.bmp');
I = rgb2gray(I);
fftA = fft2(double(I));

Catégories

En savoir plus sur Blue dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by