Magnitude not showing up
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
Image Analyst
2012년 11월 18일
Try
imshow(abs(fftshift(fftA)),[]);
Or, to compress the scale,
imshow(log(abs(fftshift(fftA))), []);
댓글 수: 3
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]);
참고 항목
카테고리
Help Center 및 File Exchange에서 Blue에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!