Skew correction
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.
Automatic skew correction
To automatically straighten skewed image before recognition, set correct_skew
recognition setting to true
. Since most of the images have some degree of tilt, this setting is turned on by default.
var settings = Module.WasmAsposeOCRRecognitionSettings();
// Even if you omit this line, the automatic skew correction will be enabled
settings.correct_skew = true;
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 or when the image is rotated by more than 15 degrees in either direction.
To deal with such situations, you can manually define the skew angle for such images using the skew
property in recognition setting. The rotation angle is passed in degrees as a floating point number:
-360
to0
: rotate counterclockwise;0
to360
: rotate clockwise.
var settings = Module.WasmAsposeOCRRecognitionSettings();
// Fix rotated pages
settings.skew = -90;
Usage scenarios
- 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.