代码语言:javascript复制
train = cell(11400, 1);
label = zeros(11400, 1);
dis1 = dir(['E:AdeskCpp-PrimerPCANetPCANetdatastrain' '.']);
nms1 = {dis1.name};
i=0;
for m = 1:length(nms1)
nm1 = ['E:AdeskCpp-PrimerPCANetPCANetdatastrain' nms1{m}];
dis2 = dir([nm1 '*.jpg']);
nms2 = {dis2.name};
for k = 1:length(nms2)
i = i 1;
nm2 = ['E:AdeskCpp-PrimerPCANetPCANetdatastrain' nms1{m} '' nms2{k}]; % 注意要加上路径
train{i} = double(rgb2gray(imread(nm2)));
label(i) = double(m-2);
m
k
end
end
save('Mont_data.mat','train', 'label');