300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > matlab 读取同一文件中所有图像_matlab 批量读取文件夹内所有图片的几种方法

matlab 读取同一文件中所有图像_matlab 批量读取文件夹内所有图片的几种方法

时间:2021-10-20 01:12:53

相关推荐

matlab 读取同一文件中所有图像_matlab 批量读取文件夹内所有图片的几种方法

直接上代码:

% 如果你的图片命名方式是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'));

% % 或者

% image_name = img_path_list(j).name;

% image = imread(strcat(file_path,image_name));

end

end

% 如果你的图片命名方式是first1.jpg first2.jpg....first50.jpg.....

clear all;

clc;

file_path1 ='C:\Users\Administrator\Desktop\1\';

img_path_list1 = dir(strcat(file_path1,'*.jpg'));

Len= length(img_path_list1); % 获取图像总数量 (三个图片文件夹中图片数量一致)

for k=1:Len

Img = imread([file_path1,'first',num2str(k),'.jpg']);

imshow(Img)

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

% 侵删

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。