connection🔗
説明🔗
connection — 領域の連結成分を計算する。
書式🔗
connection( region Region, out region ConnectedRegions )
説明🔗
connection は、Region で与えられた入力領域の連結
成分を決定します。使用される近傍は
set_system('neighborhood',<4/8>) によって設定できます。
デフォルトは 8 近傍であり、それは前景の連結成分を決定するために有
効です。 connection によって返される連結成分の最大値は
set_system('max_connection',<Num>) を経由して設定されま
す。デフォルト値 0 は、すべての連結成分を返します。
connection の逆の演算は、union1 です。
実行情報🔗
実行情報
-
マルチスレッドタイプ: リエントラント(非排他なオペレーターと並列に動作)
-
マルチスレッドスコープ: グローバル(他のスレッドから呼び出される可能性あり)
-
内部データレベルで自動的に並列演算処理を実施
パラメーター🔗
Region (input_object) region(-array) → object
入力領域
ConnectedRegions (output_object) region-array → object
連結成分
例🔗
(HDevelop)
read_image(Image,'clip')
dev_set_colored(12)
threshold(Image,Dark,0,150)
count_obj(Dark,NumThresholded)
dev_display (Dark)
connection(Dark,ConnectedRegions)
count_obj(ConnectedRegions,NumConnected)
dev_display (ConnectedRegions)
(C)read_image(&Image,"monkey")\;
set_colored(WindowHandle,12)\;
threshold(Image,&Light,150.0,255.0)\;
count_obj(Light,&Number1)\;
printf("Number of regions after threshold = %d\n",Number1)\;
disp_region(Light,WindowHandle)\;
connection(Light,&Many)\;
count_obj(Many,&Number2)\;
printf("Number of regions after threshold = %d\n",Number2)\;
disp_region(Many,WindowHandle)\;
#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 (argv[1])\;
HWindow w\;
w.SetColored(12)\;
HRegion Light = image >= 128\;
Light.Display(w)\;
HRegionArray Many = Light.Connection()\;
cout << "Number of regions after threshold = " << Many.Num()\;
Many.Display(w)\;
}
複雑性🔗
入力領域の面積を \(F\) とし、生成される連結成分数を be the number of \(N\)とします。その場合、実行時間は \(O(\sqrt{F} * \sqrt{N})\) です。
結果🔗
connection は、常に値 2 (H_MSG_TRUE) を返します。空の入力(与えられ
た領域がない)の場合は、
set_system('no_object_result',<Result>)
を通して動作を設定し、空の入力領域の場合は、
set_system('empty_region_result',<Result>) を通して動作を
設定できます。
必要に応じて、例外が発生します。
他のオペレーターとの組み合わせ🔗
組み合わせ
前処理の候補
auto_threshold, threshold, dyn_threshold, erosion1
後処理の候補
select_shape, select_gray, shape_trans, set_colored, dilation1, count_obj, reduce_domain, add_channels
他の選択候補
関連項目
モジュール🔗
Foundation