필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
Anand
Anand 2014년 3월 6일
답변: 123 2018년 3월 22일
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
%Read the input image I = imread('extract1.png');
%To detect Mouth
MouthDetect = vision.CascadeObjectDetector('Mouth','MergeThreshold',16);
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
EyeDetect = vision.CascadeObjectDetector('EyePairBig');
BB=step(EyeDetect,I);
figure,imshow(I);
rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
title('Eyes Detection');

채택된 답변

Anand
Anand 2014년 3월 6일
%Read the input image
I = imread('extract1.png');
%To detect Mouth
MouthDetect = vision.CascadeObjectDetector('Mouth','MergeThreshold',16);
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
EyeDetect = vision.CascadeObjectDetector('EyePairBig');
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.

추가 답변 (2개)

veeresh singh
veeresh singh 2014년 5월 2일
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
Image Analyst
Image Analyst 2014년 5월 2일
That's not how it detects them. That's how it indicates them so you can see what it found, after they've been detected. You can crop out the sub image like this:
subImage = imcrop(I, BB); % Crop box BB out of image "I".
PRABHJOT SINGH
PRABHJOT SINGH 2014년 10월 1일
편집: PRABHJOT SINGH 2014년 10월 1일
x = imcrop(I,BB(i,:));
imshow (I)
this would work and solve your problem ;)

댓글을 달려면 로그인하십시오.


123
123 2018년 3월 22일
Can someone please give me a code to find the eyes and mouth. thank you very much

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by