在MATLAB里如何实现对一个文件夹里的图片进行检索?

如题所述

用system(['mkdir
',dirname]);新建一个文件夹,然后cd(dirname)进去这个文件夹,然后就imwrite(im,imagename,'jpg')保存图片
温馨提示:答案为网友推荐,仅供参考
第1个回答  2019-08-05
这是读取两层文件夹里图片的示例。
clc;
clear;
fatherPath=['C:\Users\chen\Desktop\
人脸识别
\faces'];
dirs=dir(fatherPath);
dircell=
struct2cell
(dirs);
for
i=3:length(dircell)
subdirs=dircell(1,i);
SonPath=[fatherPath
'\'
cell2mat
(subdirs)];
%SonPath=[fatherPath
'\'
cell2mat(subdirs)
'\*.pgm'];
dirs2=dir(SonPath);
dircell2=struct2cell(dirs2);
for
j=3:length(dirs2)
PictureName=dircell2(1,j);
PicturePath=[SonPath
'\'
cell2mat(PictureName)];
tempimg=imread(PicturePath);
%
imgname=[SonPath
'\'
cell2mat(PictureName)
'.png'];
imgname=['C:\Users\chen\Desktop\人脸识别\png\'
cell2mat(PictureName)
'.png'];
imwrite(tempimg,imgname);
end
end