MATLAB批量读入图片


%% import pictures, and save into images{img_num}
function [images] = import_data(file_path)
    % 批量读取图片
    img_path_list = dir(strcat(file_path,'*.jpg'));%获取该文件夹中所有jpg格式的图像  
    img_num = length(img_path_list);%获取图像总数量  
    images = cell(1, img_num);
    if img_num > 0 %有满足条件的图像  
        for i = 1:img_num %逐一读取图像  
            image_name = img_path_list(i).name;% 图像名  
            images{i} =  im2bw(imread(strcat(file_path, image_name)));
            % fprintf(' %d %s\n',i,strcat(file_path,image_name));% 显示正在处理的图像名  
        end  
    end  
end


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM