您的位置:首页 > 编程语言 > MATLAB

matlab 批量读取文件夹内所有图片的几种方法

2017-10-30 18:57 507 查看
直接上代码:
% 如果你的图片命名方式是1.bmp  2.bmp.......
clear;clc;
file_path =  '你的需要处理的图片的文件夹路径\';
img_path_list = dir(strcat(file_path,'*.bmp'));
img_num = length(img_path_list);
if img_num > 0
for j = 1:img_num
image =  imread(strcat(int2str(j),'.bmp'),'bmp');
% % 或者
% image_name = img_path_list(j).name;
% image =  imread(strcat(file_path,image_name));

end
end

% 如果你的图片命名方式是first00001.bmp  first00002.bmp.......first00050.bmp
clear;clc;
file_path =  '你的需要处理的图片的文件夹路径\';
img_path_list = dir(strcat(file_path,'*.bmp'));
img_num = length(img_path_list);
if img_num > 0
for j = 1:img_num
is=num2str(Startframe1);
number = '00000';  % 这个可以是五个0  也可以是6个0等
number(end-length(is)+1:end)=is;
filename11=[ file_path1 'first' number '.bmp'];
image = imread(filename11);
end
end


% 侵删
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息