Matlab频谱图生成代码如下
clear,clc,close all;grayI=imread('7.png');%读取图像grayI=im2gray(grayI);DFT=fft2(grayI);ADFT=abs(DFT);top=max(ADFT(:));bottom=min(ADFT(:));ADFT1=(ADFT-bottom)/(top-bottom)*100;ADFT2=fftshift(ADFT1);%计算傅里叶变换并移位subplot(131),imshow(grayI),title('原图');%显示原图像subplot(132),imshow(ADFT1),title('原频谱图');%显示傅里叶变换频谱图subplot(133),imshow(ADFT2),title('移位频谱图');%显示傅里叶变换频谱图% imwrite(ADFTI1,'li5-1-1.jpg');% imwrite(ADFTI2,'li5-1-2.jpg');