fix(classify): replace peak-counting bimodality with Otsu eta (MK-14) #32
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/classify-otsu-bimodality-MK-14"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements MK-14. Replaces the peak-counting bimodality detector with Otsu eta, the textbook between-class variance ratio. Validated against the user's local fixture set (21 letter-size mono scans + 5 thermal receipts).
Summary
bimodality_scorereturnsmax_t (between-class variance at threshold t) / (total variance), computed in one pass over the 64-bin luma histogram with O(1) per-threshold class moments via prefix sums. No new deps.[0, 1]regardless of how spread the dark population is: hard-binary inputs (white paper + black ink, however anti-aliased) score 0.84-0.94, photos and gradients < 0.30. Old detector returned 0.000 for every real scan because the dark ink population spread across many bins and no single bin cleared the 1%-of-total gate.bimodality_binary0.85 -> 0.82 (anchored below the real-scan eta cluster).soft_scale_bimodality0.05 -> 0.06.edge_density_text_min0.10 -> 0.06 (admits light-print thermal receipts).min_score0.50 -> 0.35 (Otsu eta produces naturally lower multiplicative class scores).tests/fixtures/to.gitignore. Real validation imagery stays local; the directory layouttests/fixtures/classify/<class>/is established convention for ad-hoc validation runs.Validation
tests/fixtures/classify/binary-scan/tests/fixtures/classify/receipt/No test code changes; only thresholds in
classify.tomland the detector body inclassify.rs.Test plan
cargo test(synthetic suite, including the existing binary-scan and receipt cases).cargo run --release -- image classify <path>against each file in the local fixture set (results above).cargo clippy --all-targets -- -D warnings.cargo fmt --check.