Issue 469 -- tweak to special case of all-black 8x8 region. Parse it as black. Other...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sat, 31 Jul 2010 15:07:16 +0000 (15:07 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sat, 31 Jul 2010 15:07:16 +0000 (15:07 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1500 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/common/HybridBinarizer.java

index e6a6952..e3eb0a2 100644 (file)
@@ -148,7 +148,13 @@ public final class HybridBinarizer extends GlobalHistogramBinarizer {
         // If the contrast is inadequate, use half the minimum, so that this block will be
         // treated as part of the white background, but won't drag down neighboring blocks
         // too much.
-        int average = (max - min > 24) ? (sum >> 6) : (min >> 1);
+        int average;
+        if (max - min > 24) {
+          average = sum >> 6;
+        } else {
+          // When min == max == 0, let average be 1 so all is black
+          average = max == 0 ? 1 : min >> 1;
+        }
         blackPoints[y][x] = average;
       }
     }