Skip to content

dyn_thresholdDynThresholdDynThresholddyn_thresholddyn_threshold🔗

説明🔗

dyn_thresholdDynThresholdDynThresholddyn_thresholddyn_threshold — 局所的なしきい値を用いて画像を分割する。

書式🔗

dyn_threshold( image OrigImage, image ThresholdImage, out region RegionDynThresh, number Offset, string LightDark )void DynThreshold( const HObject& OrigImage, const HObject& ThresholdImage, HObject* RegionDynThresh, const HTuple& Offset, const HTuple& LightDark )static void HOperatorSet.DynThreshold( HObject origImage, HObject thresholdImage, out HObject regionDynThresh, HTuple offset, HTuple lightDark )def dyn_threshold( orig_image: HObject, threshold_image: HObject, offset: Union[int, float], light_dark: str ) -> HObject

Herror dyn_threshold( const Hobject OrigImage, const Hobject ThresholdImage, Hobject* RegionDynThresh, double Offset, const char* LightDark )

Herror T_dyn_threshold( const Hobject OrigImage, const Hobject ThresholdImage, Hobject* RegionDynThresh, const Htuple Offset, const Htuple LightDark )

HRegion HImage::DynThreshold( const HImage& ThresholdImage, const HTuple& Offset, const HString& LightDark ) const

HRegion HImage::DynThreshold( const HImage& ThresholdImage, double Offset, const HString& LightDark ) const

HRegion HImage::DynThreshold( const HImage& ThresholdImage, double Offset, const char* LightDark ) const

HRegion HImage::DynThreshold( const HImage& ThresholdImage, double Offset, const wchar_t* LightDark ) const (Windows only)

HRegion HImage.DynThreshold( HImage thresholdImage, HTuple offset, string lightDark )

HRegion HImage.DynThreshold( HImage thresholdImage, double offset, string lightDark )

説明🔗

dyn_thresholdDynThreshold は画像領域のピクセルがしきい値条件を満たす入 力画像から選択します。\(g_{o} = g_{\textrm{OrigImage}}\) および \(g_{ t} = g_{\textrm{ThresholdImage}}\) と仮定します。その後、 LightDarklightDarklight_dark = 'light'"light" に対する条件は、以下の式になります。

\[\begin{eqnarray*} g_{o} \ge g_{t} + \textrm{Offset} \end{eqnarray*}\]

LightDarklightDarklight_dark = 'dark'"dark" の場合、条件は以下のとおりです。

\[\begin{eqnarray*} g_{o} \le g_{t} - \textrm{Offset} \end{eqnarray*}\]

LightDarklightDarklight_dark = 'equal'"equal" の場合、条件は以下のとおりです。

\[\begin{eqnarray*} g_{t} - \textrm{Offset} \le g_{o} \le g_{t} + \textrm{Offset} \end{eqnarray*}\]

最後に、LightDarklightDarklight_dark = 'not_equal'"not_equal" の場合、条件は以下のとお りです。

\[\begin{eqnarray*} g_{t} - \textrm{Offset} > g_{o} \vee g_{o} > g_{t} + \textrm{Offset} \end{eqnarray*}\]

通常、しきい値画像は(例えば、mean_imageMeanImage、 binomial_filterBinomialFilter、gauss_filterGaussFilter などで適用することに より)オリジナル画像を平滑化したバージョンです。そのため、 dyn_thresholdDynThreshold の効果は、オリジナル画像にハイパスフィルター を使用した画像に thresholdThreshold を適用する画像と類似します。( highpass_imageHighpassImage を参照してください。)

dyn_thresholdDynThreshold を使用し、オブジェクトの XLD を抽出すること ができます。ここで、オブジェクトの大きさ(直径)は、ローパスフィル ターのマスクサイズとオブジェクトのエッジの振幅によって決定されま す。

大きなマスクサイズを選択すればするほど、検出領域も大きくなります。 大まかに言うと、マスクサイズは抽出されるオブジェクトの直径の約 2 倍程度に設定する必要があります。パラメーター Offsetoffsetoffset をゼロに設 定しないことも重要です。この場合、あまりに多くの小さな領域(ノイ ズ)が検出されるためです。5 から 40 までの値が有用な選択です。大き な Offsetoffsetoffset を選択するにつれて、抽出領域がだんだん小さくな ります。

上記の条件を満たす入力画像のすべての点は、1 つの領域にまとめて保存 されます。必要ならば、connectionConnection を呼び出すことによって連 結成分を得ることができます。

注意🔗

Offsetoffsetoffset を -1 ~o 1 に選ぶと、通常大き なメモリを必要とする非常にノイズが大きい領域が生成されます。 Offsetoffsetoffset が非常に大きく選ばれる(たとえば \(>\) 60 以上)と、 しきい値条件を満足しない点が生じることがあります。(すなわち、空の 領域が返されます。) Offsetoffsetoffset を非常に小さく選ぶ(たとえ ば \(<\) -60 未満)と、すべての点がしきい値条件を満足してしまいま す。(すなわち、全部の領域が返されます。)

実行情報🔗

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

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

  • ドメインレベルで自動的に並列演算処理を実施

パラメーター🔗

OrigImageorigImageorig_image (input_object) singlechannelimage(-array) → object (byte / int2 / uint2 / int4 / real)HObject (byte / int2 / uint2 / int4 / real)HImage (byte / int2 / uint2 / int4 / real)HObject (byte / int2 / uint2 / int4 / real)Hobject (byte / int2 / uint2 / int4 / real)

入力画像

ThresholdImagethresholdImagethreshold_image (input_object) singlechannelimage(-array) → object (byte / int2 / uint2 / int4 / real)HObject (byte / int2 / uint2 / int4 / real)HImage (byte / int2 / uint2 / int4 / real)HObject (byte / int2 / uint2 / int4 / real)Hobject (byte / int2 / uint2 / int4 / real)

しきい値画像(通常しきい値処理する画像の平均画像)

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

抽出された結果領域

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

ThresholdImage に適用したオフセット

初期値: 5.05.0
推奨値: 1.0, 3.0, 5.0, 7.0, 10.0, 20.0, 30.01.0, 3.0, 5.0, 7.0, 10.0, 20.0, 30.0
値域: -255.0 ≤ Offset ≤ 255.0 (lin)
最小増分: 0.01
推奨増分: 5

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

「明るい」、「暗い」または「類似した」のどの領域を 抽出するかの選択

初期値: 'light'"light"
値のリスト: 'dark', 'equal', 'light', 'not_equal'"dark", "equal", "light", "not_equal"

例🔗

(HDevelop)


* Looking for regions with the diameter D
mean_image(Image,Mean,D*2+1,D*2+1)
dyn_threshold(Image,Mean,Seg,5,'light')
connection(Seg,Regions)
(C)
/* Looking for regions with the diameter D */
mean_image(Image,&Mean,D*2+1,D*2+1)\;
dyn_threshold(Image,Mean,&Seg,5.0,"light")\;
connection(Seg,&Region)\;
(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[])
{
  HImage   image ("monkey"),
           mean\;
  HWindow  win\;
 if (argc != 2)
  {
    cout << "Using: " << argv[0] << " <diameter>" << endl\;
    exit (1)\;
  }
 int d = atoi (argv[1]) * 2 + 1\;
 image.Display (win)\;
 mean = image.MeanImage (d, d)\;
 HRegionArray seg = image.DynThreshold (mean, 5.0, "light")\;
  HRegionArray reg = seg.Connection ()\;
 win.SetColored (12)\;
  reg.Display (win)\;
  win.Click ()\;
 return (0)\;
}

複雑性🔗

入力領域の面積を \(A\) とします。その場合、実行時間は \(O(A)\) です。

結果🔗

dyn_thresholdDynThreshold は、すべてのパラメーターが正しい場合に 2 (H_MSG_TRUE) を返します。入力画像と出力領域に関する動作は、set_systemSetSystem でフラグ 'no_object_result'"no_object_result"、 'empty_region_result'"empty_region_result"、および 'store_empty_region'"store_empty_region" の値を設定することによって決定されま す。 必要に応じて、例外が発生します。

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

組み合わせ

前処理の候補

mean_imageMeanImage, smooth_imageSmoothImage, binomial_filterBinomialFilter, gauss_filterGaussFilter

後処理の候補

connectionConnection, select_shapeSelectShape, reduce_domainReduceDomain, select_graySelectGray, rank_regionRankRegion, dilation1Dilation1, openingOpening, erosion1Erosion1

他の選択候補

check_differenceCheckDifference, thresholdThreshold

関連項目

highpass_imageHighpassImage, sub_imageSubImage

モジュール🔗

Foundation