cl;
img=imread('15.bmp');
%img=double(img);
f=fft2(img); %傅里葉變換
f=fftshift(f); %使圖像對稱
r=real(f); %圖像頻域實部
i=imag(f); %圖像頻域虛部
margin=log(abs(f)); %圖像幅度譜,加log便於顯示
phase=log(angle(f)*180/pi); %圖像相位譜
l=log(f);
subplot(2,2,1),imshow(img),title('源圖像');
%subplot(2,2,2),imshow(l,[]),title('圖像頻譜');
subplot(2,2,3),imshow(margin,[]),title('圖像幅度譜');
subplot(2,2,4),imshow(phase,[]),title('圖像相位譜');