Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you cut a face out of an image?

I have been given an image with rgb channels. I only want to see the persons face. How would I do that? Are neural nets used for this? If so, are there existing data files from neural nets that have already done the processing?

like image 478
user1873073 Avatar asked Oct 04 '13 04:10

user1873073


2 Answers

Since your questions is tagged with OpenCV, I will assume that you are looking for a solution within this library.

The first step is to find the faces. For this, use one of the cascade object detectors that are available: either the Viola-Jones one or the LBP one. OpenCV comes with cascades trained for face detection for each of these detectors.

Then, it depends if getting a bounding box is enough or not.

If you need something more accurate, then you can:

  • [coarse face] use a skin color detector inside the face bounding box to get a finer face estimate, binarize the image and finally close the face shape using morphological filtering;
  • [fine face contour] use something like a grabcut procedure to get a pixel-accurate contour. You can initialize the grabcut with borders of the bounding box as background and center part of the bounding box as foreground.
like image 149
sansuiso Avatar answered Oct 05 '22 14:10

sansuiso


Not really sure what you want to do, but you can use Haar Classifier for face detection.

From then on, it should be easy to only display the face. While there are available classifiers online, you can try training your own classifier should you have the time. I have done classifiers on hand, face, eyes before and it have an impressive result.

Should you need more help on training classifier, etc, just comment here, I will try my best to assist you.

like image 39
rockinfresh Avatar answered Oct 05 '22 16:10

rockinfresh