Magnitude not showing up

2 ビュー (過去 30 日間)
u-will-neva-no
u-will-neva-no 2012 年 11 月 18 日
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?

採用された回答

Image Analyst
Image Analyst 2012 年 11 月 18 日
Try
imshow(abs(fftshift(fftA)),[]);
Or, to compress the scale,
imshow(log(abs(fftshift(fftA))), []);
  3 件のコメント
Image Analyst
Image Analyst 2012 年 11 月 18 日
編集済み: Image Analyst 2012 年 11 月 18 日
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 2012 年 11 月 18 日
Perfect. Thanks so much!

サインインしてコメントする。

その他の回答 (1 件)

Yusef
Yusef 2013 年 5 月 14 日
編集済み: Yusef 2013 年 5 月 14 日
I had the same problem, just need
I=imread('image.bmp');
I = rgb2gray(I);
fftA = fft2(double(I));

カテゴリ

Help Center および File ExchangeExplore and Edit Images with Image Viewer App についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by