Skew angle checker for scanned documents.

Namespace:  AForge.Imaging
Assembly:  AForge.Imaging (in AForge.Imaging.dll) Version: 2.2.5.0 (2.2.5.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.

Note:The routine supposes that a white-background document is provided with black letters. The algorithm is not supposed for any type of objects, but for document images with text.

The range of angles to detect is controlled by MaxSkewToDetect property.

The filter accepts 8 bpp grayscale images for processing.

Sample usage:

CopyC#
// 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:

Inheritance Hierarchy

System..::.Object
  AForge.Imaging..::.DocumentSkewChecker

See Also