1. 程式人生 > 其它 >30.3、Blob---Connection

30.3、Blob---Connection

閾值分割後,需要提取目標物體。為了提取目標物體不得不先找到連通區域。

1、原理

提取連通域的搜尋型別有兩種,一種是4連通域,一種是8連通域

Halcon中的connection是預設是用8連通域。

2、作用:

    *產生region區域

gen_rectangle1 (ROI_0, 72.5, 175.5, 134.5, 293.5)

gen_circle (TMP_Region, 98.5, 385.5, 40.3609)

union2 (ROI_0, TMP_Region, ROI_0)

*進行連通性分析,把一個整體邊界不連線的區域分開

connection (ROI_0, ConnectedRegions)

*connectiond的反操作union1,把互相分開的region陣列重新聯合成一個整體

union1 (ConnectedRegions, RegionUnion)

3、connect_and_holes(Regions : : : NumConnected, NumHoles)

    功能:計算連通個數和孔洞數量

    *生成區域

gen_rectangle1 (ROI_0, 69.5, 81.5, 172.5, 253.5)

gen_circle (TMP_Region, 112.5, 397.5, 40.8167)

union2 (ROI_0, TMP_Region, ROI_0)

gen_rectangle2 (TMP_Region, 105.5,

532.5, rad(-29.5115), 60.9016, 56.4189)

union2 (ROI_0, TMP_Region, ROI_0)

gen_ellipse (TMP_Region, 121.5, 138.5, rad(-38.2902), 24.2074, 8)

difference (ROI_0, TMP_Region, ROI_0)

gen_ellipse (TMP_Region, 107.5, 378.5, rad(-48.0128), 13.4536, 8)

difference (ROI_0, TMP_Region, ROI_0)

*計算可連通個數已經孔洞個數

connect_and_holes (ROI_0, NumConnected, NumHoles)