#498
OCR
Read printed text from an image. A pure-Java OCR engine you can read line by line.
Technique: Otsu threshold, line projection, connected components, template matching against rendered fonts
Read the code:
src/main/java/com/study/advlab/ocr/OcrEngine.javasrc/main/java/com/study/advlab/ocr/GlyphLibrary.javasrc/main/java/com/study/advlab/ocr/SampleImageService.java
The six steps in
OcrEngine1. Grey scale
Each pixel becomes one brightness 0-255.
Each pixel becomes one brightness 0-255.
2. Otsu threshold
Finds the brightness that best separates ink from paper.
Finds the brightness that best separates ink from paper.
3. Lines
Rows that contain ink are grouped into text lines.
Rows that contain ink are grouped into text lines.
4. Glyphs
Connected ink pixels form a letter; the dot of "i" is merged with its stem.
Connected ink pixels form a letter; the dot of "i" is merged with its stem.
5. Match
12 × 12 density grid + shape + baseline position, compared with letters drawn in 12 fonts.
12 × 12 density grid + shape + baseline position, compared with letters drawn in 12 fonts.
6. Words
Font-aware gaps become spaces; "O" in a number becomes "0".
Font-aware gaps become spaces; "O" in a number becomes "0".