使用matlab对二级子目录中的特定图像进行提取并复制到指定文件夹中

%% 
clear all; close all; clc;

%%
Dataset = '/home/xn/caffe/examples/facetestquestions/ImageDatainc';
Folder = dir(Dataset);
DST_PATH_t = '/home/xn/caffe/examples/facetestquestions/test';
Folder(1:2) = [];
NumCls = length(Folder);

%% 
for iCls = 1:NumCls
    ClsName = Folder(iCls).name;
    ImgPath = dir(fullfile(Dataset, ClsName,'*.jpg'));
    for iImg = [2 6 13]
        filename=['/home/xn/caffe/examples/facetestquestions/ImageDatainc/',ClsName,'/',ImgPath(iImg).name];
        end_path = [DST_PATH_t,'/',ClsName];
        mkdir(end_path);
        copyfile(filename, end_path); 
    end
end
fclose(fid);

猜你喜欢

转载自blog.csdn.net/xunan003/article/details/80377486