fix: drop glare holes before the margin and never auto-pick specks
Filtering holes after the margin let -2 mm grow 1 mm specks past the 3 mm cutoff, and could drop real holes shrunk by a positive margin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
abef0f982b
commit
41baa25a01
7 files changed
+59
-25
No files matched your search
@@ -9,6 +9,7 @@ import type { Point, RasterImage, Shape } from './types';
|
||||
export type Tool = 'none' | 'scale' | 'seed' | 'draw';
|
||||
|
||||
const DEFAULT_THRESHOLD = 128;
|
||||
const MIN_HOLE_MM = 3;
|
||||
|
||||
export class AppState {
|
||||
// Raw: the cv module and pixel buffers must never be wrapped in reactive proxies.
|
||||
@@ -43,7 +44,10 @@ export class AppState {
|
||||
if (this.mode === 'manual') {
|
||||
return shapeFromPolygons(cv, image.width, image.height, { outer: this.manualOuter, holes: this.manualHoles }, this.marginPx);
|
||||
}
|
||||
return detect(cv, image, { threshold: this.threshold, invert: this.invert, seed: this.seed, marginPx: this.marginPx });
|
||||
return detect(cv, image, {
|
||||
threshold: this.threshold, invert: this.invert, seed: this.seed, marginPx: this.marginPx,
|
||||
minHolePx: this.pxPerMm ? MIN_HOLE_MM * this.pxPerMm : 0,
|
||||
});
|
||||
});
|
||||
|
||||
exportShape = $derived(this.shapePx && this.pxPerMm ? prepareForExport(this.shapePx, this.pxPerMm) : null);
|
||||
|
||||
Reference in new issue
Block a user