-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfaceDsCreate.m
More file actions
85 lines (77 loc) · 2.54 KB
/
faceDsCreate.m
File metadata and controls
85 lines (77 loc) · 2.54 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function DS = faceDsCreate(faceInfo, type, feaName, saveOpt, DsName)
%faceDsCreate: create face DS for classification
%
% Usage:
%
% Description:
%
% Example:
% DS=faceDsCreate(faceDatasetRead('./demoDataset/Custom', 'jpg'), 'gender', 'LBP', 1);
%
% See also
% Category: faceAnalysis
% Mymy, 20130114, 20130114
if nargin < 1, selfdemo; return; end
if nargin < 2, type = 'gender'; end
if nargin < 3, feaName = 'LBP'; end
if nargin < 4, saveOpt = 1; end
if nargin < 5, DsName = [type 'DS_' feaName '.mat']; end
DS.dataName = type;
display('Start to create DS....');
for i = 1:length(faceInfo)
cropFace = imcrop(imread(faceInfo(i).filename),faceInfo(i).faceRectWithTuning);
[~, ~, dim]=size(cropFace);
if dim>=3, cropFace=rgb2gray(cropFace); end
switch feaName
case 'LBP'
DS.input(:, i) = LBP(cropFace)';
case 'LDP'
DS.input(:, i) = LDP(cropFace)';
case 'LTP'
DS.input(:, i) = LTP(cropFace)';
case 'garbor'
I = imresize(cropFace, [57 76], 'bicubic');
I = histeq(uint8(I));
I = double(I)/255;
DS.input(:, i) = gaborFilter(histeq(I));
otherwise
display('We have no this method!');
end
switch type
case 'age'
if (ageInfo.age <= 75)
DS.output(1, i) = ceil(ageInfo.age/15); % 15: age intervsl
else
DS.output(1, i) = 5;
end
case 'gender'
if strcmp(faceInfo(i).gender, 'male'), DS.output(1,i) = 1; end
if strcmp(faceInfo(i).gender, 'female'), DS.output(1,i) = 2; end
case 'expression'
if strcmp(faceInfo(i).expression, 'HA'), DS.output(1,i) = 1; end
if strcmp(faceInfo(i).expression, 'SA'), DS.output(1,i) = 2; end
if strcmp(faceInfo(i).expression, 'SU'), DS.output(1,i) = 3; end
if strcmp(faceInfo(i).expression, 'AN'), DS.output(1,i) = 4; end
if strcmp(faceInfo(i).expression, 'DI'), DS.output(1,i) = 5; end
if strcmp(faceInfo(i).expression, 'FE'), DS.output(1,i) = 6; end
otherwise
display('We have no this type!');
end
fprintf('progress==>%d / %d\n', i, length(faceInfo));
end
DS.inputName = cell(1,size(DS.input, 1)); % tmp to present feature
switch type
case 'age'
DS.outputName = {'1-15', '16-30', '31-45', '46-60', '61-'};
case 'gender'
DS.outputName = {'male', 'female'};
case 'expression'
DS.outputName = {'HA', 'SA', 'SU', 'AN', 'DI', 'FE'};
otherwise
display('We have no this type!');
end
if saveOpt, save(DsName, 'DS'); end
display('Done.');
function selfdemo
mObj=mFileParse(which(mfilename));
strEval(mObj.example);