Commit 5361665
committed
feat: SIMD OCR preprocessing — binarization, adaptive threshold, deskew
ndarray/hpc/ocr_simd.rs: SIMD-accelerated image preprocessing for OCR:
- Otsu binarization: U8x64 histogram + optimal threshold
- Bit-packed BinaryImage: 64 pixels per u64 word
- Adaptive threshold: integral image + local mean (handles uneven lighting)
- Skew estimation: horizontal projection profile variance
- Foreground density: popcount for blank page detection
- Full preprocess_page() pipeline: binarize → skew → density check
For tesseract integration: preprocess with SIMD, then pipe binary image
to tesseract LSTM (which only does character recognition, the fast part).
For our own OCR: binary image → connected components → Base17 fingerprint
per character glyph → codebook lookup = O(1) character recognition.
10 tests: Otsu bimodal, binarize all-white/black/checkerboard,
density, blank page, text page, skew detection, adaptive vs Otsu.
Data-flow: &[u8] slices (SIMD), owned BinaryImage (write-back), no &mut self.
https://claude.ai/code/session_01ChLvBfpJS8dQhHxRD4pYNp1 parent e9905bf commit 5361665
2 files changed
Lines changed: 451 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| |||
0 commit comments