ImageEn, unit imageenproc




function SkewDetection(ResampleWidth: Integer; AngleRange: Integer; Precision: Double; EdgeDetect: Boolean): Double;


Estimates the orientation angle (in degrees) of lines of text. Apply this method only to images that contain printed text.
If an area is selected, SkewDetection will work only on the selection.

Parameter Description
ResampleWidth The width of the analysis image (set to 0 to analyze the image at its full size). SkewDetection can be very slow on large images, so it is recommended that images are resampled to a smaller size by setting ResampleWidth (e.g. specifying 800 will reduce the image to a width of 800 for analysis)
AngleRange The maximum working range in degrees. For example, if you specify 30, SkewDetection will scan the image within the range of -15 to 15 degrees. A low value will enhance performance and accuracy. Permitted values are 1 to 180
Precision The level of precision of the angle detection. Permitted range is 0.0 to 0.9 with only one decimal digit. Typical value is 0.1
EdgeDetect Whether to apply an edge detection algorithm before calculating the orientation

Note: If the image PixelFormat is not ie24RGB or ie1g, it will be converted


Demo  Demos\ImageAnalysis\Orientator\Orientator.dpr
Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr


// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );


// Check for skew within the range -15 to 15 with 0.1 degrees of precision and automatically orient (for printed text)
d := ImageEnView1.Proc.SkewDetection( ImageEnView1.IEBitmap.Width div 4, 30, 0.1, false );
ImageEnView1.Proc.RotateAndCrop( d, ierBicubic );


See Also