GdPicture image identifier.
Maximum angle of research. IE: set 10 to perform a skew research about ±10 degrees. A value lower than 15 is suggested. Value used by other overloads is 15.
Color to use to fill background. A suitable color value can be obtained by using the ARGBI() method.
Determines the smallest angle of skew to detect. 0.25 is suggested. Higher value results in faster detection and vice-versa. Value used by other overloads is 0.25.
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. Value used by other overloads is False.
Example





In This Topic
GdPicture14 Namespace / GdPictureImaging Class / AutoDeskew Method / AutoDeskew(Int32,Single,Int32,Single,Boolean) Method

AutoDeskew(Int32,Single,Int32,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 Integer Value. 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 Integer, _
   ByVal AngleStep As Single, _
   ByVal Optimistic As Boolean _
) As GdPictureStatus
public GdPictureStatus AutoDeskew( 
   int ImageID,
   float MaxAngleOfResearch,
   int BackColor,
   float AngleStep,
   bool Optimistic
)
public function AutoDeskew( 
    ImageID: Integer;
    MaxAngleOfResearch: Single;
    BackColor: Integer;
    AngleStep: Single;
    Optimistic: Boolean
): GdPictureStatus; 
public function AutoDeskew( 
   ImageID : int,
   MaxAngleOfResearch : float,
   BackColor : int,
   AngleStep : float,
   Optimistic : boolean
) : GdPictureStatus;
public: GdPictureStatus AutoDeskew( 
   int ImageID,
   float MaxAngleOfResearch,
   int BackColor,
   float AngleStep,
   bool Optimistic
) 
public:
GdPictureStatus AutoDeskew( 
   int ImageID,
   float MaxAngleOfResearch,
   int 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 than 15 is suggested. Value used by other overloads is 15.
BackColor
Color to use to fill background. A suitable color value can be obtained by using the ARGBI() method.
AngleStep
Determines the smallest angle of skew to detect. 0.25 is suggested. Higher value results in faster detection and vice-versa. Value used by other overloads is 0.25.
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. Value used by other overloads 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.ARGBI(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