1.MATLAB批量读取固定格式文件
file_path = 'D:\mormal_dibright\';% 图像文件夹路径
img_path_list = dir(strcat(file_path,'*.bmp'));%获取该文件夹中所有bmp格式的图像
img_num = length(img_path_list);%获取图像总数量
I=cell(1,img_num);
if img_num > 0 %有满足条件的图像
for j = 1:img_num %逐一读取图像
image_name = img_path_list(j).name;% 图像名
image = imread(strcat(file_path,image_name));
I{j}=image;
fprintf('%d %d %s\n',i,j,strcat(file_path,image_name));% 显示正在处理的图像名
%图像处理过程 省略
%这里直接可以访问细胞元数据的方式访问数据
end
end
savepath='D:\yl\数据\';
for i=1:600
Image=imread([num2str(i,'%d'),'_predict_prob','.png']); %读入图片,如1_predict_prob.png
%*********处理图片(省略)**********%
imwrite(Image,[savepath,num2str(i,'%04d'),'.png']);%将处理后的图片保存在D:\yl\数据\下,命名为0001.png
end
2. 文件夹下cmd命令行批量生成pos和neg的图片路径
dir /s/b *.jpg* > b.txt exit