用過Halcon的基本都用過這個select_shape,靈活用起來,還是非常好用的。
下面來說說它的使用。
我們閾值分割后,通常的想法是直接選取自己感興趣的。
但是這是非常理想的狀態,按這個思路寫的程序,八成要被工程蹂躪。
一般用select_shape算子來進行兩類的操作來達成工程上更好的魯棒性:
- 首先是用select_shape很小心的過濾掉確定沒用的干擾區域,但是有用信息又不會損失太大。
比如用area去掉dyn_threshold提取出來的很多小噪點。比如離目標較遠的其他選中區域去掉等。- 進行blob分析和形態學操作,對感興趣的目標特征進行各種特征增強,為后面的最后提取目標做准備。
- 最后再用select_shape,一般用多條件組合來選取目標區域。
這樣寫出來的程序才具有更好的魯棒性,更能適應工程需求。
在它的各項特征中,最常用而有效的就是area面積了,
另外其他的特性雖然用的沒那么普及,但是深入理解每個特性的具體定義,絕對是事半功倍。
比如用圓度去除非圓弧長條,反之,離心率提取細長特征體等等。
磨刀不誤砍柴工,花在這個select_shape上的時間是絕對值得的。
題外話:模板匹配,邊緣提取,多種閾值分割都值得花力氣掌握,后面有時間陸續寫。
下面是select_shape的Feature的中英文解釋
核心:提取出來目標形狀和干擾形狀最大最明顯的本質特征差別,組合特性進行篩選。
'area': Area of the object
目標的面積:ROI面積大小進行篩選,去掉小面積的干擾,和其他組合效果更好。
'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 (seecircularity)
圓度,與圓相似程度,圓度=區域面積/((中心到區域邊界的最大距離)^2PI),區域面積和以最大距離為半徑的圓面積做比較,越接近圓,這個比值就會越接近1。
圓度對於大的凸起、孔洞和不相連的區域敏感。必須實心圓度才高。
'compactness': Compactness (seecompactness)
緊湊度=輪廓的長度^2/(4區域的面積PI)。一個圓的緊湊度是1。如果區域是長條或有孔,則緊湊度大於1。
緊湊度對粗糙度和孔洞敏感。大於1,外表越是粗糙毛刺多,值越大。孔洞多,值越大。越接近實心圓越緊湊。鐵匠鍛鐵塊就是這樣的。
'contlength': Total length of contour (see operatorcontlength)
輪廓長度:輪廓線的總長度。同等尺寸下,多刺多孔的值大。
'convexity': Convexity (seeconvexity)
凸性,又稱凸度,凸性=凸包面積/原區域面積,如果是矩形、圓,凸性為1,如果區域含有缺口或孔洞,凸性小於1. 凸包內每個頂點所對應的內角是否小於180度
'rectangularity': Rectangularity (seerectangularity)
矩形相似度,越接近矩形,就越接近1,否則小於1
'ra': Main radius of the equivalent ellipse (seeelliptic_axis)
等效橢圓的主半徑
'rb': Secondary radius of the equivalent ellipse (seeelliptic_axis)
等效橢圓的副半徑
'phi': Orientation of the equivalent ellipse (seeelliptic_axis)
等效橢圓的方向
'anisometry:'Anisometry (seeeccentricity)
離心率,等距=等效橢圓主軸/副軸
'bulkiness:'Bulkiness (see operatoreccentricity)
蓬松性=PI主軸*副軸/區域面積
'struct_factor:'Structur Factor (see operatoreccentricity)
結構元素
'outer_radius': Radius of smallest surrounding circle (seesmallest_circle)
最小外接圓的半徑
'inner_radius': Radius of largest inner circle (seeinner_circle)
最小內接圓的半徑
'inner_width':Width of the largest axis-parallel rectangle that fits into the region (seeinner_rectangle1)
區域最大內接矩形的寬度
'inner_height': Height of the largest axis-parallel rectangle that fits into the region (seeinner_rectangle1)
區域最大內接矩形的高度
'dist_mean':Mean distance from the region border to the center (see operatorroundness)
從區域邊界到中心的平均距離
'dist_deviation:'Deviation of the distance from the region border from the center (see operatorroundness)
從區域邊界到中心的偏差
'roundness': Roundness (see operatorroundness)
圓度
'num_sides': Number of polygon sides (see operatorroundness)
多邊形的邊的數量
'connect_num': Number of connection components (see operatorconnect_and_holes)
連接區域的數量
'holes_num': Number of holes (see operatorconnect_and_holes)
孔洞數
'area_holes': Area of the holes of the object (see operatorarea_holes)
目標的孔洞面積
'max_diameter': Maximum diameter of the region (see operatordiameter_region)
區域最大直徑
'orientation': Orientation of the region (see operatororientation_region)
區域方向
'euler_number': Euler number (see operatoreuler_number)
歐拉數
'rect2_phi':Orientation of the smallest surrounding rectangle (see operatorsmallest_rectangle2)
最小外接矩形的方向
'rect2_len1': Half the length of the smallest surrounding rectangle (see operatorsmallest_rectangle2)
最小外接矩形的長度的一半
'rect2_len2': Half the width of the smallest surrounding rectangle (see operatorsmallest_rectangle2)
最小外接矩形的寬度的一半
'moments_m11': Geometric moments of the region (see operatormoments_region_2nd)
區域的幾何矩
看了感覺怎么樣?來說說吧。。。
喜歡記得關注起來!趕緊的。