ClassesClasses | | Operators

text_line_orientationtext_line_orientationTextLineOrientationTextLineOrientation (Operator)

Name

text_line_orientationtext_line_orientationTextLineOrientationTextLineOrientation — Determines the orientation of a text line or paragraph.

Signature

text_line_orientation(Region, Image : : CharHeight, OrientationFrom, OrientationTo : OrientationAngle)

Herror text_line_orientation(const Hobject Region, const Hobject Image, const Hlong CharHeight, double OrientationFrom, double OrientationTo, double* OrientationAngle)

Herror T_text_line_orientation(const Hobject Region, const Hobject Image, const Htuple CharHeight, const Htuple OrientationFrom, const Htuple OrientationTo, Htuple* OrientationAngle)

void TextLineOrientation(const HObject& Region, const HObject& Image, const HTuple& CharHeight, const HTuple& OrientationFrom, const HTuple& OrientationTo, HTuple* OrientationAngle)

HTuple HRegion::TextLineOrientation(const HImage& Image, Hlong CharHeight, double OrientationFrom, double OrientationTo) const

static void HOperatorSet.TextLineOrientation(HObject region, HObject image, HTuple charHeight, HTuple orientationFrom, HTuple orientationTo, out HTuple orientationAngle)

HTuple HRegion.TextLineOrientation(HImage image, int charHeight, double orientationFrom, double orientationTo)

Description

text_line_orientationtext_line_orientationTextLineOrientationTextLineOrientationTextLineOrientation determines the orientation of a single text line or a paragraph in relation to the horizontal image axis. If the orientation of a single text line should be determined, the range for the OrientationFromOrientationFromOrientationFromOrientationFromorientationFrom and OrientationToOrientationToOrientationToOrientationToorientationTo should be in the interval from -pi/4 to pi/4.

The parameter RegionRegionRegionRegionregion specifies the area of the image in which the text lines are located. The RegionRegionRegionRegionregion is only used to reduce the working area. To determine the slant, the gray values inside that area are used. The text lines are segmented by the operator text_line_orientationtext_line_orientationTextLineOrientationTextLineOrientationTextLineOrientation itself. If more than one region is passed, the numerical values of the orientation angle are stored in a tuple, the position of a value in the tuple corresponding to the position of the region in the input tuple.

CharHeightCharHeightCharHeightCharHeightcharHeight specifies the approximately height of the existing text lines in the region RegionRegionRegionRegionregion. It's assumed, that the text lines are darker than the background.

The search area can be restricted by the parameters OrientationFromOrientationFromOrientationFromOrientationFromorientationFrom and OrientationToOrientationToOrientationToOrientationToorientationTo, whereby also the runtime of the operator is influenced.

With the calculated angle OrientationAngleOrientationAngleOrientationAngleOrientationAngleorientationAngle and operators like affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImage, the region RegionRegionRegionRegionregion of the image ImageImageImageImageimage can be rotated such, that the text lines lie horizontally in the image. This may simplify the character segmentation for OCR applications.

Execution Information

Parameters

RegionRegionRegionRegionregion (input_object)  region(-array) objectHRegionHRegionHobject

Area of text lines.

ImageImageImageImageimage (input_object)  singlechannelimage objectHImageHImageHobject (byte / uint2)

Input image.

CharHeightCharHeightCharHeightCharHeightcharHeight (input_control)  integer HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Height of the text lines.

Default value: 25

Typical range of values: 1 ≤ CharHeight CharHeight CharHeight CharHeight charHeight

Restriction: CharHeight >= 1

OrientationFromOrientationFromOrientationFromOrientationFromorientationFrom (input_control)  angle.rad HTupleHTupleHtuple (real) (double) (double) (double)

Minimum rotation of the text lines.

Default value: -0.523599

Typical range of values: -3.141593 ≤ OrientationFrom OrientationFrom OrientationFrom OrientationFrom orientationFrom ≤ 3.141593

Restriction: -2 * pi <= OrientationFrom <= 2 * pi

OrientationToOrientationToOrientationToOrientationToorientationTo (input_control)  angle.rad HTupleHTupleHtuple (real) (double) (double) (double)

Maximum rotation of the text lines.

Default value: 0.523599

Typical range of values: -3.141593 ≤ OrientationTo OrientationTo OrientationTo OrientationTo orientationTo ≤ 3.141593

Restriction: OrientationFrom <= OrientationTo && OrientationTo < OrientationFrom + pi

OrientationAngleOrientationAngleOrientationAngleOrientationAngleorientationAngle (output_control)  angle.rad(-array) HTupleHTupleHtuple (real) (double) (double) (double)

Calculated rotation angle of the text lines.

Example (HDevelop)

read_image(Image,'letters')
text_line_orientation(Image,Image,50,rad(-80),rad(80),OrientationAngle)
rotate_image(Image,ImageRotate,-OrientationAngle/rad(180)*180,'constant')

Result

If the input parameters are set correctly, the operator text_line_orientationtext_line_orientationTextLineOrientationTextLineOrientationTextLineOrientation returns the value 2 (H_MSG_TRUE). Otherwise an exception will be raised.

Possible Successors

rotate_imagerotate_imageRotateImageRotateImageRotateImage, affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImage, affine_trans_image_sizeaffine_trans_image_sizeAffineTransImageSizeAffineTransImageSizeAffineTransImageSize

Module

Foundation


ClassesClasses | | Operators