dariush
dariush

Reputation: 3341

Why i cannot getting correct Fourier transformed image using matlab?

I am trying a test some Fourier transformation operations, but i cannot get correct Fourier transformed image, for example, consider following images:

Lennaenter image description hereWhat is suppose to be

The last image is the Fourier transformed image what which should be my output

The matlab code i have used is as following:

function fftshow(file)
    close all;
    img=imread(file);
    ft=fft2(img(:,:,1));
    sft=fftshift(ft);
    asft = abs(sft);
    lasft = log2(asft+1);
    imagesc(img), title('The real image');
    pause
    imagesc(asft), colormap([0,0,0;1,1,1]), title('The magnitude image');
    pause
    imagesc(lasft), colormap([0,0,0;1,1,1]), title('The log2 magnitude image');
    clear img ft sft;
end

what am i doing wrong?

Any help would be appreciated.

Upvotes: 0

Views: 240

Answers (1)

lennon310
lennon310

Reputation: 12699

colormap([0,0,0;1,1,1]) works as a binary display, use colormap(gray) instead.

Upvotes: 2

Related Questions