forked from dxyzx0/TRSVD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadYaleDataset.m
27 lines (27 loc) · 918 Bytes
/
readYaleDataset.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function readYaleDataset(dataDir , saveName) %
dirs = dir(dataDir);
data = [];
labels = [];
for i = 3:numel(dirs)
imgDir = dirs(i).name;
imgDir = fullfile(dataDir, imgDir);
imgList = dir(fullfile(imgDir, '*.pgm')); %
for j = 1:20 %numel(imgList)
imgName = imgList(j).name;
if strcmp('Ambient.pgm', imgName(end-10:end))
continue;
end
im = imread(fullfile(imgDir, imgName));
if size(im, 3) ==3
im = rgb2gray(im);
end
im = imresize(im, [32 32]);
im = reshape(im, 32*32, 1);
data = [data im];
end
labels = [labels ones(1, 20-1) * (i-2)];
% disp('success');
end
disp('all images are saved');
save(saveName, 'data', 'labels');
end