Halcon 算子 select_shape- 藉助形狀特徵選擇區域(選擇輪廓)
select_shape - 藉助形狀特徵選擇區域。
原型:
1
|
select_shape(Regions : SelectedRegions : Features, Operation, Min, Max : ) |
(將連接的區域進行篩選,篩選的特徵有很多,如面積長度等,可以去掉不滿足條件的輪廓)
描述:
操作符select_shape根據形狀選擇區域。對於來自區域的每個輸入區域,計算所指示的特徵(features)。如果計算特徵的每個(Operation='and')或至少一個(Operation='or')在默認限制(最小值、最大值)內,則該區域將適應輸出(複製)。
條件:Min_i <= Feature_i(Object) <= Max_i
功能特徵的取值:
特徵 | 英 | 譯 | 備註 |
area | Area of the object | 對象的面積 | |
row | Row index of the center | 中心點的行座標 | |
column | Column index of the center | 中心點的列座標 | |
width | Width of the region | 區域的寬度 | |
height | Height of the region | 區域的高度 | |
row1 | Row index of upper left corner | 左上角行座標 | |
column1 | Column index of upper left corner | 左上角列座標 | |
row2 | Row index of lower right corner | 右下角行座標 | |
column2 | Column index of lower right corner | 右下角列座標 | |
circularity | Circularity | 圓度 | 0~1 |
compactness | Compactness | 緊密度 | 0~1 |
contlength | Total length of contour | 輪廓線總長 | |
convexity | Convexity | 凸性 | |
rectangularity | Rectangularity | 矩形度 | 0~1 |
ra | Main radius of the equivalent ellipse | 等效橢圓長軸半徑長度 | |
rb | Secondary radius of the equivalent ellipse | 等效橢圓短軸半徑長度 | |
phi | Orientation of the equivalent ellipse | 等效橢圓方向 | |
anisometry | Anisometry | 橢圓參數,Ra/Rb長軸與短軸的比值 | |
bulkiness | Bulkiness | 橢圓參數,蓬鬆度π*Ra*Rb/A | |
struct_factor | Structur Factor | 橢圓參數,Anisometry*Bulkiness-1 | |
outer_radius | Radius of smallest surrounding circle | 最小外接圓半徑 | |
inner_radius | Radius of largest inner circle | 最大內接圓半徑 | |
inner_width | Width of the largest axis-parallel rectangle that fits into the region | 最大內接矩形寬度 | |
inner_height | Height of the largest axis-parallel rectangle that fits into the region | 最大內接矩形高度 | |
dist_mean | Mean distance from the region border to the center | 區域邊界到中心的平均距離 | |
dist_deviation | Deviation of the distance from the region border from the center | 區域邊界到中心距離的偏差 | |
roundness | Roundness | 圓度,與circularity計算方法不同 | |
num_sides | Number of polygon sides | 多邊形邊數 | |
connect_num | Number of connection components | 連通數 | |
holes_num | Number of holes | 區域內洞數 | |
area_holes | Area of the holes of the object | 所有洞的面積 | |
max_diameter | Maximum diameter of the region | 最大直徑 | |
orientation | Orientation of the region | 區域方向 | |
euler_number | Euler number | 歐拉數,即連通數和洞數的差 | |
rect2_phi | Orientation of the smallest surrounding rectangle | 最小外接矩形的方向 | |
rect2_len1 | Half the length of the smallest surrounding rectangle | 最小外接矩形長度的一半?? | smallest_rectangle2 |
rect2_len2 | Half the width of the smallest surrounding rectangle | 最小外接矩形寬度的一半 | |
moments_m11 | Geometric moments of the region | 幾何矩(圖片中對象的形狀,大小,位置) | |
moments_m20 | Geometric moments of the region | 幾何矩 | |
moments_m02 | Geometric moments of the region | 幾何矩 | |
moments_ia | Geometric moments of the region | 幾何矩 | |
moments_ib | Geometric moments of the region | 幾何矩 | |
moments_m11_invar | Geometric moments of the region | 幾何矩 | |
moments_m20_invar | Geometric moments of the region | 幾何矩 | |
moments_m02_invar | Geometric moments of the region | 幾何矩 | |
moments_phi1 | Geometric moments of the region | 幾何矩 | |
moments_phi2 | Geometric moments of the region | 幾何矩 | |
moments_m21 | Geometric moments of the region | 幾何矩 | |
moments_m12 | Geometric moments of the region | 幾何矩 | |
moments_m03 | Geometric moments of the region | 幾何矩 | |
moments_m30 | Geometric moments of the region | 幾何矩 | |
moments_m21_invar | Geometric moments of the region | 幾何矩 | |
moments_m12_invar | Geometric moments of the region | 幾何矩 | |
moments_m03_invar | Geometric moments of the region | 幾何矩 | |
moments_m30_invar | Geometric moments of the region | 幾何矩 | |
moments_i1 | Geometric moments of the region | 幾何矩 | |
moments_i2 | Geometric moments of the region | 幾何矩 | |
moments_i3 | Geometric moments of the region | 幾何矩 | |
moments_i4 | Geometric moments of the region | 幾何矩 | |
moments_psi1 | Geometric moments of the region | 幾何矩 | |
moments_psi2 | Geometric moments of the region | 幾何矩 | |
moments_psi3 | Geometric moments of the region | 幾何矩 | |
moments_psi4 | Geometric moments of the region | 幾何矩 |
參數:
- Regions (input_object) region-array → object //要檢查的區域
- SelectedRegions (output_object) region-array → object //符合條件的區域
- Features (input_control) string(-array) → (string) //要檢查的形狀特徵
- 默認值: 'area'
- 值列表: 'area', 'row', 'column', 'width', 'height', 'row1', 'column1', 'row2', 'column2', 'circularity', 'compactness', 'contlength', 'convexity', 'rectangularity', 'ra', 'rb', 'phi', 'anisometry', 'bulkiness', 'struct_factor', 'outer_radius', 'inner_radius', 'inner_width', 'inner_height', 'max_diameter', 'dist_mean', 'dist_deviation', 'roundness', 'num_sides', 'orientation', 'connect_num', 'holes_num', 'area_holes', 'euler_number', 'rect2_phi', 'rect2_len1', 'rect2_len2', 'moments_m11', 'moments_m20', 'moments_m02', 'moments_ia', 'moments_ib', 'moments_m11_invar', 'moments_m20_invar', 'moments_m02_invar', 'moments_phi1', 'moments_phi2', 'moments_m21', 'moments_m12', 'moments_m03', 'moments_m30', 'moments_m21_invar', 'moments_m12_invar', 'moments_m03_invar', 'moments_m30_invar', 'moments_i1', 'moments_i2', 'moments_i3', 'moments_i4', 'moments_psi1', 'moments_psi2', 'moments_psi3', 'moments_psi4'
- Operation (input_control) string → (string) //單個特徵的鏈接類型
- 默認值: 'and'
- 值列表: 'and', 'or'
- Min (input_control) real(-array) → (real / integer / string) //特徵下限 ,最小值
- 默認值: 150.0
- 典型取值範圍: 0.0 ≤ Min ≤ 99999.0
- 最小增量: 0.001
- 建議增量: 1.0
- Max (input_control) real(-array) → (real / integer / string) //特徵上限,最大值
- 默認值: 99999.0
- 典型取值範圍: 0.0 ≤ Max ≤ 99999.0
- 最小增量: 0.001
- 建議增量: 1.0
- 限制: Max >= Min //Max必須大於等於Min ,否則報錯
示例:
1
2
3
4
5
|
read_image(Image, 'monkey' ) threshold(Image,S1,160,255) connection(S1,S2) select_shape(S2,Eyes,[ 'area' , 'anisometry' ], 'and' ,[500,1.0],[50000,1.7]) disp_region(Eyes,WindowHandle) |