showfft.m

来自「to find stastical moments」· M 代码 · 共 33 行

M
33
字号
% function showfft(input_image,)
% show the 2d fft transform of an gray scale image
% input:  input_image -- input image, should be gray scale image
%         with_phase  -- =1 show phase and fft magnitude  (shifted)
%                        =0 show magnitude (shifted) only

function showfft(img,with_phase)

colormap(gray(256));

if with_phase==1,
% with phase
%    img = double(img);

    fft_img = fft2(img);
    subplot(221); imshow(img,[]); title('Image');  
    pause;
    subplot(222); imshow(log10(abs(fft_img)),[]); title('FFT log Magnitude (not shifted)');
    subplot(223); imshow(fftshift(log10(abs(fft_img))),[]); title('FFT log Magnitude (shifted)');
    subplot(224); imshow(fftshift((angle(fft_img)+3.14)/6.28),[]); title('FFT Phase (shifted)');
    h = gcf;
    truesize(h,[256*4 256*4]);
    pause; 
    clf;
else
% without phase 
    fft_img = fft2(img);
    subplot(121); imshow(img,'truesize'); title('Image'); 
    subplot(122); imagesc(fftshift(log10(abs(fft_img)))); title('FFT log Magnitude (shifted)');
    pause;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?