segment_characters T_segment_characters SegmentCharacters SegmentCharacters segment_characters (算子)
名称
segment_characters T_segment_characters SegmentCharacters SegmentCharacters segment_characters — 分割图像给定区域中的字符。
签名
Herror T_segment_characters (const Hobject Region , const Hobject Image , Hobject* ImageForeground , Hobject* RegionForeground , const Htuple Method , const Htuple EliminateLines , const Htuple DotPrint , const Htuple StrokeWidth , const Htuple CharWidth , const Htuple CharHeight , const Htuple ThresholdOffset , const Htuple Contrast , Htuple* UsedThreshold )
void SegmentCharacters (const HObject& Region , const HObject& Image , HObject* ImageForeground , HObject* RegionForeground , const HTuple& Method , const HTuple& EliminateLines , const HTuple& DotPrint , const HTuple& StrokeWidth , const HTuple& CharWidth , const HTuple& CharHeight , const HTuple& ThresholdOffset , const HTuple& Contrast , HTuple* UsedThreshold )
HImage HRegion ::SegmentCharacters (const HImage& Image , HRegion* RegionForeground , const HString& Method , const HString& EliminateLines , const HString& DotPrint , const HString& StrokeWidth , const HTuple& CharWidth , const HTuple& CharHeight , Hlong ThresholdOffset , Hlong Contrast , HTuple* UsedThreshold ) const
HImage HRegion ::SegmentCharacters (const HImage& Image , HRegion* RegionForeground , const HString& Method , const HString& EliminateLines , const HString& DotPrint , const HString& StrokeWidth , const HTuple& CharWidth , const HTuple& CharHeight , Hlong ThresholdOffset , Hlong Contrast , Hlong* UsedThreshold ) const
HImage HRegion ::SegmentCharacters (const HImage& Image , HRegion* RegionForeground , const char* Method , const char* EliminateLines , const char* DotPrint , const char* StrokeWidth , const HTuple& CharWidth , const HTuple& CharHeight , Hlong ThresholdOffset , Hlong Contrast , Hlong* UsedThreshold ) const
HImage HRegion ::SegmentCharacters (const HImage& Image , HRegion* RegionForeground , const wchar_t* Method , const wchar_t* EliminateLines , const wchar_t* DotPrint , const wchar_t* StrokeWidth , const HTuple& CharWidth , const HTuple& CharHeight , Hlong ThresholdOffset , Hlong Contrast , Hlong* UsedThreshold ) const
(
Windows only)
static void HOperatorSet .SegmentCharacters (HObject region , HObject image , out HObject imageForeground , out HObject regionForeground , HTuple method , HTuple eliminateLines , HTuple dotPrint , HTuple strokeWidth , HTuple charWidth , HTuple charHeight , HTuple thresholdOffset , HTuple contrast , out HTuple usedThreshold )
HImage HRegion .SegmentCharacters (HImage image , out HRegion regionForeground , string method , string eliminateLines , string dotPrint , string strokeWidth , HTuple charWidth , HTuple charHeight , int thresholdOffset , int contrast , out HTuple usedThreshold )
HImage HRegion .SegmentCharacters (HImage image , out HRegion regionForeground , string method , string eliminateLines , string dotPrint , string strokeWidth , HTuple charWidth , HTuple charHeight , int thresholdOffset , int contrast , out int usedThreshold )
def segment_characters (region : HObject, image : HObject, method : str, eliminate_lines : str, dot_print : str, stroke_width : str, char_width : Sequence[int], char_height : Sequence[int], threshold_offset : int, contrast : int) -> Tuple[HObject, HObject, Sequence[int]]
def segment_characters_s (region : HObject, image : HObject, method : str, eliminate_lines : str, dot_print : str, stroke_width : str, char_width : Sequence[int], char_height : Sequence[int], threshold_offset : int, contrast : int) -> Tuple[HObject, HObject, int]
描述
This operator is used to segment characters in a given Region Region Region Region region region of an
Image Image Image Image image image . The Region Region Region Region region region is only used to reduce the working area.
The segmented characters are returned in RegionForeground RegionForeground RegionForeground RegionForeground regionForeground region_foreground 。
Two different methods to detect the characters are supplied.
All segmentation methods assume that the text is darker than the
background. If this is not the case, please invert the image with
invert_image invert_image InvertImage InvertImage InvertImage invert_image 。
The parameter Method Method Method Method method method determines the algorithm for text
segmentation. The possible values are
'local_contrast_best'
This method extracts text that differ locally from the
background. Therefore, it is suited for images with
inhomogeneous illumination. The enhancement of the text
borders, leads to a more accurate determination of the
outline of the text. Which is especially useful if the
background is highly textured. The parameter
Contrast Contrast Contrast Contrast contrast contrast defines the minimum contrast,i.e.,
the minimum gray value difference between symbols and
background.
'local_auto_shape'
The minimum contrast is estimated automatically such
that the number of very small regions is reduced. This
method is especially suitable for noisy images. The
parameter ThresholdOffset ThresholdOffset ThresholdOffset ThresholdOffset thresholdOffset threshold_offset can be used to adjust
the threshold.
Let g(x,y) be the gray value at position (x,y) in the
input Image Image Image Image image image . The threshold condition is
determined by:
。
Select EliminateLines EliminateLines EliminateLines EliminateLines eliminateLines eliminate_lines if the extraction of characters is disturbed
by lines that are horizontal or vertical with respect to the lines of
text and set its value to 'true' "true" "true" "true" "true" "true" . The elimination is influenced by the
maximum of CharWidth CharWidth CharWidth CharWidth charWidth char_width and the maximum of CharHeight CharHeight CharHeight CharHeight charHeight char_height .
For further information see the description of these parameters.
DotPrint DotPrint DotPrint DotPrint dotPrint dot_print :
Should be set to 'true' "true" "true" "true" "true" "true" if dot prints should be read, else to
'false' "false" "false" "false" "false" "false" .
StrokeWidth StrokeWidth StrokeWidth StrokeWidth strokeWidth stroke_width :
Specifies the stroke width of the text. It is used to calculate internally
used mask sizes to determine the characters. This mask sizes are also
influenced through the parameters DotPrint DotPrint DotPrint DotPrint dotPrint dot_print , the average
CharWidth CharWidth CharWidth CharWidth charWidth char_width , and the average CharHeight CharHeight CharHeight CharHeight charHeight char_height 。
CharWidth CharWidth CharWidth CharWidth charWidth char_width :
This can be a tuple with up to three values. The first value is the
average width of a character. The second is the minimum width of a
character and the third is the maximum width of a character.
If the minimum is not set or equal -1, the operator automatically sets
these value depending on the average CharWidth CharWidth CharWidth CharWidth charWidth char_width . The same is
the case if the maximum is not set. Some examples:
[10] sets the average character width to 10, the minimum and
maximum are calculated by the operator.
[10,-1,20] sets the average character width to 10, the minimum value is
calculated by the system, and the maximum is set to 20.
[10,5,20] sets the average character width to 10, the minimum to 5,
and the maximum to 20.
CharHeight CharHeight CharHeight CharHeight charHeight char_height :
This can be a tuple with up to three values. The first value is the
average height of a character. The second is the minimum height of a
character and the third is the maximum height of a character.
If the minimum is not set or equal -1, the operator automatically sets
these value depending on the average CharHeight CharHeight CharHeight CharHeight charHeight char_height . The same is
the case if the maximum is not set. Some examples:
[10] sets the average character height to 10, the minimum and
maximum are calculated by the operator.
[10,-1,20] sets the average character height to 10, the minimum value is
calculated by the system, and the maximum is set to 20.
[10,5,20] this sets the average character height to 10, the minimum to 5,
and the maximum to 20.
ThresholdOffset ThresholdOffset ThresholdOffset ThresholdOffset thresholdOffset threshold_offset :
This parameter can be used to adjust the threshold, which is used when the
segmentation method 'local_auto_shape' "local_auto_shape" "local_auto_shape" "local_auto_shape" "local_auto_shape" "local_auto_shape" is chosen.
Contrast Contrast Contrast Contrast contrast contrast :
Defines the minimum contrast between the text and the background. This
parameter is used if the segmentation method 'local_contrast_best' "local_contrast_best" "local_contrast_best" "local_contrast_best" "local_contrast_best" "local_contrast_best"
is selected.
UsedThreshold UsedThreshold UsedThreshold UsedThreshold usedThreshold used_threshold :
After the execution, this parameter returns the threshold used to
segment the characters.
ImageForeground ImageForeground ImageForeground ImageForeground imageForeground image_foreground returns the image that was internally used for the
segmentation.
执行信息
多线程类型:可重入(与非独占算子并行运行)。
多线程作用域:全局(可从任何线程调用)。
在元组级别上自动并行化。
参数
Region Region Region Region region region (输入对象) region(-array) → object HRegion HObject HRegion Hobject
Area in the image where the text lines are located.
Image Image Image Image image image (输入对象) singlechannelimage → object HImage HObject HImage Hobject (byte / uint2)
输入图像。
ImageForeground ImageForeground ImageForeground ImageForeground imageForeground image_foreground (输出对象) image(-array) → object HImage HObject HImage Hobject * (byte / uint2)
Image used for the segmentation.
RegionForeground RegionForeground RegionForeground RegionForeground regionForeground region_foreground (输出对象) singlechannelregion(-array) → object HRegion HObject HRegion Hobject *
Region of characters.
Method Method Method Method method method (输入控制) string → HTuple str HTuple Htuple (string) (string ) (HString ) (char* )
Method to segment the characters.
默认值:
'local_auto_shape'
"local_auto_shape"
"local_auto_shape"
"local_auto_shape"
"local_auto_shape"
"local_auto_shape"
值列表:
'local_auto_shape' "local_auto_shape" "local_auto_shape" "local_auto_shape" "local_auto_shape" "local_auto_shape" , 'local_contrast_best' "local_contrast_best" "local_contrast_best" "local_contrast_best" "local_contrast_best" "local_contrast_best"
EliminateLines EliminateLines EliminateLines EliminateLines eliminateLines eliminate_lines (输入控制) string → HTuple str HTuple Htuple (string) (string ) (HString ) (char* )
Eliminate horizontal and vertical lines?
默认值:
'false'
"false"
"false"
"false"
"false"
"false"
值列表:
'false' "false" "false" "false" "false" "false" , 'true' "true" "true" "true" "true" "true"
DotPrint DotPrint DotPrint DotPrint dotPrint dot_print (输入控制) string → HTuple str HTuple Htuple (string) (string ) (HString ) (char* )
Should dot print characters be detected?
默认值:
'false'
"false"
"false"
"false"
"false"
"false"
值列表:
'false' "false" "false" "false" "false" "false" , 'true' "true" "true" "true" "true" "true"
StrokeWidth StrokeWidth StrokeWidth StrokeWidth strokeWidth stroke_width (输入控制) string → HTuple str HTuple Htuple (string) (string ) (HString ) (char* )
Stroke width of a character.
默认值:
'medium'
"medium"
"medium"
"medium"
"medium"
"medium"
值列表:
'bold' "bold" "bold" "bold" "bold" "bold" , 'light' "light" "light" "light" "light" "light" , 'medium' "medium" "medium" "medium" "medium" "medium" , 'ultra_light' "ultra_light" "ultra_light" "ultra_light" "ultra_light" "ultra_light"
CharWidth CharWidth CharWidth CharWidth charWidth char_width (输入控制) integer-array → HTuple Sequence[int] HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Width of a character.
默认值:
25
值范围:
1
≤
CharWidth
CharWidth
CharWidth
CharWidth
charWidth
char_width
CharHeight CharHeight CharHeight CharHeight charHeight char_height (输入控制) integer-array → HTuple Sequence[int] HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Height of a character.
默认值:
25
值范围:
1
≤
CharHeight
CharHeight
CharHeight
CharHeight
charHeight
char_height
ThresholdOffset ThresholdOffset ThresholdOffset ThresholdOffset thresholdOffset threshold_offset (输入控制) integer → HTuple int HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Value to adjust the segmentation.
默认值:
0
Contrast Contrast Contrast Contrast contrast contrast (输入控制) integer → HTuple int HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Minimum gray value difference between text and
background.
默认值:
10
UsedThreshold UsedThreshold UsedThreshold UsedThreshold usedThreshold used_threshold (输出控制) integer(-array) → HTuple Sequence[int] HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Threshold used to segment the characters.
示例(HDevelop)
for Index := 1 to 5 by 1
read_image (Image, 'dot_print_rotated/dot_print_rotated_'+Index$'02d')
text_line_orientation (Image, Image, 50, rad(-30), rad(30), \
OrientationAngle)
rotate_image (Image, ImageRotate, deg(-OrientationAngle), 'constant')
segment_characters (ImageRotate, ImageRotate, ImageForeground, \
RegionForeground, 'local_auto_shape', 'false', \
'false', 'medium', 25, 25, 0, 10, UsedThreshold)
endfor
结果
If the input parameters are set correctly, the operator
segment_characters segment_characters SegmentCharacters SegmentCharacters SegmentCharacters segment_characters 返回值 2 ( H_MSG_TRUE )。否则将抛出异常。
可能的前趋
text_line_orientation text_line_orientation TextLineOrientation TextLineOrientation TextLineOrientation text_line_orientation
可能的后继
select_characters select_characters SelectCharacters SelectCharacters SelectCharacters select_characters ,
connection connection Connection Connection Connection connection
替代
threshold threshold Threshold Threshold Threshold threshold
模块
基础