train = cell(11400, 1);
label = zeros(11400, 1);
dis1 = dir(['E:\Adesk\Cpp-Primer\PCANet\PCANet\datas\train\' '.']);
nms1 = {dis1.name};
i=0;
for m = 1:length(nms1)
nm1 = ['E:\Adesk\Cpp-Primer\PCANet\PCANet\datas\train\' nms1{m}];
dis2 = dir([nm1 '\*.jpg']);
nms2 = {dis2.name};
for k = 1:length(nms2)
i = i+1;
nm2 = ['E:\Adesk\Cpp-Primer\PCANet\PCANet\datas\train\' 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');