Optical Character Recognition (OCR) is the technology that converts images of text into machine-readable text. It's what lets you scan a document and get an editable file, or point your phone at a sign and instantly translate it. The process seems magical, but it's a pipeline of well-understood computer vision and machine learning steps.
Step 1: Image Acquisition
OCR starts with an image — from a scanner, camera, or screenshot. The quality of this image has the biggest impact on accuracy. Factors that matter:
- Resolution: 300 DPI is the minimum for printed text; 150 DPI for screen captures
- Lighting: Even, diffused lighting is best. Shadows and glare create artefacts
- Angle: Text should be as straight as possible. Skewed text needs correction
- Focus: Blurry images produce far more recognition errors
Step 2: Preprocessing
Before the OCR engine tries to read characters, it cleans up the image:
- Grayscale conversion: Colour information isn't needed for text recognition and removing it simplifies processing
- Binarisation: Converting the image to black and white (thresholding). Text becomes black, background becomes white. Adaptive thresholding handles uneven lighting
- Deskewing: Detecting and correcting the angle of the text. Even a 2-degree tilt significantly reduces accuracy
- Noise removal: Removing speckles, dots, and other artefacts that could be mistaken for characters
- Layout analysis: Identifying text regions, separating columns, and detecting reading order
Step 3: Text Detection and Segmentation
The engine identifies where text appears in the image and breaks it down:
- Text localisation: Finding regions that contain text (vs. images, borders, or blank space)
- Line segmentation: Splitting text blocks into individual lines
- Word segmentation: Splitting lines into words (for languages with spaces)
- Character segmentation: Splitting words into individual characters (the hardest part for connected scripts like Arabic or Devanagari)
Step 4: Character Recognition
This is the core of OCR — identifying what each character is. Modern OCR engines use deep learning:
- CNN-based models: Convolutional neural networks trained on millions of character images. They learn visual features like strokes, curves, and junctions that distinguish an 'a' from an 'o'
- Sequence models (CRNN/LSTM): Instead of segmenting into individual characters, these models read entire lines at once. They handle connected scripts and varied spacing better
- Transformer-based models: The newest approach, using attention mechanisms to focus on relevant parts of the image. These achieve the highest accuracy but require more compute
Step 5: Post-Processing
Raw OCR output always has errors. Post-processing cleans it up:
- Spell checking: Comparing recognised words against a dictionary and correcting likely misspellings
- Language modelling: Using context to fix errors. If the engine reads "the qvick brown fox," a language model knows "qvick" should be "quick"
- Confidence scoring: Each character or word gets a confidence score. Low-confidence regions can be flagged for human review
- Format preservation: Maintaining paragraph breaks, columns, tables, and font information where possible
Accuracy Factors
Modern OCR engines achieve 95-99% accuracy on clean printed text. Accuracy drops with:
- Handwritten text (70-90% even with the best engines)
- Low-resolution or blurry images
- Unusual fonts or decorative typography
- Mixed languages or scripts in the same document
- Complex layouts with tables, columns, and graphics
Browser-Based OCR
Tesseract.js, used by the OCR tool on this site, runs the full OCR pipeline in your browser using WebAssembly. It supports 100+ languages and achieves accuracy comparable to server-based engines for printed text. The key advantage: your images never leave your device. This is critical for sensitive documents like passports, bank statements, or medical records.
Use the OCR tool above to extract text from images, screenshots, or scanned documents. Upload an image, select the language, and get editable text. No data is uploaded to any server.