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  

猜你喜欢

转载自blog.csdn.net/yaqin1112/article/details/80051772