필터 지우기
필터 지우기

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 CenterFile Exchange에서 Explore 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