Improve IK-style artifact scanner pipeline
This commit is contained in:
@@ -40,6 +40,18 @@ describe("ocrPreprocess", () => {
|
||||
expect(otsuThreshold(new Array<number>(256).fill(0))).toBe(127);
|
||||
});
|
||||
|
||||
it("can increase contrast before histogramming small numeric crops", () => {
|
||||
const bitmap = bitmapFrom([
|
||||
[118, 118, 118],
|
||||
[138, 138, 138],
|
||||
], 2, 1);
|
||||
const normal = computeLuminanceHistogram(bitmap);
|
||||
const contrasted = computeLuminanceHistogram(bitmap, { contrast: 80 });
|
||||
const normalValues = normal.flatMap((count, value) => Array.from({ length: count }, () => value));
|
||||
const contrastedValues = contrasted.flatMap((count, value) => Array.from({ length: count }, () => value));
|
||||
expect(Math.max(...contrastedValues) - Math.min(...contrastedValues)).toBeGreaterThan(Math.max(...normalValues) - Math.min(...normalValues));
|
||||
});
|
||||
|
||||
it("inverts bright foreground to black-on-white by default", () => {
|
||||
// Bright text pixel + dark background pixel.
|
||||
const bitmap = bitmapFrom([
|
||||
|
||||
Reference in New Issue
Block a user