Skip to content

char_thresholdCharThresholdCharThresholdchar_thresholdchar_threshold🔗

説明🔗

char_thresholdCharThresholdCharThresholdchar_thresholdchar_threshold — 抽出された特性に対してしきい値分割を実行する。

書式🔗

char_threshold( image Image, region HistoRegion, out region Characters, number Sigma, number Percent, out integer Threshold )void CharThreshold( const HObject& Image, const HObject& HistoRegion, HObject* Characters, const HTuple& Sigma, const HTuple& Percent, HTuple* Threshold )static void HOperatorSet.CharThreshold( HObject image, HObject histoRegion, out HObject characters, HTuple sigma, HTuple percent, out HTuple threshold )def char_threshold( image: HObject, histo_region: HObject, sigma: float, percent: Union[int, float] ) -> Tuple[HObject, Sequence[int]]

def char_threshold_s( image: HObject, histo_region: HObject, sigma: float, percent: Union[int, float] ) -> Tuple[HObject, int]Herror char_threshold( const Hobject Image, const Hobject HistoRegion, Hobject* Characters, double Sigma, double Percent, Hlong* Threshold )

Herror T_char_threshold( const Hobject Image, const Hobject HistoRegion, Hobject* Characters, const Htuple Sigma, const Htuple Percent, Htuple* Threshold )

HRegion HImage::CharThreshold( const HRegion& HistoRegion, double Sigma, const HTuple& Percent, HTuple* Threshold ) const

HRegion HImage::CharThreshold( const HRegion& HistoRegion, double Sigma, double Percent, Hlong* Threshold ) const

HRegion HImage.CharThreshold( HRegion histoRegion, double sigma, HTuple percent, out HTuple threshold )

HRegion HImage.CharThreshold( HRegion histoRegion, double sigma, double percent, out int threshold )

説明🔗

char_thresholdCharThreshold の主なアプリケーションは1 チ ャンネル画像における、明るい紙の上からの暗い文字のセグメントです。このオペレーターは、以下のように働きま す。 最初に、画像 Imageimageimage のグレイ値のヒストグラムが領域 HistoRegionhistoRegionhisto_region{} 内の点に対して計算されます。ノイズを除去す るために、ヒストグラムが与えられた Sigmasigmasigma (Gaussian smoothing) で滑らかにされます。ヒストグラム内で、文字は低いグレイ 値で小さいピークを形成する一方、背景(白い紙)は、高いグレイ値で大 きなピークに相当します。2 つのピーク間の最小の位置を示すオペレー ター binary_thresholdBinaryThreshold (Methodmethodmethod='smooth_histo'"smooth_histo"の場合)と対比して、 分割のためのしきい値はヒストグラムの最大、すなわち背景に関連して下記条件で決定されます。

         histogram[threshold] * 100.0 < histogram[maximum] * (100.0 - Percent)

たとえば Percentpercentpercent = 95 を選べば、オペレーターはその周波数 が最大の周波数の 5 パーセントであるグレイ値を示します。 char_thresholdCharThreshold は文字は背景より暗いという仮定しているの で、しきい値は最大値の「左に」対して検索します。

binary_thresholdBinaryThreshold と比較して、もし文字と背景に対応するヒストグ ラムのピーク間に明確な最小値がない場合、あるいは文字に対応するピーク がまったくない場合、このオペレーターが使用されるべきです。この状態は、 たとえば、画像が文字を少ししか含んでいない場合や照明が不均一な 場合に起きる可能性があります。

実行情報🔗

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

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

  • 内部データレベルで自動的に並列演算処理を実施

パラメーター🔗

Imageimageimage (input_object) singlechannelimage(-array) → object (byte)HObject (byte)HImage (byte)HObject (byte)Hobject (byte)

入力画像。

HistoRegionhistoRegionhisto_region (input_object) region → objectHObjectHRegionHObjectHobject

ヒストグラムが計算される領域

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

暗い領域(キャラクタ)

Sigmasigmasigma (input_control) number → (real)HTuple (double)HTuple (double)floatHtuple (double)

ヒストグラムに適用するガウススムージングに 用いるシグマの値

初期値: 2.02.0
推奨値: 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.00.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0
値域: 0.0 ≤ Sigma ≤ 50.0 (lin)
最小増分: 0.01
推奨増分: 0.2

Percentpercentpercent (input_control) number → (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[int, float]Htuple (double / Hlong)

グレイ値の差に対するパーセンテージ

初期値: 9595
推奨値: 90, 92, 95, 96, 97, 98, 99, 99.5, 10090, 92, 95, 96, 97, 98, 99, 99.5, 100
値域: 0.0 ≤ Percent ≤ 100.0 (lin)
最小増分: 0.1
推奨増分: 0.5

Thresholdthresholdthreshold (output_control) integer(-array) → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

計算されたしきい値

例🔗

(HDevelop)


read_image (Image, 'letters')
char_threshold (Image, Image, Seg, 0.0, 5.0, Threshold)
connection (Seg, Connected)
(C)
read_image(&Image,"letters")\;
char_threshold(Image,Image,&Seg,0.0,5.0,&Threshold)\;
connection(Seg,&Connected)\;
set_colored(WindowHandle,12)\;
set_shape(WindowHandle,"rectangle1")\;
disp_region(Connected,WindowHandle)\;
(C++)
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std\;
#endif
#include "HalconCpp.h"
using namespace Halcon\;

int main (int argc, char *argv[])
{
  if (argc != 2)
  {
    cout << "Usage : " << argv[0] << " 'image' " << endl\;
    return -1\;
  }
 HImage       image(argv[1])\;
  HWindow      w\;
  HTuple       threshold\;
 w.SetDraw("margin")\;
  w.SetShape("rectangle1")\;
  w.SetColored(12)\;
 image.Display(w)\;
 HRegionArray reg = image.CharThreshold(image,0,5,&threshold)\;
  HRegionArray con = reg.Connection()\;
 cout << "Display image after CharThreshold segmentation " << endl\;
  con.Display(w)\;
  w.Click()\;
 return 0\;
}

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

組み合わせ

前処理の候補

anisotropic_diffusionAnisotropicDiffusion, median_imageMedianImage, illuminateIlluminate

後処理の候補

connectionConnection, select_shapeSelectShape, select_graySelectGray

他の選択候補

binary_thresholdBinaryThreshold, auto_thresholdAutoThreshold, gray_histoGrayHisto, smooth_funct_1d_gaussSmoothFunct1dGauss, thresholdThreshold

モジュール🔗

Foundation