Ask Your Question
1

Face threshold in various light

asked 2013-12-19 16:21:13 -0600

Fisher gravatar image

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.

edit retag flag offensive close merge delete

Comments

@Fisher, Hello Sir, I am working on same concept. Would you able to convert that c++ code to java. Plz provide any help in this direction. It will be really helpful to us. Thanks.

Devis gravatar imageDevis ( 2014-08-29 05:00:29 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
5

answered 2013-12-19 21:37:03 -0600

pyro gravatar image

updated 2013-12-19 21:39:06 -0600

An excellent but simple illumination normalization technique is presented in this paper, and applied to face detection: http://lear.inrialpes.fr/pubs/2007/TT07/Tan-amfg07a.pdf

An existing C++ implementation of the above paper's algorithm: https://github.com/bytefish/opencv/blob/master/misc/tan_triggs.cpp

Note that this is only for illumination normalization, and you may have to experiment a bit with the normalized image to obtain a binary image as per your requirement.

edit flag offensive delete link more

Comments

Can you please give me some advise that how can I use it with XCODE?

mau.tasol gravatar imagemau.tasol ( 2018-05-29 07:09:49 -0600 )edit

Question Tools

Stats

Asked: 2013-12-19 16:21:13 -0600

Seen: 1,834 times

Last updated: Dec 19 '13