GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureImaging Class / AutoDeskew Method / AutoDeskew(Int32,Single,GdPictureColor,Single,Boolean) Method
GdPicture image identifier.
Maximum angle of research. IE: set 10 to perform a skew research about ±10 degrees. A value lower tha 15 is suggested.
Color to use to fill background. A suitable color value can be obtained by using the ARGB() method.
Determines the smallest angle of skew to detect. 0.25 is suggested. Higher value results in faster detection and vice-versa.
Determines if the engine must be optimistic in the skew detection. For example, set true when you know the image has a skew and false otherwise. Default value is false.
Example





In This Topic
AutoDeskew(Int32,Single,GdPictureColor,Single,Boolean) Method
In This Topic
Tries to deskew a GdPicture image to about ± specified degrees. This method enables to specify the background color to use as a Color Object. It also enables you to put a cut off value where slight skewing of image is allowed. Deskewing an image can help a lot to do OCR, OMR, barcode detection or just improve the readability of an image.
Syntax
'Declaration
 
Public Overloads Function AutoDeskew( _
   ByVal ImageID As Integer, _
   ByVal MaxAngleOfResearch As Single, _
   ByVal BackColor As GdPictureColor, _
   ByVal AngleStep As Single, _
   ByVal Optimistic As Boolean _
) As GdPictureStatus
public function AutoDeskew( 
    ImageID: Integer;
    MaxAngleOfResearch: Single;
    BackColor: GdPictureColor;
    AngleStep: Single;
    Optimistic: Boolean
): GdPictureStatus; 
public function AutoDeskew( 
   ImageID : int,
   MaxAngleOfResearch : float,
   BackColor : GdPictureColor,
   AngleStep : float,
   Optimistic : boolean
) : GdPictureStatus;
public: GdPictureStatus AutoDeskew( 
   int ImageID,
   float MaxAngleOfResearch,
   GdPictureColor BackColor,
   float AngleStep,
   bool Optimistic
) 
public:
GdPictureStatus AutoDeskew( 
   int ImageID,
   float MaxAngleOfResearch,
   GdPictureColor BackColor,
   float AngleStep,
   bool Optimistic
) 

Parameters

ImageID
GdPicture image identifier.
MaxAngleOfResearch
Maximum angle of research. IE: set 10 to perform a skew research about ±10 degrees. A value lower tha 15 is suggested.
BackColor
Color to use to fill background. A suitable color value can be obtained by using the ARGB() method.
AngleStep
Determines the smallest angle of skew to detect. 0.25 is suggested. Higher value results in faster detection and vice-versa.
Optimistic
Determines if the engine must be optimistic in the skew detection. For example, set true when you know the image has a skew and false otherwise. Default value is false.

Return Value

A member of the GdPictureStatus enumeration.
Remarks

When minor skewing of images does not affect the subsequent processes, sometimes it is perferred not to deskew the image, could be for quality or timesaving. This method offers the input of a cutt off value, where slight skewing is allowed.

Be aware: If the skew angle is larger than the cutt off value, the returned value will be rounded to the nearest multiple of (AngleStep)

This method requires the Image Documents component to run.

Example
Deskewing a tiff image by analyzing angles in the range [-12; +12] degrees.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("skewed.tif");
 
    gdpictureImaging.AutoDeskew(imageID, 15, gdpictureImaging.ARGB(255, 255, 255, 255), 12, true);
 
    // Let's encode the new tiff with the same mode used by the input image.
    TiffCompression tiffCompression = gdpictureImaging.GetTiffCompression(imageID);
 
    gdpictureImaging.SaveAsTIFF(imageID, "deskewed.tif", tiffCompression);
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also