text_line_slanttext_line_slantTextLineSlantTextLineSlanttext_line_slant (算子)

名称

text_line_slanttext_line_slantTextLineSlantTextLineSlanttext_line_slant — 确定文本行或段落的字符倾斜度。

签名

text_line_slant(Region, Image : : CharHeight, SlantFrom, SlantTo : SlantAngle)

Herror 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)

void TextLineSlant(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

static void HOperatorSet.TextLineSlant(HObject region, HObject image, HTuple charHeight, HTuple slantFrom, HTuple slantTo, out HTuple slantAngle)

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

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) -> float

描述

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

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

CharHeightCharHeightCharHeightCharHeightcharHeightchar_height specifies the approximately high of the existing text lines in the region RegionRegionRegionRegionregionregion. It's assumed, that the text lines are darker than the background.

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

With the calculated slant angle SlantAngleSlantAngleSlantAngleSlantAngleslantAngleslant_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.

执行信息

参数

RegionRegionRegionRegionregionregion (输入对象)  region(-array) objectHRegionHObjectHRegionHobject

Area of text lines.

ImageImageImageImageimageimage (输入对象)  singlechannelimage objectHImageHObjectHImageHobject (byte / uint2)

输入图像。

CharHeightCharHeightCharHeightCharHeightcharHeightchar_height (输入控制)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Height of the text lines.

默认值: 25

值范围: 1 ≤ CharHeight CharHeight CharHeight CharHeight charHeight char_height

SlantFromSlantFromSlantFromSlantFromslantFromslant_from (输入控制)  angle.rad HTuplefloatHTupleHtuple (real) (double) (double) (double)

Minimum slant of the characters

默认值: -0.523599

值范围: -0.785398 ≤ SlantFrom SlantFrom SlantFrom SlantFrom slantFrom slant_from ≤ 0.785398

限制: SlantFrom <= SlantTo

SlantToSlantToSlantToSlantToslantToslant_to (输入控制)  angle.rad HTuplefloatHTupleHtuple (real) (double) (double) (double)

Maximum slant of the characters

默认值: 0.523599

值范围: -0.785398 ≤ SlantTo SlantTo SlantTo SlantTo slantTo slant_to ≤ 0.785398

限制: SlantFrom <= SlantTo

SlantAngleSlantAngleSlantAngleSlantAngleslantAngleslant_angle (输出控制)  angle.rad(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Calculated slant of the characters in the region

示例(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')

结果

If the input parameters are set correctly, the operator text_line_slanttext_line_slantTextLineSlantTextLineSlantTextLineSlanttext_line_slant 返回值 2 ( H_MSG_TRUE )。否则将抛出异常。

可能的后继

hom_mat2d_slanthom_mat2d_slantHomMat2dSlantHomMat2dSlantHomMat2dSlanthom_mat2d_slant, affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImageaffine_trans_image, affine_trans_image_sizeaffine_trans_image_sizeAffineTransImageSizeAffineTransImageSizeAffineTransImageSizeaffine_trans_image_size

模块

基础