My data set contains a number of high resolution greyscale images containing a person's face. A single image containing the background without the face is provided. The background is mostly static in the image, except for some minor changes in lightning from frame to frame. The background pixel intensities can be similar to those of the face. I need an algorithm that would produce a pixel-perfect mask of the face, given that we know what the background looks beforehand.
(the face outline will not necessarily be as prominent as in this example - edge detection does not find it correctly all the time)
A naive approach I've tried is: run a median filter for noise removal, do a diff of image-background, threshold on low values to produce a binary mask, find biggest contour and fill it in.
However, this fails in cases where:
- The background is skin-coloured as image subtraction gives near-0 difference in the face region
- The background contains a skin-coloured object right beside the side of the face
- The image has a very low contrast. The lower the contrast, the more sensitive it becomes to threshold values, requiring fine tuning for every image.
How would you approach this problem?