When a page is fed to a flatbed scanner (mechanically or manually) or photographed with a smartphone, it is nearly impossible to achieve perfect alignment. As a result, a slight skew (tilt) inevitably occurs in scanned images or photographs.
Skew angle detection and image straightening is critical to the OCR process as it directly affects the reliability and efficiency of segmentation and text extraction. Aspose.OCR offers automated processing algorithms to correct image tilt (deskew) before proceeding to recognition.
Detecting skew angle
> Skew angle: 5.9°
Automatic skew correction
Manual skew correction
In rare cases, automatic skew correction may incorrectly determine the angle of the image. This can happen to poor quality photos with significant perspective distortions.
To deal with such situations, you can rotate the image by the specified degree using
Rotate preprocessing filter or manually define the skew angle for such images using the
SkewAngle property of recognition settings. The rotation angle is passed in degrees:
0: rotate counterclockwise;
360: rotate clockwise.
Image regions preprocessing
Automatic skew correction and manual rotation filters can be applied to specific regions of an image. For example, you can straighten an illustration on a page while leaving the rest of the content unchanged.
The original size of an image does not change when its area is rotated. Parts of the rotated area that do not match the original size of the area are cropped.
It is recommended to apply the automatic deskew and manual rotation filters only to square areas.
To apply a filter to an area, specify its top left corner along with width and height as
Aspose.Drawing.Rectangle object. If the region is omitted, the filter is applied to the entire image.
Aspose.Drawing.Rectangle rectangle = new Aspose.Drawing.Rectangle(5, 161, 340, 340); Aspose.OCR.Models.PreprocessingFilters.PreprocessingFilter filters = new Aspose.OCR.Models.PreprocessingFilters.PreprocessingFilter(); filters.Add(Aspose.OCR.Models.PreprocessingFilters.PreprocessingFilter.Rotate(90, rectangle));
- Automatic skew correction is recommended in almost all cases, except for perfectly straight scans.
- Manual rotation is recommended for:
- photos of low quality;
- images with a significant angle of inclination.