Dilation
Contents
[
Hide
]
Some images, such as store receipts, have very thin characters that may be damaged by automatic contrast corrections or binarization.
Aspose.OCR for Python via .NET provides a special processing 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 automatically converts the image to black and white.
Dilation
To increase the thickness of characters in an image, run the image through dilate
processing filter.
# Instantiate Aspose.OCR API
api = AsposeOcr()
# Initialize image processing
filters = PreprocessingFilter()
filters.add(PreprocessingFilter.dilate())
# Add image to the recognition batch and apply processing filter
input = OcrInput(InputType.SINGLE_IMAGE, filters)
input.add("source.png")
# Save processed image to the "result" folder
ImageProcessing.save(input, "result")
# Recognize the image
result = api.recognize(input)
# Print recognition result
print(result[0].recognition_text)
Usage scenarios
Dilation is recommended for the following images:
- Receipts.
- Printouts with very thin font.