-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataBaseCreator.m
48 lines (48 loc) · 1.93 KB
/
DataBaseCreator.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function DataBaseCreator(direction)
faceDetector = vision.CascadeObjectDetector('ClassificationModel','FrontalFaceLBP');
strh = strcat(direction,'/Hombres/*.bmp');
strm = strcat(direction,'/Mujeres/*.bmp');
imagefilesH = dir(strh);
imagefilesM = dir(strm);
nfilesH = length(imagefilesH);
nfilesM = length(imagefilesM);
mkdir('BaseDeDatos','CarasHombres');
mkdir('BaseDeDatos','CarasMujeres');
for h=1:nfilesH
currentfilename = strcat(direction,'/Hombres/',imagefilesH(h).name);
currentimage = imread(currentfilename);
I = histeq(currentimage);
bboxes = step(faceDetector, I);
IFaces = insertObjectAnnotation(I, 'rectangle', bboxes, 'Face');
if(size(bboxes,1)>0)
if (size(bboxes,1)>1)
[M,index] = max(bboxes(:,3));
bboxes=bboxes(index,:);
end
IfaceDetected = I((bboxes(1,2):(bboxes(1,2)+bboxes(1,4)-1)),(bboxes(1,1):(bboxes(1,1)+bboxes(1,3)-1)));
%segunda ecualizacion debido a fondos muy contrastados(claros u
%oscuros)
Prueba = histeq(IfaceDetected);
filename2=['BaseDeDatos/CarasHombres/hombre (' num2str(h) ').bmp'];
imwrite(Prueba, filename2);
end
end
for m=1:nfilesM
currentfilename = strcat(direction,'/Mujeres/',imagefilesM(m).name);
currentimage = imread(currentfilename);
I = histeq(currentimage);
bboxes = step(faceDetector, I);
IFaces = insertObjectAnnotation(I, 'rectangle', bboxes, 'Face');
if(size(bboxes,1)>0)
if (size(bboxes,1)>1)
[M,index] = max(bboxes(:,3));
bboxes=bboxes(index,:);
end
IfaceDetected = I((bboxes(1,2):(bboxes(1,2)+bboxes(1,4)-1)),(bboxes(1,1):(bboxes(1,1)+bboxes(1,3)-1)));
%segunda ecualizacion debido a fondos muy contrastados(claros u
%oscuros)
Prueba = histeq(IfaceDetected);
filename2=['BaseDeDatos/CarasMujeres/mujer (' num2str(m) ').bmp'];
imwrite(Prueba, filename2);
end
end