写个简单版的(竟然没有matlab语言的选择项):
clc;clear;
file_path1 = 'D:\Documents\MATLAB\毕业设计图\第四章\old\';% 图像文件夹路径
file_path2 = 'D:\Documents\MATLAB\毕业设计图\第四章\new\';% 图像文件夹路径
img_path_list = dir(strcat(file_path1,'*.bmp'));%获取该文件夹中所有bmp格式的图像
img_num = length(img_path_list);%获取图像总数量
I=cell(1,img_num);
if img_num > 0 %有满足条件的图像
for j = 1:img_num %逐一读取图像
image_name_old = img_path_list(j).name;% 图像名
image_name_new = image_name_old;
image_name_new(1)='5';
image = imread(strcat(file_path1,image_name_old));
imwrite(image,strcat(file_path2,image_name_new))
end
end