Skip to content

select_charactersSelectCharactersSelectCharactersselect_charactersT_select_characters🔗

説明🔗

select_charactersSelectCharactersSelectCharactersselect_charactersT_select_characters — 与えられた領域から文字を選択する。

書式🔗

select_characters( region Region, out region RegionCharacters, string DotPrint, string StrokeWidth, integer CharWidth, integer CharHeight, string Punctuation, string DiacriticMarks, string PartitionMethod, string PartitionLines, string FragmentDistance, string ConnectFragments, integer ClutterSizeMax, string StopAfter )void SelectCharacters( const HObject& Region, HObject* RegionCharacters, const HTuple& DotPrint, const HTuple& StrokeWidth, const HTuple& CharWidth, const HTuple& CharHeight, const HTuple& Punctuation, const HTuple& DiacriticMarks, const HTuple& PartitionMethod, const HTuple& PartitionLines, const HTuple& FragmentDistance, const HTuple& ConnectFragments, const HTuple& ClutterSizeMax, const HTuple& StopAfter )static void HOperatorSet.SelectCharacters( HObject region, out HObject regionCharacters, HTuple dotPrint, HTuple strokeWidth, HTuple charWidth, HTuple charHeight, HTuple punctuation, HTuple diacriticMarks, HTuple partitionMethod, HTuple partitionLines, HTuple fragmentDistance, HTuple connectFragments, HTuple clutterSizeMax, HTuple stopAfter )def select_characters( region: HObject, dot_print: str, stroke_width: str, char_width: Sequence[int], char_height: Sequence[int], punctuation: str, diacritic_marks: str, partition_method: str, partition_lines: str, fragment_distance: str, connect_fragments: str, clutter_size_max: int, stop_after: str ) -> HObject

Herror T_select_characters( const Hobject Region, Hobject* RegionCharacters, const Htuple DotPrint, const Htuple StrokeWidth, const Htuple CharWidth, const Htuple CharHeight, const Htuple Punctuation, const Htuple DiacriticMarks, const Htuple PartitionMethod, const Htuple PartitionLines, const Htuple FragmentDistance, const Htuple ConnectFragments, const Htuple ClutterSizeMax, const Htuple StopAfter )

HRegion HRegion::SelectCharacters( const HString& DotPrint, const HString& StrokeWidth, const HTuple& CharWidth, const HTuple& CharHeight, const HString& Punctuation, const HString& DiacriticMarks, const HString& PartitionMethod, const HString& PartitionLines, const HString& FragmentDistance, const HString& ConnectFragments, Hlong ClutterSizeMax, const HString& StopAfter ) const

HRegion HRegion::SelectCharacters( const char* DotPrint, const char* StrokeWidth, const HTuple& CharWidth, const HTuple& CharHeight, const char* Punctuation, const char* DiacriticMarks, const char* PartitionMethod, const char* PartitionLines, const char* FragmentDistance, const char* ConnectFragments, Hlong ClutterSizeMax, const char* StopAfter ) const

HRegion HRegion::SelectCharacters( const wchar_t* DotPrint, const wchar_t* StrokeWidth, const HTuple& CharWidth, const HTuple& CharHeight, const wchar_t* Punctuation, const wchar_t* DiacriticMarks, const wchar_t* PartitionMethod, const wchar_t* PartitionLines, const wchar_t* FragmentDistance, const wchar_t* ConnectFragments, Hlong ClutterSizeMax, const wchar_t* StopAfter ) const (Windows only)

HRegion HRegion.SelectCharacters( string dotPrint, string strokeWidth, HTuple charWidth, HTuple charHeight, string punctuation, string diacriticMarks, string partitionMethod, string partitionLines, string fragmentDistance, string connectFragments, int clutterSizeMax, string stopAfter )

説明🔗

select_charactersSelectCharacters は与えられた Regionregionregion から文字と 思われる領域を選択し、RegionCharactersregionCharactersregion_characters に返します。 StrokeWidthstrokeWidthstroke_width、DotPrintdotPrintdot_print 文字サイズなどのような特徴 を使用することによって選択されます。与えられた Regionregionregion を 結合しなければならず、そのほかのすべての Regionregionregion が別々に 処理されます。つまり、select_charactersSelectCharacters を呼び出す前に connectionConnection を呼び出さないでください。なぜなら、断片やドッ トが文字と連結されていないからです。 文字の領域が複数ある場合、この領域を結合することなく処理することも 当然可能です。 select_charactersSelectCharacters における Regionregionregion は、通常、 segment_charactersSegmentCharacters から得られますが、その他の分割オペレー ターも使用できます。

選択過程は、4 つの部分に分割できます。 すべてのステップは、パラメーター StrokeWidthstrokeWidthstroke_width、 CharHeightcharHeightchar_height、および CharWidthcharWidthchar_width に影響されます。 ドットのような小さな対象物を認識できない場合、最小 CharWidthcharWidthchar_width と最小 CharHeightcharHeightchar_height を適用します。 しかし、ある特定の過程における結果に、特に影響を与えるパラメーター もあります。 さらに詳しい説明を以下に記載します。 パラメーター StopAfterstopAfterstop_after を用いて、指定の処理を中断すること ができます。

まずはじめに、'step1_select_candidates'"step1_select_candidates"、 CharWidthcharWidthchar_width、および CharHeightcharHeightchar_height が候補を選択するた めに使用されます。また、この処理の結果は、ClutterSizeMaxclutterSizeMaxclutter_size_max によって影響を受けます。

次に、'step2_partition_characters'"step2_partition_characters"、パラメーター PartitionMethodpartitionMethodpartition_method とパラメーター PartitionLinespartitionLinespartition_lines が 結果に影響します。

ステップ 3 'step3_connect_fragments'"step3_connect_fragments" は、パラメーター ConnectFragmentsconnectFragmentsconnect_fragments と DotPrintdotPrintdot_print を使用します。ドッ ト印刷された文字を検出しなければならず、また文字に連結されていない ドットがある場合、この問題を処理するには、2 つの方法があります。 つまり、FragmentDistancefragmentDistancefragment_distance を増やすか、 StrokeWidthstrokeWidthstroke_width を減らします。

最後のステップ 'step4_select_characters'"step4_select_characters" では、この結果は パラメーター DiacriticMarksdiacriticMarksdiacritic_marks と Punctuationpunctuationpunctuation によ って影響を受けます。

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 に設定します。

Punctuationpunctuationpunctuation: オペレーターが句読点 (例えば .,:’`”) を検出しなければならない場 合、このパラメーターを 'true'"true" に設定してください。さもな ければ、無視されます。

DiacriticMarksdiacriticMarksdiacritic_marks: ご使用のアプリケーションにおいて、文字列が識別記号 (例えば â,é,ö) を含む場合、このパラメーターを 'true'"true" に設定してください。'false'"false" に設 定して場合には、識別記号は無視されます。

PartitionMethodpartitionMethodpartition_method: 隣接文字がお互いに近接して印刷される場合、部分的に結合される場合が あります。このパラメーターを使用し、このような文字を分割する方法を 指定することができます。可能性のある値は 'none'"none" であり、 この場合、分割は実行されません。'fixed_width'"fixed_width" は、分割が 定数の文字幅で行われることを意味します。抽出された領域の幅が平均 CharWidthcharWidthchar_width を上回っている場合、領域は与えられた平均 CharWidthcharWidthchar_width を持つ部分に分割されます。分割は領域の左縁から 開始します。'variable_width'"variable_width" は最も文字の連結が希薄な部分 で分割されます。この方法では、プロポーショナルフォントで文字を印刷 するか、連続する多数の文字を 1 つのシンボルとして抽出するかを選ぶ ことができます。 select_charactersSelectCharacters を呼び出す前に、text_line_slantTextLineSlant を呼び出すか、text_line_orientationTextLineOrientation を使用することが有用な 場合もあります。

PartitionLinespartitionLinespartition_lines: ある文字列や異なる文字列の文字を連結する場合、このパラメーターを 'true'"true" に設定します。

FragmentDistancefragmentDistancefragment_distance: このパラメーターは文字の断片を連結するようにします。あまりに多く文 字が連結される場合、このパラメーターを 'narrow'"narrow" または 'medium'"medium" に設定してください。多くの断片を連結する必要があ る場合は、パラメーターを 'medium'"medium" または 'wide'"wide" に設定してください。 この連結は、CharWidthcharWidthchar_width と CharHeightcharHeightchar_height の最大値によ り影響を受けます。関連項目: ConnectFragmentsconnectFragmentsconnect_fragments。

ConnectFragmentsconnectFragmentsconnect_fragments: 抽出するシンボルが分割されている、つまり、シンボルがある領域で抽出 されず、複数の部分に分裂している場合、このパラメーターを 'true'"true" に設定してください。ステップ 'step3_connect_fragments'"step3_connect_fragments" では、 FragmentDistancefragmentDistancefragment_distance と StopAfterstopAfterstop_after も参照してくださ い。

ClutterSizeMaxclutterSizeMaxclutter_size_max: 抽出する文字がノイズ、つまり実際のシンボルの近くに小さな領域を含む 場合、この値を増やします。シンボルの一部が欠けている場合、この値を 減らします。

StopAfterstopAfterstop_after: オペレーターが望ましい結果を生成しない場合、このパラメーターを使用 してください。この値を修正することによって、選択された処理を実行し た後、オペレーターは停止し、対応する結果を提供します。 完全に終了するには、StopAfterstopAfterstop_after を 'completion'"completion" に 設定します。

実行情報🔗

実行情報
  • マルチスレッドタイプ: リエントラント(非排他なオペレーターと並列に動作)

  • マルチスレッドスコープ: グローバル(他のスレッドから呼び出される可能性あり)

  • tupleレベルで自動的に並列演算処理を実施

パラメーター🔗

Regionregionregion (input_object) region(-array) → objectHObjectHRegionHObjectHobject

文字を選択する文字列の領域

RegionCharactersregionCharactersregion_characters (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

選択された文字

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

Punctuationpunctuationpunctuation (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

句読点の追加フラグ

初期値: 'false'"false"
値のリスト: 'false', 'true'"false", "true"

DiacriticMarksdiacriticMarksdiacritic_marks (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

識別記号の有無

初期値: 'false'"false"
値のリスト: 'false', 'true'"false", "true"

PartitionMethodpartitionMethodpartition_method (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

隣接する文字を分割する方法

初期値: 'none'"none"
値のリスト: 'fixed_width', 'none', 'variable_width'"fixed_width", "none", "variable_width"

PartitionLinespartitionLinespartition_lines (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

文字列を分割するフラグ

初期値: 'false'"false"
値のリスト: 'false', 'true'"false", "true"

FragmentDistancefragmentDistancefragment_distance (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

断片の距離

初期値: 'medium'"medium"
値のリスト: 'medium', 'narrow', 'wide'"medium", "narrow", "wide"

ConnectFragmentsconnectFragmentsconnect_fragments (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

断片の連結フラグ

初期値: 'false'"false"
値のリスト: 'false', 'true'"false", "true"

ClutterSizeMaxclutterSizeMaxclutter_size_max (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

ノイズの最大サイズ

初期値: 00
値域: 0 ≤ ClutterSizeMax

StopAfterstopAfterstop_after (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

指定の処理後に実行を停止

初期値: 'completion'"completion"
値のリスト: 'completion', 'step1_select_candidates', 'step2_partition_characters', 'step3_connect_fragments', 'step4_select_characters'"completion", "step1_select_candidates", "step2_partition_characters", "step3_connect_fragments", "step4_select_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)
  select_characters (RegionForeground, RegionCharacters, 'true', \
                     'ultra_light', [60,1,100], [60,1,100], 'false', \
                     'false', 'none', 'true', 'wide', 'true', 0, 'completion')
endfor

結果🔗

入力パラメーターが正しく設定されているならば、オペレーター select_charactersSelectCharacters は、値 2 (H_MSG_TRUE) を返します。 さもなければ、例外処理が発生します。

他のオペレーターとの組み合わせ🔗

組み合わせ

前処理の候補

segment_charactersSegmentCharacters, text_line_slantTextLineSlant

後処理の候補

do_ocr_single_class_mlpDoOcrSingleClassMlp, do_ocr_multi_class_mlpDoOcrMultiClassMlp

他の選択候補

connectionConnection

モジュール🔗

Foundation