clear
clc
srcDir=uigetdir('F:\Data\preshear and relaxation\2013-11-26-SSBR80-60oC- 1 s-1 preshear and hold.','请选择读取目录'); %获得选择的文件夹
cd(srcDir);
allnames=struct2cell(dir('*.tif')); %只处理8位的bmp文件
[k,len]=size(allnames); %获得bmp文件的个数
saveDir=uigetdir('F:\Data\preshear and relaxation\2013-11-26-SSBR80-60oC- 1 s-1 preshear and hold.','请选择保存目录');
for ii=1:len %逐次取出文件
name=allnames{1,ii};
I=imread(name); %读取文件
fftI=fft2(I);
sfftI=fftshift(fftI);
RR=real(sfftI);
II=imag(sfftI);
A=sqrt(RR.^2+II.^2);
A=(A-min(min(A)))/(max(max(A))-min(min(A)))*225;
h=figure;
imshow(A);
%%
%by lds
colorbar
colormap('jet')
[~,lname]=size(name);
namefig=name(1:lname-3);saveas(gcf,[saveDir '\' namefig 'fig']) %保存fig的图像
print(1,'-dpng',[saveDir '\' namefig 'png']); %保存png的图像
close(h)
end
帮高中同学LXG修改过的代码