class_2dim_sup🔗
説明🔗
class_2dim_sup — 2 次元ピクセルクラス分けを用いて画像を分割する。
書式🔗
class_2dim_sup( image ImageCol, image ImageRow, region FeatureSpace, out region RegionClass2Dim )
説明🔗
class_2dim_sup は、2 次元特徴空間を用いて 2 チャンネル画像
内の点をクラス分けします。各点に対して、2 つのグレイ値 (各画像か
ら 1 つ) を特徴として使用します。特徴空間は入力領域によって表され
ます。クラス分けは以下に示すように行われます。
各グレイ値によって決定される点 \((g_{r},g_{c})\) が領域
FeatureSpace 内に含まれる場合、画像の入力領域からの点が受け入れられます。\(g_{r}\)
は、画像 ImageRow か
らのグレイ値で、\(g_{c}\) は ImageCol からの対応するグレイ
値です。
\(P\) が座標 \(P=(R,C)\) を持つ点であり、\(g_{r}\) が画像
ImageRow 内の位置 \((R,C)\) におけるグレイ値であり、\(g_{c}\)
が画像 ImageCol 内の位置 \((R,C)\) におけるグレイ値である
とします。以下であるならば、点 \(P\) は出力領域に集められます。
\(g_{r}\) は行座標、\(g_{c}\) は列座標と解釈されます。
FeatureSpace の生成に関しては histo_2dim を参照し
てください。特徴空間は、class_2dim_sup が呼び出される前
に、rank_region、dilation1、shape_trans、
elliptic_axis などのような領域変換オペレーターを適用するこ
とで、変更できます。
パラメーター ImageCol と ImageRow は、同じ大きさ
をもつ等しい数の画像を含まなければなりません。
画像の点は、両方の画像に関する領域の共通部分から取る必要がありま
す。(reduce_domain 参照)
実行情報🔗
実行情報
-
マルチスレッドタイプ: リエントラント(非排他なオペレーターと並列に動作)
-
マルチスレッドスコープ: グローバル(他のスレッドから呼び出される可能性あり)
パラメーター🔗
ImageCol (input_object) singlechannelimage(-array) → object (byte / direction / cyclic / int1)
入力画像(第 1 チャンネル)
ImageRow (input_object) singlechannelimage(-array) → object (byte / direction / cyclic / int1)
入力画像(第 2 チャンネル)
FeatureSpace (input_object) region(-array) → object
特徴空間を定義する領域
RegionClass2Dim (output_object) region(-array) → object
クラス分けされた領域
例🔗
(C)
read_image(&Image,"combine")\;
open_window(0,0,-1,-1,0,"visible","",&WindowHandle)\;
disp_image(Image,WindowHandle)\;
fwrite_string("draw region of interest with the mouse")\;
fnew_line()\;
set_color(WindowHandle,"green")\;
draw_region(&Testreg,draw_region)\;
/* Texture transformation for 2-dimensional charachteristic */
texture_laws(Image,&T1,"el",2,5)\;
mean_image(T1,&M1,21,21)\;
texture_laws(M1,&T2,"es,",2,5)\;
mean_image(T2,&M2,21,21)\;
/* 2-dimensinal histogram of the test region */
histo_2dim(Testreg,M1,M2,&Histo)\;
/* All points occuring at least once */
threshold(Histo,&FeatureSpace,1.0,100000.0)\;
set_draw(WindowHandle,"fill")\;
set_color(WindowHandle,"red")\;
disp_region(FeatureSpace,WindowHandle)\;
fwrite_string("Characteristics area in red")\;
fnew_line()\;
/* Segmentation */
class_2dim_sup(M1,M2,FeatureSpace,&RegionClass2Dim)\;
set_color(WindowHandle,"blue")\;
disp_region(RegionClass2Dim,WindowHandle)\;
fwrite_string("Result of classification in blue")\;
fnew_line()\;
#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)\;
}
HRegion feats, cd2reg\;
HImage image (argv[1]),
text1, text2,
mean1, mean2,
histo\;
HWindow win\;
Hlong nc\;
if ((nc = image.CountChannels ()) != 3)
{
cout << argv[1] << " is not a rgb-image " << endl\;
return (-2)\;
}
image.Display (win)\;
win.SetColor ("green")\;
cout << "Draw the region of interrest " << endl\;
HRegion region = win.DrawRegion ()\;
text1 = image.TextureLaws ("el", 2, 5)\;
mean1 = text1.MeanImage (21, 21)\;
text2 = mean1.TextureLaws ("es", 2, 5)\;
mean2 = text2.MeanImage (21, 21)\;
histo = region.Histo2dim (mean1, mean2)\;
feats = histo.Threshold (1.0, 1000000.0)\;
win.SetDraw ("fill")\;
win.SetColor ("red")\;
feats.Display (win)\;
cout << "Charakteristics area in red" << endl\;
cd2reg = mean1.Class2dimSup (mean2, feats)\;
win.SetColor ("blue")\;
cd2reg.Display (win)\;
cout << "Result of classification in blue " << endl\;
win.Click ()\;
return (0)\;
}
複雑性🔗
入力領域の面積を \(A\) とします。その場合、実行時間は \(O(256^2 + A)\) です。
結果🔗
class_2dim_sup 2 (H_MSG_TRUE) を返します。すべてのパラメーターが正し
い場合、入力画像と出力領域に関する動作は、set_system のフ
ラグ値 'no_object_result'、'empty_region_result'、
および 'store_empty_region' の設定により決定します。必
要に応じて、例外が発生します。
他のオペレーターとの組み合わせ🔗
組み合わせ
前処理の候補
histo_2dim, threshold, draw_region, dilation1, opening, shape_trans
後処理の候補
connection, select_shape, select_gray
他の選択候補
関連項目
モジュール🔗
Foundation