Click or drag to resize
Accord.NET (logo)

DocumentSkewChecker Class

Skew angle checker for scanned documents.
Inheritance Hierarchy

Namespace:  Accord.Imaging
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.6.0
public class DocumentSkewChecker
Request Example View Source

The DocumentSkewChecker type exposes the following members.

Public methodDocumentSkewChecker
Initializes a new instance of the DocumentSkewChecker class.
Public propertyLocalPeakRadius
Radius for searching local peak value, [1, 10].
Public propertyMaxBeta Obsolete.
Maximum angle to detect skew in degrees.
Public propertyMaxSkewToDetect
Maximum skew angle to detect, [0, 45] degrees.
Public propertyMinBeta Obsolete.
Minimum angle to detect skew in degrees.
Public propertyStepsPerDegree
Steps per degree, [1, 10].
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetSkewAngle(Bitmap)
Get skew angle of the provided document image.
Public methodGetSkewAngle(BitmapData)
Get skew angle of the provided document image.
Public methodGetSkewAngle(UnmanagedImage)
Get skew angle of the provided document image.
Public methodGetSkewAngle(Bitmap, Rectangle)
Get skew angle of the provided document image.
Public methodGetSkewAngle(BitmapData, Rectangle)
Get skew angle of the provided document image.
Public methodGetSkewAngle(UnmanagedImage, Rectangle)
Get skew angle of the provided document image.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Extension Methods
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodToT
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)

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 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:

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

See Also