Dilation

Some images, such as store receipts, have very thin characters that may be damaged by automatic contrast corrections or binarization.

Aspose.OCR provides a special preprocessing filter called dilation that can increase the thickness of characters in an image by adding pixels to the edges of high-contrast objects, such as letters.

Dilation

To increase the thickness of characters in an image, run the image through BinarizeAndDilate preprocessing filter.

AsposeOCR api = new AsposeOCR();
// Make text thicker
PreprocessingFilter filters = new PreprocessingFilter();
filters.add(PreprocessingFilter.BinarizeAndDilate());
// Prepare batch
OcrInput images = new OcrInput(InputType.SingleImage, filters);
images.add("image.png");
// Save processed images to the folder
ImageProcessing.Save(images, "C:\\images");
Ultra-light font Strong font

Image regions preprocessing

BinarizeAndDilate filter can be applied to specific regions of an image. For example, you can make the article body text thicker while leaving the headers 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();
filters.add(PreprocessingFilter.BinarizeAndDilate(rectangle));

Usage scenarios

Dilation is recommended for the following images:

  • Receipts.
  • Printouts with very thin font.