jpg,png,txt等文件的读取 matlab

第一个代码解决问题, jpg,png,txt等文件的读取 

第二个代码除了解决上述问题,还要从更多的图片中找到与上面对应的图片,选取出来

namelist = dir('C:\Users\DELL\Desktop\data\helen\train\train_res\*.jpg');
namelist1 = dir('C:\Users\DELL\Desktop\data\helen\train\train_res\*.txt');

% 读取后namelist 的格式为
% name -- filename
% date -- modification date
% bytes -- number of bytes allocated to the file
% isdir -- 1 if name is a directory and 0 if not
img = cell(1954,1);
text = cell(1954,1);
len = length(namelist);
for i = 1:len
    file_name{i}=namelist(i).name;
    file_name1{i}=namelist1(i).name;
    img{i}= imread(strcat('C:\Users\DELL\Desktop\data\helen\train\train_res\',file_name{i}));
    text{i} = load(strcat('C:\Users\DELL\Desktop\data\helen\train\train_res\',file_name1{i}));
end
namelist = dir('C:\Users\DELL\Desktop\data\helen\train\train_res\*.jpg');
namelist1 = dir('C:\Users\DELL\Desktop\data\helen\train\train_res\*.txt');
namelist2 = dir('C:\Users\DELL\Desktop\helen\helen\trainset\*.jpg');
% 读取后namelist 的格式为
% name -- filename
% date -- modification date
% bytes -- number of bytes allocated to the file
% isdir -- 1 if name is a directory and 0 if not
img = cell(1954,1);
img1 = cell(1954,1);
text = cell(1954,1);
len = length(namelist);
for i = 1:len
    file_name{i}=namelist(i).name;
    file_name1{i}=namelist1(i).name;
    img{i}= imread(strcat('C:\Users\DELL\Desktop\data\helen\train\train_res\',file_name{i}));
    img1{i} = imread(strcat('C:\Users\DELL\Desktop\helen\helen\trainset\',file_name{i}));
    text{i} = load(strcat('C:\Users\DELL\Desktop\data\helen\train\train_res\',file_name1{i}));
end

猜你喜欢

转载自blog.csdn.net/YeziTong/article/details/84939182