# How to detect eyes and mouth on a single image in MATLAB?

35 views (last 30 days)
Anand on 6 Mar 2014
Answered: 123 on 22 Mar 2018
At the moment this code detect eyes and mouth in separate images, how can i combine these facial parts in 1 image, does anyone know how i would combine these features and output them in a single image.
Thankyou
%To detect Mouth
BB=step(MouthDetect,I);
figure,
imshow(I); hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','r');
end
title('Mouth Detection');
hold off;
%To detect Eyes
BB=step(EyeDetect,I);
figure,imshow(I);
rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
title('Eyes Detection');
Anand on 6 Mar 2014

Anand on 6 Mar 2014
%To detect Mouth
BB=step(MouthDetect,I);
figure,
imshow(I); hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','r');
end
%To detect Eyes
BB=step(EyeDetect,I);
hold on
rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
Just don't create a second figure like you're doing. Use the same figure and hold on.

veeresh singh on 2 May 2014
the above algo detects the regions by surrounding them with the rectangle regions...how to display the rectangular regions separately?...any code for automatically cropping that region and display it separately?
##### 2 CommentsShowHide 1 older comment
PRABHJOT SINGH on 1 Oct 2014
x = imcrop(I,BB(i,:));
imshow (I)
this would work and solve your problem ;)

123 on 22 Mar 2018
Can someone please give me a code to find the eyes and mouth. thank you very much