mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
Add sharpening filter to this implementation too
git-svn-id: https://zxing.googlecode.com/svn/trunk@415 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
284c1776d5
commit
3140b4abdb
|
@ -62,9 +62,30 @@ public final class LCDUIImageMonochromeBitmapSource implements MonochromeBitmapS
|
|||
} else {
|
||||
row.clear();
|
||||
}
|
||||
for (int i = 0, offset = y * width + startX; i < getWidth; i++, offset++) {
|
||||
if (computeRGBLuminance(rgbPixels[offset]) < blackPoint) {
|
||||
row.set(i);
|
||||
|
||||
// If the current decoder calculated the blackPoint based on one row, assume we're trying to
|
||||
// decode a 1D barcode, and apply some sharpening.
|
||||
// TODO: We may want to add a fifth parameter to request the amount of shapening to be done.
|
||||
if (lastMethod.equals(BlackPointEstimationMethod.ROW_SAMPLING)) {
|
||||
int offset = y * width + startX;
|
||||
int left = computeRGBLuminance(rgbPixels[offset]);
|
||||
offset++;
|
||||
int center = computeRGBLuminance(rgbPixels[offset]);
|
||||
for (int i = 1; i < getWidth - 1; i++, offset++) {
|
||||
int right = computeRGBLuminance(rgbPixels[offset + 1]);
|
||||
// Simple -1 4 -1 box filter with a weight of 2
|
||||
int luminance = ((center << 2) - left - right) >> 1;
|
||||
if (luminance < blackPoint) {
|
||||
row.set(i);
|
||||
}
|
||||
left = center;
|
||||
center = right;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0, offset = y * width + startX; i < getWidth; i++, offset++) {
|
||||
if (computeRGBLuminance(rgbPixels[offset]) < blackPoint) {
|
||||
row.set(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return row;
|
||||
|
|
Loading…
Reference in a new issue