说说常用算子select_shape的特性一些使用

用过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)
区域的几何矩


看了感觉怎么样?来说说吧。。。
喜欢记得关注起来!赶紧的。


原文地址:https://www.cnblogs.com/eyesonchip/p/13698031.html