Skew angle checker for scanned documents.
Namespace:
AForge.ImagingAssembly: AForge.Imaging (in AForge.Imaging.dll) Version: 2.1.4.0 (2.1.4.0)
Syntax
| C# |
|---|
public class DocumentSkewChecker |
Remarks
The class implements document's skew checking algorithm, which is based on Hough line transformation. The algorithm is based on searching for text base lines - black line of text bottoms' followed by white line below.
The range of angles to detect is controlled by MaxSkewToDetect property.
The filter accepts 8 bpp grayscale images for processing.
Sample usage:
// create instance of skew checker DocumentSkewChecker skewChecker = new DocumentSkewChecker( ); // get documents skew angle double angle = skewChecker.GetSkewAngle( documentImage ); // create rotation filter RotateBilinear rotationFilter = new RotateBilinear( -angle ); rotationFilter.FillColor = Color.White; // rotate image applying the filter Bitmap rotatedImage = rotationFilter.Apply( documentImage );
Initial image:
Deskewed image: