circularity🔗
説明🔗
circularity — 領域の真円度に対する形状係数を算出する。
書式🔗
circularity( region Regions, out real Circularity )
説明🔗
オペレーター circularity は入力領域の丸み(真円度)を
計算します。
-
計算: F が領域の面積で、max が中心からすべての XLD オブジェクトの ピクセルまでの距離である場合、形状係数 C は以下のように 定義されます。
\[\begin{eqnarray*} C^\prime = \frac{F}{(max^2 * \pi)} \end{eqnarray*}\]C = min(1,C’)
円の形状係数 C は 1 です。領域が長いかまたは穴をもつなら
ば、形状係数 C は 1 未満となります。
オペレーター circularity は、大きいふくらみ、ホールや連結し
ていない領域の特徴を捉える場合に特に意味をもちます。
領域の面積は真円の面積にのみ近似することができるので、形状係数 C は 1.0 以上にはなりません。
この近似誤差は、大きな領域に比べ、小さな領域でより大きくなります。
この章(Regions / Features)のドキュメント内に真円度が変化
した場合のregionのイメージ図があります。
空の領域の場合、オペレーター circularity は、他の動作が設
定されていなければ(set_system 参照)値 0 を返します。
1 つ以上の領域が入力された場合、形状係数は Tuple に格納さ
れます。tuple における値の位置は入力された領域の位置に対応します。
実行情報🔗
実行情報
-
マルチスレッドタイプ: リエントラント(非排他なオペレーターと並列に動作)
-
マルチスレッドスコープ: グローバル(他のスレッドから呼び出される可能性あり)
-
tupleレベルで自動的に並列演算処理を実施
パラメーター🔗
Regions (input_object) region(-array) → object
対象となる入力領域
Circularity (output_control) real(-array) → (real)
入力領域の真円度
制限: 0 <= Circularity && Circularity <= 1.0
例🔗
(HDevelop)
* Comparison between shape factors of rectangle, circle and ellipse:
gen_rectangle1(R1,10,10,20,20)
gen_rectangle2(R2,100,100,0.0,100,20)
gen_ellipse(E100,100,100,0.0,100,20)
gen_circle(C,100,100,20)
circularity(R1,M_R1)
circularity(R2,M_R2)
circularity(E100,M_E)
circularity(C,M_C)
fwrite_string(FileId,['quadrate: ',M_R1])
fnew_line(FileId)
fwrite_string(FileId,['rectangle: ',M_R2])
fnew_line(FileId)
fwrite_string(FileId,['ellipse: ',M_E])
fnew_line(FileId)
fwrite_string(FileId,['circle: ',M_C])
fnew_line(FileId)
(C)/* Comparison between shape factors of rectangle, circle and ellipse */
gen_rectangle1(&R1,10.0,10.0,20.0,20.0)\;
gen_rectangle2(&R2,100.0,100.0,0.0,100.0,20.0)\;
gen_ellipse(&E,100.0,100.0,0.0,100.0,20.0)\;
gen_circle(&C,100.0,100.0,20.0)\;
circularity(R1,&R1_)\;
circularity(R2,&R2_)\;
circularity(E,&E_)\;
circularity(C,&C_)\;
printf("quadrate: %g\n",R1_)\;
printf("rectangle: %g\n",R2_)\;
printf("ellipse: %g\n",E_)\;
printf("circle: %g\n",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] << " <# of regions> " << endl\;
return (-1)\;
}
HWindow w\;
HRegionArray reg\;
int NumOfElements = atoi (argv[1])\;
cout << "Draw " << NumOfElements << " regions " << endl\;
for (int i=0\; i < NumOfElements\; i++)
{
reg[i] = w.DrawRegion ()\;
}
Tuple circ = reg.Circularity ()\;
Tuple cont = reg.Contlength ()\;
for (i = 0\; i < NumOfElements\; i++)
{
cout << "Circularity of " << i+1 << ". region = " << circ[i].D()\;
cout << "\t\t Contour Length of" << i+1 <<
". region = " << cont[i].D() << endl\;
}
w.Click ()\;
return(0)\;
}
結果🔗
入力が空でない場合、オペレーター circularity は、値 2 (H_MSG_TRUE)
を返します。
入力が空だった場合(入力画像が得られない場合)の動作は、オペレー
ター set_system('no_object_result',<Result>) で設定されま す。
空の領域の場合(領域が空集合である場合)の動作は、オペレーター
set_system('empty_region_result',<Result>) を通して設定さ れます。
必要に応じて、例外が発生します。
他のオペレーターとの組み合わせ🔗
組み合わせ
前処理の候補
threshold, regiongrowing, connection
他の選択候補
roundness, compactness, convexity, eccentricity
関連項目
モジュール🔗
Foundation