eraser — training-data param sweep v2

1. MASK_THRESH global sweep — one threshold can't win

Cell = binary LABEL (black=print kept). Text reads clean ~0.15; thin figure lines need ~0.03. That conflict motivates section 2.

stampsourcethr 0.03thr 0.06thr 0.1thr 0.15
figure
61-10__p001_
source
thr 0.03
3.6%
thr 0.06
2.8%
thr 0.1
2.5%
thr 0.15
2.2%
figure
61-11__p001_
source
thr 0.03
15.7%
thr 0.06
12.7%
thr 0.1
11.1%
thr 0.15
9.8%
figure
61-11__p001_
source
thr 0.03
11.7%
thr 0.06
9.5%
thr 0.1
8.3%
thr 0.15
7.4%
text
09__M__p001_
source
thr 0.03
9.4%
thr 0.06
7.9%
thr 0.1
7.2%
thr 0.15
6.5%
text
12__p001__00
source
thr 0.03
16.5%
thr 0.06
13.3%
thr 0.1
11.8%
thr 0.15
10.4%

2. MASK METHOD — the fix for text-vs-diagram

per-type: text→0.15, figure→0.03 (we already classify stamps; dead simple, your exact sweet spots). adaptive: cv2 local Gaussian threshold — catches thin lines by LOCAL contrast regardless of absolute darkness (your "laplacian" idea). hysteresis: keep faint pixels (ink>0.035) only if connected to a solid core (ink>0.15) — captures faint line extensions, rejects isolated noise. Pick the column that keeps thin diagram lines AND clean text.

typesourceglobal 0.06per-typeadaptivehysteresistophat
figure
source
global 0.06
per-type 0.03
adaptive(local)
hysteresis
tophat(ridge)
figure
source
global 0.06
per-type 0.03
adaptive(local)
hysteresis
tophat(ridge)
figure
source
global 0.06
per-type 0.03
adaptive(local)
hysteresis
tophat(ridge)
text
source
global 0.06
per-type 0.15
adaptive(local)
hysteresis
tophat(ridge)
text
source
global 0.06
per-type 0.15
adaptive(local)
hysteresis
tophat(ridge)

3. FADE — whole-tile vs print-only (don't faint the background!)

Each tile's left side is artificially darkened to fake a shaded/dark background. whole-tile (old) washes that background out toward paper as fade rises — bad, it erases the dark-BG the shade/sliver aug teaches. print-only (new) fades ONLY the print, leaving the background dark. Default now FADE_MAX=0.7 (you OK'd 0.7; 0.9 too much).

tilefade 0.0fade 0.3fade 0.5fade 0.7fade 0.9
tile 0
whole-tile (old: fades BG)
fade 0.0 (off)
fade 0.3
fade 0.5
fade 0.7
fade 0.9
tile 0
print-only (new: BG kept)
fade 0.0 (off)
fade 0.3
fade 0.5
fade 0.7
fade 0.9
tile 1
whole-tile (old: fades BG)
fade 0.0 (off)
fade 0.3
fade 0.5
fade 0.7
fade 0.9
tile 1
print-only (new: BG kept)
fade 0.0 (off)
fade 0.3
fade 0.5
fade 0.7
fade 0.9
tile 2
whole-tile (old: fades BG)
fade 0.0 (off)
fade 0.3
fade 0.5
fade 0.7
fade 0.9
tile 2
print-only (new: BG kept)
fade 0.0 (off)
fade 0.3
fade 0.5
fade 0.7
fade 0.9

4. SHADE — floor sweep (you OK'd 0.18)

tilenonefloor 0.6floor 0.45floor 0.3floor 0.18
tile 0
none
floor 0.6
floor 0.45
floor 0.3
floor 0.18
tile 1
none
floor 0.6
floor 0.45
floor 0.3
floor 0.18
tile 2
none
floor 0.6
floor 0.45
floor 0.3
floor 0.18