AutoDeskew(Int32,Single,GdPictureColor,Single,Boolean) Method
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.
'Declaration
Public Overloads Function AutoDeskew( _
ByVal As Integer, _
ByVal As Single, _
ByVal As GdPictureColor, _
ByVal As Single, _
ByVal As Boolean _
) As GdPictureStatus
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.
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);
}