Skip to content

text_line_orientationTextLineOrientationTextLineOrientationtext_line_orientationtext_line_orientationπŸ”—

Short descriptionπŸ”—

text_line_orientationTextLineOrientationTextLineOrientationtext_line_orientationtext_line_orientation β€” Determines the orientation of a text line or paragraph.

SignatureπŸ”—

text_line_orientation( region Region, image Image, integer CharHeight, angle.rad OrientationFrom, angle.rad OrientationTo, out angle.rad OrientationAngle )void TextLineOrientation( const HObject& Region, const HObject& Image, const HTuple& CharHeight, const HTuple& OrientationFrom, const HTuple& OrientationTo, HTuple* OrientationAngle )static void HOperatorSet.TextLineOrientation( HObject region, HObject image, HTuple charHeight, HTuple orientationFrom, HTuple orientationTo, out HTuple orientationAngle )def text_line_orientation( region: HObject, image: HObject, char_height: int, orientation_from: float, orientation_to: float ) -> Sequence[float]

def text_line_orientation_s( region: HObject, image: HObject, char_height: int, orientation_from: float, orientation_to: float ) -> floatHerror 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 )

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

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

DescriptionπŸ”—

text_line_orientationTextLineOrientation 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 OrientationFromorientationFromorientation_from and OrientationToorientationToorientation_to should be in the interval from -pi/4 to pi/4.

The parameter Regionregionregion specifies the area of the image in which the text lines are located. The Regionregionregion 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_orientationTextLineOrientation 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.

CharHeightcharHeightchar_height specifies the approximately height of the existing text lines in the region Regionregionregion. It’s assumed, that the text lines are darker than the background.

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

With the calculated angle OrientationAngleorientationAngleorientation_angle and operators like affine_trans_imageAffineTransImage, the region Regionregionregion of the image Imageimageimage can be rotated such, that the text lines lie horizontally in the image. This may simplify the character segmentation for OCR applications.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

ParametersπŸ”—

Regionregionregion (input_object) region(-array) β†’ objectHObjectHRegionHObjectHobject

Area of text lines.

Imageimageimage (input_object) singlechannelimage β†’ object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject (byte / uint2)

Input image.

CharHeightcharHeightchar_height (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Height of the text lines.

Default: 2525
Value range: 1 ≀ CharHeight
Restriction: CharHeight >= 1

OrientationFromorientationFromorientation_from (input_control) angle.rad β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Minimum rotation of the text lines.

Default: -0.523599-0.523599
Value range: -3.141593 ≀ OrientationFrom ≀ 3.141593
Restriction: OrientationFrom <= OrientationTo

OrientationToorientationToorientation_to (input_control) angle.rad β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum rotation of the text lines.

Default: 0.5235990.523599
Value range: -3.141593 ≀ OrientationTo ≀ 3.141593
Restriction: OrientationFrom <= OrientationTo && OrientationTo < OrientationFrom + pi

OrientationAngleorientationAngleorientation_angle (output_control) angle.rad(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (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_orientationTextLineOrientation returns the value 2 (H_MSG_TRUE). Otherwise an exception will be raised.

Combinations with other operatorsπŸ”—

Combinations

Possible successors

rotate_imageRotateImage, affine_trans_imageAffineTransImage, affine_trans_image_sizeAffineTransImageSize

ModuleπŸ”—

Foundation