Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Enquiry on face detection code

Subject: Enquiry on face detection code

From: Darren LEE

Date: 9 Nov, 2010 10:30:55

Message: 1 of 2

hi all,

I having problem in understanding the below code which downloaded from
file exchange.


%Detection of Face on the basis of skin color
clear all;
close all;
clc
I=imread('face1.jpg');
imshow(I)
cform = makecform('srgb2lab');
J = applycform(I,cform);
figure;imshow(J);
K=J(:,:,2);
figure;imshow(K);
L=graythresh(J(:,:,2));
BW1=im2bw(J(:,:,2),L);
figure;imshow(BW1);
M=graythresh(J(:,:,3));
figure;imshow(J(:,:,3));
BW2=im2bw(J(:,:,3),M);
figure;imshow(BW2);
O=BW1.*BW2;
% Bounding box
P=bwlabel(O,8);
BB=regionprops(P,'Boundingbox');
BB1=struct2cell(BB);
BB2=cell2mat(BB1);

[s1 s2]=size(BB2);
mx=0;
for k=3:4:s2-1
    p=BB2(1,k)*BB2(1,k+1);
    if p>mx & (BB2(1,k)/BB2(1,k+1))<1.8
        mx=p;
        j=k;
    end
end
figure,imshow(I);
hold on;
rectangle('Position',[BB2(1,j-2),BB2(1,j-1),BB2(1,j),BB2(1,j
+1)],'EdgeColor','r' )


Can somebody explain to me step by step what does the "for function"
doing?


Thanks in advance

Subject: Enquiry on face detection code

From: ImageAnalyst

Date: 9 Nov, 2010 11:13:17

Message: 2 of 2

This wonderfully-commented, total mess of a code looks like a novice
programmer looping through all the bounding boxes trying to find the
bounding box that has the largest aspect ratio less than 1.8.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us