Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
I = bwareaopen(mascara, 200);
imshow(I);hold on
pause(2)
[L Ne]=bwlabel(double(I),8);%etiqueta objetos
%recupera propiedades de objetos etiquetados
prop=regionprops(L,'Area','Centroid', 'BoundingBox','Extent');
total=0;
for n=1:size(prop,1) %Dibuja marco verde alrededor de caras
boundingBox = prop(n).BoundingBox;
x1 = boundingBox(1);%recupera limites por cada objeto
y1 = boundingBox(2);
x2 = x1 + boundingBox(3) - 1;
y2 = y1 + boundingBox(4) - 1;
verticesX = [x1 x2 x2 x1 x1];
verticesY = [y1 y1 y2 y2 y1];
xtotal=abs(x1-x2);
ytotal=abs(y1-y2);
cent=prop(n).Centroid;
X=cent(1);Y=cent(2);
if prop(n).Extent>.4 %llenado del bounding box
%discrimina rectangulos muy grandes
if ((xtotal-ytotal)<(4*ytotal))&&((ytotal-xtotal)<(3*xtotal))
plot(verticesX, verticesY, 'g-', 'LineWidth', 2);
total=total+1; % cuenta el total de caras
end
end
end