Skip to content

text_line_slantTextLineSlantTextLineSlanttext_line_slanttext_line_slantπŸ”—

Short descriptionπŸ”—

text_line_slantTextLineSlantTextLineSlanttext_line_slanttext_line_slant β€” Determines the slant of characters of a text line or paragraph.

SignatureπŸ”—

text_line_slant( region Region, image Image, integer CharHeight, angle.rad SlantFrom, angle.rad SlantTo, out angle.rad SlantAngle )void TextLineSlant( const HObject& Region, const HObject& Image, const HTuple& CharHeight, const HTuple& SlantFrom, const HTuple& SlantTo, HTuple* SlantAngle )static void HOperatorSet.TextLineSlant( HObject region, HObject image, HTuple charHeight, HTuple slantFrom, HTuple slantTo, out HTuple slantAngle )def text_line_slant( region: HObject, image: HObject, char_height: int, slant_from: float, slant_to: float ) -> Sequence[float]

def text_line_slant_s( region: HObject, image: HObject, char_height: int, slant_from: float, slant_to: float ) -> floatHerror text_line_slant( const Hobject Region, const Hobject Image, const Hlong CharHeight, double SlantFrom, double SlantTo, double* SlantAngle )

Herror T_text_line_slant( const Hobject Region, const Hobject Image, const Htuple CharHeight, const Htuple SlantFrom, const Htuple SlantTo, Htuple* SlantAngle )

HTuple HRegion::TextLineSlant( const HImage& Image, Hlong CharHeight, double SlantFrom, double SlantTo ) const

HTuple HRegion.TextLineSlant( HImage image, int charHeight, double slantFrom, double slantTo )

DescriptionπŸ”—

text_line_slantTextLineSlant determines the slant of a single text line or a paragraph.

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_slantTextLineSlant 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 high 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 SlantFromslantFromslant_from and SlantToslantToslant_to, whereby also the runtime of the operator is influenced.

With the calculated slant angle SlantAngleslantAngleslant_angle and operators for affine transformations, the slant can be removed from the characters. This may simplify the character separation for OCR applications. To work correctly all characters of a region should have nearly the same slant.

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

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

Minimum slant of the characters

Default: -0.523599-0.523599
Value range: -0.785398 ≀ SlantFrom ≀ 0.785398
Restriction: SlantFrom <= SlantTo

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

Maximum slant of the characters

Default: 0.5235990.523599
Value range: -0.785398 ≀ SlantTo ≀ 0.785398
Restriction: SlantFrom <= SlantTo

SlantAngleslantAngleslant_angle (output_control) angle.rad(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Calculated slant of the characters in the region

ExampleπŸ”—

(HDevelop)


hom_mat2d_identity(HomMat2DIdentity)
read_image(Image,'dot_print_slanted')
* correct slant
text_line_slant(Image,Image,50,rad(-45),rad(45),SlantAngle)
hom_mat2d_slant(HomMat2DIdentity,-SlantAngle,'x',0,0,HomMat2DSlant)
affine_trans_image(Image,Image,HomMat2DSlant,'constant','true')

ResultπŸ”—

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

Combinations with other operatorsπŸ”—

Combinations

Possible successors

hom_mat2d_slantHomMat2dSlant, affine_trans_imageAffineTransImage, affine_trans_image_sizeAffineTransImageSize

ModuleπŸ”—

Foundation