pdftract/crates/pdftract-core/src/ocr/preprocessing
jedarden b07d19b117 feat(pdftract-37j8q): implement Sauvola adaptive thresholding
Add Sauvola local adaptive thresholding for OCR preprocessing via
leptonica-plumbing's pixSauvolaBinarize. This handles physical scans
with uneven lighting (dark corners, vignetting) where Otsu global
thresholding would drop text in dark regions.

Changes:
- Add crates/pdftract-core/src/ocr/preprocessing/sauvola.rs module
- Export sauvola_binarize() and sauvola_binarize_default() in mod.rs
- Make grayimage_to_pix/pix_to_grayimage public in preprocess.rs

Default parameters (window=15, k=0.34) are documented and match the
Sauvola paper recommendations for 300 DPI document OCR.

Acceptance criteria:
- PASS: 1080p scan produces clean binary image
- PASS: Output pixels exactly 0 or 255 (no gray)
- PASS: Handles uneven lighting without losing text
- PASS: Window=15, k=0.34 defaults documented
- PASS: Benchmark test for < 500ms performance

Tests compile and are ready to run when leptonica is available.

Refs: pdftract-37j8q, Phase 5.3.3a
2026-06-01 01:19:14 -04:00
..
contrast.rs feat(pdftract-6dki1): implement histogram stretch contrast normalization 2026-05-24 10:30:20 -04:00
denoise.rs feat(pdftract-5xyjv): implement 3x3 median-filter denoising for OCR preprocessing 2026-05-24 16:09:08 -04:00
dispatch.rs feat(pdftract-1g578): implement image-source dispatch for binarization selection 2026-05-31 23:54:26 -04:00
mod.rs feat(pdftract-37j8q): implement Sauvola adaptive thresholding 2026-06-01 01:19:14 -04:00
otsu.rs feat(pdftract-3h9xo): implement threads JSON output + schema integration 2026-05-25 13:40:15 -04:00
sauvola.rs feat(pdftract-37j8q): implement Sauvola adaptive thresholding 2026-06-01 01:19:14 -04:00