Image processing can be used to process various objects in various ways and one for them is the face detection. The face detection system has got many applications and developing such a system is even easier by use of the Image Processing ToolBox available in MATLAB.
The detection of face involves various tasks. They can be summarized in three steps as:-
- reading of a RGB image
- minimisation of background portion
- detection of face object
Here is the code for the detection of the face area. Save it as filename.m file and execute the code in matlab.
%%%%% Reading of a RGB image
i=imread('imagepath'); % for eg. C:\P1140119.jpg
%%%%% minimisation of background portion
if (y2<=c | y2>=9*c) | (x1==1 | x2==r*10)
%%%%% detection of face object
L = bwlabel(BW,8);
BB = regionprops(L, 'BoundingBox');
if p>mx & (BB2(1,k)/BB2(1,k+1))<1.8
The sample output for the image read from my computer is shown below:-
The final output is the one with detected area of the face.
The algorithm can be extended to detect even more precisely the area of the face.