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

Computer Vision Toolboxcorner detectionemotion detectionexpression recognitionface detectionImage Acquisition Toolboximage processingImage Processing Toolbox

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');

Best Answer

%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.