这个很简单的,一起来学习吧!
close all;
clear all;
clc;
input_path='.\picture\';%图像文件夹路径
output_path='E:\研0暑假工作\MATLAB学习\程序\';
file_path_list=dir(strcat(input_path,'L*'));%列出当前文件夹文件的所有信息,有name,format等
%strcat串联两个字符串等;
%dir列出当前文件夹里的所有文件和文件夹
len=length(file_path_list);%获取图像总数
fprintf('正在读取的图像为: \n');
figure('name','毕业照');
if len>0%有图像
for j=1:len%逐一读取
name=file_path_list(j).name;
I=imread(strcat(input_path,name));%读取
fprintf('第%d个:%s\n',j,strcat(input_path,name));
subplot(2,2,j),imshow(I),title(j);%图片的显示
imwrite(I,[output_path,'PL',int2str(j),'.jpg']);%图片的保存
end
end