clc,clear;
file_path = 'C:\data\images\'; %待转化图片的文件路径
img_path_list = dir(strcat(file_path,'*.png'));%读取该路径下文件中所有png格式图片(可改)
img_num = length(img_path_list); %获取图片数量
for j = 1:img_num
image_name = img_path_list(j).name; %获取图片名字
photo = imread(strcat(file_path,image_name));%读图片,strcat为字符串拼接
filename = strcat(num2str(i),'.bmp'); %根据需求改名字(根据需求变)
bmp_file = fullfile('C:\data\images_bmp\',filename); %新建文件
imwrite(photo ,bmp_file,'bmp'); %将png转换为bmp
end
来源:CSDN
作者:啊哈石头
链接:https://blog.csdn.net/qq_43547049/article/details/104117578