RGB图像的批处理
clear all;
close all;
clc;
file_path = 'pichuli2\';% 原图像文件夹路径
save_path = 'tran2\';% 生成图像文件夹路径
img_path_list = dir(strcat(file_path,'*.jpg'));%获取该文件夹中所有.jpg格式的图像
img_num = length(img_path_list);%获取图像总数
if img_num > 0 %有满足条件的图像
for pn = 1:img_num %逐一读取图像
image_name = img_path_list(pn).name;% 图像名
a = imread(strcat(file_path,image_name));%读取图像
fprintf('%d %s\n',pn,strcat(file_path,image_name));% 显示正在处理的图像名
%%下面添加具体的图像处理程序
……
……
……
……
……
end
end
批处理结果下载
以上省略号处,是你的图像处理程序,处理完之后,紧接着就是保存
imwrite(b,[save_path,num2str(pn),'.jpg']);
% saveas(gcf,[save_path,num2str(pn)],'jpg');
这两个保存,第一个是把处理后的图片b保存下来,第二个是把你的显示窗口figure整个保存下来。
转载:https://blog.csdn.net/qq_32973679/article/details/102570583
查看评论