matlab批量读取文件夹中图片
file_path ='E:\graduate_student\Information_Hiding_CS_code\pictureDB\misc\';% 图像文件夹路径(注意misc文件夹后有一个斜杠)
img_path_list = dir(strcat(file_path,'*.Tiff'));%获取该文件夹中所有tiff格式的图像
img_num = length(img_path_list);%获取图像总数量
if img_num > 0 %有满足条件的图像
for j = 1:img_num %逐一读取图像
image_name = img_path_list(j).name;% 图像名
image =imread(strcat(file_path,image_name));
image_size=size(image);%判断维度,将彩色图片转换为灰度图
dimension=numel(image_size);
if dimension==3
image=rgb2gray(image);
end
end
end