vp9-skinmap. Some adjustments for model=1.
authorMarco <marpan@google.com>
Wed, 3 Feb 2016 22:21:59 +0000 (14:21 -0800)
committerMarco <marpan@google.com>
Wed, 3 Feb 2016 22:47:15 +0000 (14:47 -0800)
-use larger threshold on y (as in vp8).
-add distance threshold for each cluster
-use larger skin distance threshold for first cluster
-add some early exist checks.

Keep default setting to model=0.

Change-Id: I1044b99ade4bb1f215a860a019a4d84cee2f7715

vp9/encoder/vp9_skin_detection.c

index 54cc082..8e117eb 100644 (file)
 static const int skin_mean[5][2] = {
     {7463, 9614}, {6400, 10240}, {7040, 10240}, {8320, 9280}, {6800, 9614}};
 static const int skin_inv_cov[4] = {4107, 1663, 1663, 2157};  // q16
-static const int skin_threshold[2] = {1570636, 800000};       // q18
+static const int skin_threshold[6] = {1570636, 1400000, 800000, 800000, 800000,
+    800000};  // q18
 
 // Thresholds on luminance.
-static const int y_low = 20;
+static const int y_low = 40;
 static const int y_high = 220;
 
 // Evaluates the Mahalanobis distance measure for the input CbCr values.
@@ -55,10 +56,24 @@ int vp9_skin_pixel(const uint8_t y, const uint8_t cb, const uint8_t cr) {
       return (evaluate_skin_color_difference(cb, cr, 0) < skin_threshold[0]);
     } else {
       int i = 0;
+      // Exit on grey.
+      if (cb == 128 && cr == 128)
+        return 0;
+      // Exit on very strong cb.
+      if (cb > 150 && cr < 110)
+        return 0;
+      // Exit on (another) low luminance threshold if either color is high.
+      if (y < 50 && (cb > 140 || cr > 140))
+        return 0;
       for (; i < 5; i++) {
-        if (evaluate_skin_color_difference(cb, cr, i) < skin_threshold[1]) {
+        if (evaluate_skin_color_difference(cb, cr, i) < skin_threshold[i + 1]) {
           return 1;
         }
+        // Exit if difference is much large than the threshold.
+        if (evaluate_skin_color_difference(cb, cr, i) >
+            (skin_threshold[i + 1] << 3)) {
+          return 0;
+        }
       }
       return 0;
     }