## Real Time face region of interested like Eyes nose and Mouth keypoints

### SAMEER ahamed (view profile)

on 12 Nov 2013
Latest activity Edited by Walter Roberson

### Walter Roberson (view profile)

on 27 Jan 2014
Hi,
using matlab R2013a live video processing detect face region of interest eyes , nose and mouth morphology segmented process , after that lip segmentation key points like upper , lower and centroid points . up to code i have tried to implement , now i need to convert gray2ind to skin color image , and extract lip key points . please let me know how i can achieve correct eyes detection's (Viola Jones Algorith Left and Right) and Lip Key Points?
faceImage = imcrop(I, [xb yb wb hb]);
bbox(i,:) =bbox(1,:);
[hue,s,v]=rgb2hsv(faceImage);
cb = 0.148* faceImage(:,:,1) - 0.291* faceImage(:,:,2) + 0.439 * faceImage(:,:,3) + 128;
cr = 0.439 * faceImage(:,:,1) - 0.368 * faceImage(:,:,2) -0.071 * faceImage(:,:,3) + 128;
[w h]=size(faceImage(:,:,1));
for i=1:w
for j=1:h
if 140<=cr(i,j) & cr(i,j)<=165 & 140<=cb(i,j) & cb(i,j)<=195 & 0.01<=hue(i,j) & hue(i,j)<=0.1
segment(i,j)=1;
else
segment(i,j)=0;
end
end
end
se = strel('disk',1);
se2 = strel('disk',1);
% se2 = strel('disk',3);
er = imerode(segment,se2);
cl = imclose(er,se);
dil = imdilate(cl,se); % morphologic dilation
dil = imdilate(dil,se);
cl2 = imclose(dil,se);
d2 = imfill(cl2, 'holes'); % morphologic fill
skelImg = bwmorph(d2,'skel',Inf);
BW = edge(skelImg,'canny');
BW1 = bwareaopen(BW,40);
[X, MAP] = gray2ind(d2,64);
% RGB = ind2rgb(X,map);
% face(:,:,1) = double(faceImage(:,:,1)).*d2;
% face(:,:,2) = double(faceImage(:,:,2)).*d2;
% face(:,:,3) = double(faceImage(:,:,3)).*d2;
% face_a = uint8(face);
end
end
l_Eye = step(leftEye , faceImage);
x1 = l_Eye(1); y1 = l_Eye(2); w1 = l_Eye(3); h1 = l_Eye(4);
mboxPolygon =[x1, y1, x1+w1, y1,x1+w1,y1+h1, x1, y1+h1];
% l_Eye = [x1-1, y1-1, l_Eye(3), 2* (l_Eye(4))];
% for m = 1:size(l_Eye ,1)
leye = imcrop( faceImage ,[x1 y1 w1 h1]);
% end
R_Eye = step(rightEye,faceImage);
x2 = R_Eye(1); y2 = R_Eye(2); w2 = R_Eye(3); h2 = R_Eye(4);
% R_Eye = [x2-1, y2-1, R_Eye(3), 2* (R_Eye(4))];
% for m = 1:size(R_Eye ,1)
reye = imcrop( faceImage , [x2 y2 w2 h2]);
% end
BB=step(NoseDetect,faceImage);
x = BB(1,1); y = BB(1,2); w = BB(1,3); h = BB(1,4);
for i = 1:size(BB,1)
nose = imcrop(faceImage ,[x y w h]);
BB(i,:) =BB(1,:);
end
mregcrop = imcrop(faceImage, [1 floor(2*bbox(4)/3) bbox(3) floor(bbox(4))]);
mbox = step(mouthDetector, mregcrop);
x3 = mbox(1,1); y3 = mbox(1,2); w3 = mbox(1,3); h3 = mbox(1,4);
mouthcrop = imcrop(mregcrop ,[x3 y3 w3 h3]);