-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathrecognize_faces.m
More file actions
30 lines (25 loc) · 848 Bytes
/
Copy pathrecognize_faces.m
File metadata and controls
30 lines (25 loc) · 848 Bytes
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
28
function YPred = recognize_faces(RGB)
% RECOGNIZE_FACES - map images of faces to people names
% YPred = recognize_faces(RGB) accepts a cell array RGB of images, which
% should be RGB images. YPred returns a categorical array of image
% labels.
;
% Load precomputed model from a MAT file. For a format
% of the file, see the M-file main_fitcecoc.m.
load('model.mat');
num_images = size(RGB, 3);
% Get grayscale images of the desired size
Grayscale = cellfun(@(I)imresize(im2gray(I), targetSize),...
RGB, 'uni',false);
B = cat(3,Grayscale{:});
D = prod(targetSize);
B = reshape(B, D, []);
% Normalizing data...';
B = single(B)./256;
[B, C, SD] = normalize(B);
% Extract weights
W = U' * B;
% Predict faces
X = W';
YPred = predict(Mdl, X);
end