Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Pre-processing Images for OCR

(Document/Medical) Scanned documents are not always straight. They can be skewed by the scanner feeder or get inserted in the wrong direction (upside down). For the best possible results such images need correction before being processed by the OCR engine. LEADTOOLS provides a number of pre-processing command classes that can be used to correct the orientation of images. These include the DeskewCommand, RotateCommand, DeskewExtendedCommand, and DeskewCheckCommand classes.

Pre-processing bitional (1-Bit) images

For more information about preprocessing bitonal images refer to Cleaning Up 1-Bit Images.

Pre-processing color images

Sometimes documents are scanned in color. Color images can be adjusted or enhanced using various LEADTOOLS commands. For more information, refer to Leadtools.ImageProcessing.Color.

A more practical solution is to convert the image to a bitonal (1-bit) image before processing in order to achieve better results. However, converting color images to a 1-bit image can cause loss of some important features due to the lack of colors in the 1-bit image. Convert color images to bitonal images by using either the ColorResolutionCommand, IntensityDetectCommand or the DynamicBinaryCommand class.

Auto Binarize

The most sophisticated way to convert color images to bitonal images is by using the AutoBinarizeCommand. The AutoBinarizeCommand uses several pre-processing and threshold operations in order to maintain the key features of a colored image. The AutoBinarizeCommand can be adjusted to the specific input device used, such as a scanner or camera. It is perfect for making unclear document images more readable.

The following example demonstrates how the AutoBinarizeCommand can be used to detect text with excellent results:

Before

After

The AutoBinarizeCommand class works automatically, but also allows customization of how the algorithm works. Options include whether to perform internal processing on the image. You can also choose which threshold method to use.