Skip to content

Commit 5361665

Browse files
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_01ChLvBfpJS8dQhHxRD4pYNp
1 parent e9905bf commit 5361665

2 files changed

Lines changed: 451 additions & 0 deletions

File tree

src/hpc/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ pub mod jitson;
224224
#[cfg(feature = "jit-native")]
225225
#[allow(missing_docs)]
226226
pub mod jitson_cranelift;
227+
pub mod ocr_simd;
227228

228229
#[cfg(test)]
229230
mod e2e_tests {

0 commit comments

Comments
 (0)