mirror of
https://github.com/visioncortex/vtracer.git
synced 2026-09-26 14:01:18 -07:00
Enrich binary thresholding: tunable fixed + Bradley–Roth adaptive
BinaryFrontend gains a Threshold enum: Fixed(u8) (now tunable, was
hardcoded to 128) and Adaptive { window, t } — Bradley–Roth adaptive
thresholding computed via visioncortex's SummedAreaTable, O(pixels)
regardless of window size, for images with uneven lighting. Both use a
shared (r+g+b)/3 intensity so they agree on "dark"; the grayscale
checker_bw golden is unaffected.
Exposed through Config and all bindings: CLI (--threshold, --adaptive,
--adaptive-window, --adaptive-t), Python (constructor kwargs + getters/
setters), and the Node package (binaryThreshold, adaptive, adaptiveWindow,
adaptiveT). Adds tests covering fixed tunability and adaptive recovering
locally-dark marks under a brightness gradient that a global cutoff can't.
This commit is contained in:
Vendored
+8
@@ -19,6 +19,14 @@ export interface Options {
|
||||
maxColors?: number;
|
||||
/** 0 = off, 1 = quantize+simplify, 2 = + shorthands/grouping. */
|
||||
optimize?: number;
|
||||
/** Binary mode (`colorMode: 'bw'`): fixed threshold 0..=255; foreground when intensity is below it. */
|
||||
binaryThreshold?: number;
|
||||
/** Binary mode: use Bradley–Roth adaptive thresholding (handles uneven lighting). */
|
||||
adaptive?: boolean;
|
||||
/** Adaptive window side length in px; 0 = auto (~1/8 of the shorter side). */
|
||||
adaptiveWindow?: number;
|
||||
/** Adaptive sensitivity: percent below the local mean (default 15). */
|
||||
adaptiveT?: number;
|
||||
}
|
||||
|
||||
/** Vectorize an encoded image (PNG/JPEG/GIF/BMP) buffer to an SVG string. */
|
||||
|
||||
Reference in New Issue
Block a user