% This is a basic code for Face & Face parts Detection
% Mahdi Jampour
close all; clc; clear all;
img = imread('img.jpg');
detector = buildDetector();
[bbox bbimg faces bbfaces] = detectFaceParts(detector,img,2);
%===================================================================== Face
y =bbox(1,1); x =bbox(1,2);
w =bbox(1,3); l =bbox(1,4);
Part_Face = img(x:x+l, y:y+w,:);
figure, imshow(Part_Face);
%================================================================= Left eye
y =bbox(1,5); x =bbox(1,6);
w =bbox(1,7); l =bbox(1,8);
Part_LeftEye= img(x:x+l, y:y+w,:);
figure, imshow(Part_LeftEye);
%================================================================ Right eye
y =bbox(1,9); x =bbox(1,10);
w =bbox(1,11); l =bbox(1,12);
Part_RightEye= img(x:x+l, y:y+w,:);
figure, imshow(Part_RightEye);
%==================================================================== Mouth
y =bbox(1,13); x =bbox(1,14);
w =bbox(1,15); l =bbox(1,16);
Part_mouth = img(x:x+l, y:y+w,:);
figure, imshow(Part_mouth);
%===================================================================== Nose
y =bbox(1,17); x =bbox(1,18);
w =bbox(1,19); l =bbox(1,20);
Part_nose = img(x:x+l, y:y+w,:);
figure, imshow(Part_nose);
%=================================================================== Finish
|