Contrast correction

Low contrast and blurring are the most typical distortions when text is photographed with a smartphone camera, especially in low light conditions. They make it difficult for the OCR algorithms to operate successfully, significantly reducing the recognition accuracy.

Aspose.OCR can automatically increase the contrast of images before proceeding to recognition.

Automatic contrast adjustments

To automatically increase the image contrast before recognition, run the image through ContrastCorrection preprocessing filter.

AsposeOCR api = new AsposeOCR();
// Apply automatic contrast correction
PreprocessingFilter filters = new PreprocessingFilter();
// Prepare batch
OcrInput images = new OcrInput(InputType.SingleImage, filters);
// Save processed images to the folder
ImageProcessing.Save(images, "C:\\images");
Low-contrast image High-contrast image

Image regions preprocessing

You can automatically adjust the contrast of certain areas of the image. For example, increase the contrast of a photo in an article while leaving the rest of the content unchanged.

To apply a filter to an area, specify its top left corner along with width and height as Rectangle object. If the region is omitted, the filter is applied to the entire image.

Rectangle rectangle = new Rectangle(5, 161, 340, 340);
PreprocessingFilter filters = new PreprocessingFilter();

Usage scenarios

Automatic contrast adjustment is recommended for the following images:

  • Photos, especially those taken in low light conditions without optical or digital image stabilization.
  • Old papers.
  • Text on a background.