mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 03:37:34 -08:00
Improved black point estimation -- favor a point not white so close the white peak
git-svn-id: https://zxing.googlecode.com/svn/trunk@135 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
80b3dd3632
commit
b112a890fb
|
@ -77,11 +77,13 @@ public final class BlackPointEstimator {
|
|||
|
||||
// Find a valley between them that is low and closer to the white peak
|
||||
int bestValley = secondPeak - 1;
|
||||
int bestValleyScore = Integer.MAX_VALUE;
|
||||
int bestValleyScore = -1;
|
||||
for (int i = secondPeak - 1; i > firstPeak; i--) {
|
||||
int distance = secondPeak - i + 3;
|
||||
int score = distance * histogram[i];
|
||||
if (score < bestValleyScore) {
|
||||
int fromFirst = i - firstPeak;
|
||||
// Favor a "valley" that is not too close to either peak -- especially not the black peak --
|
||||
// and that has a low value of course
|
||||
int score = fromFirst * fromFirst * (secondPeak - i) * (256 - histogram[i]);
|
||||
if (score > bestValleyScore) {
|
||||
bestValley = i;
|
||||
bestValleyScore = score;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ public final class QRCodeReaderTestCase extends TestCase {
|
|||
"http://staticrooster.com");
|
||||
doTestURI("http://www.ihaveanidea.org/blogs/uploads/i/interactive/270.png",
|
||||
"Morden");
|
||||
doTestURI("http://www.google.co.jp/mobile/images/qrcode_mobile.gif",
|
||||
"Google \u30e2\u30d0\u30a4\u30eb\r\nhttp://google.jp");
|
||||
}
|
||||
|
||||
private static void doTestURI(final String uriString, final String expected)
|
||||
|
|
Loading…
Reference in a new issue