Hello
I want to create system that identifies human emotions based on face images. I have my eyes, eyebrows, nose, mouth found. I have problem with face binarization. I want my system to be as much universal as possible. Face images are taken with mobile phone camera, because of that there is a different light on each image. What I know for sure is that, I need to get rid or weaken effect of shadows that appear on faces due to bad light.
What have I done:
I tried to implement Niblack Thresholding algorithm but to be honest it's not working well with faces. I came up with my own idea for now because any algorithm I tried fails me. The best results I get with this:
Core.normalize(cleanFaceMatGRAY, cleanFaceMatGRAY,0, 255, Core.NORM_MINMAX, CvType.CV_8U);
niblackThresholding(cleanFaceMatGRAY, -0.2);
private void niblackThresholding(Mat image, double parameter) {
Mat meanPowered = image.clone();
Core.multiply(image, image, meanPowered);
double mean = Core.mean(image).val[0];
double stdmean = Core.mean(meanPowered).val[0];
double tresholdValue = mean + parameter * stdmean;
// MatOfDouble mean = new MatOfDouble();
// MatOfDouble std = new MatOfDouble();
// Core.meanStdDev(image, mean, std);
// double tresholdValue = mean.toArray()[0] + parameter * std.toArray()[0];
int totalRows = image.rows();
int totalCols = image.cols();
for (int cols=0; cols < totalCols; cols++) {
for (int rows=0; rows < totalRows; rows++) {
if (image.get(rows, cols)[0] > tresholdValue) {
image.put(rows, cols, 255);
} else {
image.put(rows, cols, 0);
}
}
}
}
The results are really good, but still not enough for some images. I paste links cuz images are big and I don't want to take too much screen:
For example this one is tresholded really fine:
https://dl.dropboxusercontent.com/u/108321090/a1.png
https://dl.dropboxusercontent.com/u/108321090/a.png
But bad light produce shadows sometimes and this gives this effect:
https://dl.dropboxusercontent.com/u/108321090/b1.png
https://dl.dropboxusercontent.com/u/108321090/b.png
So... I tried to manipulate manually my threshold value for B picture but it won't ever give good result.
Please help me with this problem. I appreciate any comment, suggestion, reference material. I tried a lot of things and I lack ideas.