segment_charactersSegmentCharactersSegmentCharacterssegment_charactersT_segment_characters
説明
segment_charactersSegmentCharactersSegmentCharacterssegment_charactersT_segment_characters — 与えられた画像領域の文字を分割する。
書式
segment_characters( region Region, image Image, out image ImageForeground, out region RegionForeground, string Method, string EliminateLines, string DotPrint, string StrokeWidth, integer CharWidth, integer CharHeight, integer ThresholdOffset, integer Contrast, out integer 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 )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 )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]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 )
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)
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 )
説明
このオペレーターは与えられた Imageimageimage の Regionregionregion で
文字を分割するために使用します。Regionregionregion は作業領域を絞り込
むためだけに使用されます。
分割された文字は RegionForegroundregionForegroundregion_foreground に返されます。
文字を検出するには、2 つの方法があります。
すべての分割処理において、文字列は背景よりも暗いと仮定します。そう
でない場合、invert_imageInvertImage を用いて画像を変換してください。
パラメーター Methodmethodmethod は文字列分割のためのアルゴリズムを指
定します。取り得る値は次のとおりです。
-
'local_contrast_best'"local_contrast_best"
この方法は、局所的に背景とは異なるテキストを抽出しま
す。従って、不均一な照明を使う画像に適しています。テキ
スト境界線の強調により、テキストの輪郭をより正確に決定
できます。背景が高度にテクスチャされている場合、特に便
利です。パラメーター Contrastcontrastcontrast は、最小コントラ
スト(シンボルと背景の間の最小グレイ値)を定義します。
-
'local_auto_shape'"local_auto_shape"
最小コントラストは、極小領域の数が少なくなるように自動
的に推定されます。この方法は、ノイズの多い画像に特に適
しています。パラメーター ThresholdOffsetthresholdOffsetthreshold_offset を使
用して、しきい値を調整することができます。
\(g(x,y)\) は、Imageimageimage 内の位置 \((x,y)\) のグレイ値
とします。しきい値の制限は、次の式で決まります。
\(g(x,y) \le \textrm{UsedThreshold} + \textrm{ThresholdOffset}\).
文字の抽出が、文字列に対して水平もしくは垂直の線によって妨げられている場
合、EliminateLineseliminateLineseliminate_lines を選択し、その値を 'true'"true" に設定してく
ださい。この除去は CharWidthcharWidthchar_width の最大値と
CharHeightcharHeightchar_height の最大値に影響を及ぼします。
詳細については、各パラメーターの記載を参照してください。
DotPrintdotPrintdot_print:
ドット印刷を読み取る場合は、'true'"true" に設定してください。そうでない
場合は、'false'"false" に設定してください。
StrokeWidthstrokeWidthstroke_width:
文字列のストローク幅を指定します。文字を指定する場合に使用されるマ
スクサイズを内部的に計算するために使用されます。このマスクサイズは
パラメーター DotPrintdotPrintdot_print、平均 CharWidthcharWidthchar_width と
CharHeightcharHeightchar_height を通じて操作されます。
CharWidthcharWidthchar_width:
これは、最大 3 つの値を tuple にすることができます。1 番目の値は文
字幅の平均です。2 番目の値は最小文字幅であり、3 番目は最大文字幅で
す。
最小値が設定されていない、もしくは -1 である場合、オペレーターが平
均 CharWidthcharWidthchar_width に応じて、これらの値を自動的に設定します。最
大値が設定されない場合も同様です。例については、次のとおりです。
[10] は文字幅の平均を 10 とし、最小値と最大値はオペレーター
によって計算されます。
[10,-1,20] は文字幅の平均を 10 とし、最小値はシステムによって計算
されます。また最大値を 20 に設定します。
[10,5,20] は文字幅の平均を 10 とし、最小値を 5、最大値を 20 に設定
します。
CharHeightcharHeightchar_height:
これは、最大 3 つの値を tuple に入力することができます。1 番目の値は文
字の平均の高さです。2 番目の値は文字の最小の高さであり、3 番目は文
字の最大の高さです。
最小値が設定されていない、もしくは -1 である場合、オペレーターが平
均 CharHeightcharHeightchar_height に応じて、これらの値を自動的に設定します。
最大値が設定されない場合も同様です。例については、次のとおりです。
[10] は文字の高さの平均を 10 とし、最小値と最大値については
オペレーターで計算されます。
[10,-1,20] は文字の高さの平均を 10 とし、最小値はシステムによって
計算され、最大値を 20 に設定します。
[10,5,20] は、文字の高さの平均を 10 とし、最小値を 5、最大値を 20
に設定します。
ThresholdOffsetthresholdOffsetthreshold_offset:
このパラメーターはしきい値を調整するために使用することができ、分割
方法として'local_auto_shape'"local_auto_shape" を選択した場合に使用されま
す。
Contrastcontrastcontrast:
文字列と背景間の最小コントラストを定義します。このパラメーターは、
分割方法として'local_contrast_best'"local_contrast_best" を選択した場合に使用
されます。
UsedThresholdusedThresholdused_threshold:
実行後、このパラメーターは文字を分割する際に使用したしきい値を返し
ます。
ImageForegroundimageForegroundimage_foreground は分割において内部的に使用された画像を返
します。
実行情報
実行情報
パラメーター
Regionregionregion (input_object) region(-array) → objectHObjectHRegionHObjectHobject
文字列が位置する画像内の領域
Imageimageimage (input_object) singlechannelimage → object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject (byte / uint2)
入力画像
ImageForegroundimageForegroundimage_foreground (output_object) image(-array) → object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject * (byte / uint2)
分割で使用する画像
RegionForegroundregionForegroundregion_foreground (output_object) singlechannelregion(-array) → objectHObjectHRegionHObjectHobject *
文字の領域
Methodmethodmethod (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)
文字を分割するための方法
初期値: 'local_auto_shape'"local_auto_shape"
値のリスト: 'local_auto_shape', 'local_contrast_best'"local_auto_shape", "local_contrast_best"
EliminateLineseliminateLineseliminate_lines (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)
水平もしくは垂直の線の除去フラグ
初期値: 'false'"false"
値のリスト: 'false', 'true'"false", "true"
DotPrintdotPrintdot_print (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)
ドット印刷文字を検出するフラグ
初期値: 'false'"false"
値のリスト: 'false', 'true'"false", "true"
StrokeWidthstrokeWidthstroke_width (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)
文字のストローク幅
初期値: 'medium'"medium"
値のリスト: 'bold', 'light', 'medium', 'ultra_light'"bold", "light", "medium", "ultra_light"
CharWidthcharWidthchar_width (input_control) integer-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)
文字の幅
初期値: 2525
値域: 1 ≤ CharWidth
CharHeightcharHeightchar_height (input_control) integer-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)
文字の高さ
初期値: 2525
値域: 1 ≤ CharHeight
ThresholdOffsetthresholdOffsetthreshold_offset (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)
分割を調整するための値
初期値: 00
Contrastcontrastcontrast (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)
文字列と背景間の最小グレイ値の差
初期値: 1010
UsedThresholdusedThresholdused_threshold (output_control) integer(-array) → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)
文字を分割するために使用されるしきい値
例
(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
結果
入力パラメーターが正しく設定されているならば、オペレーター
segment_charactersSegmentCharacters は、値 2 (H_MSG_TRUE) を返します。さもなければ、
例外処理が発生します。
他のオペレーターとの組み合わせ
組み合わせ
前処理の候補
text_line_orientationTextLineOrientation
後処理の候補
select_charactersSelectCharacters, connectionConnection
他の選択候補
thresholdThreshold
モジュール
Foundation