Halcon算子学习

时间:2022-04-02 07:10:31
* dev前缀的算子表示开发编译器相关的函数
dev_update_window ('off')//halcon编辑器图形输出界面参数是否都更新,off表示手动,on表示全部更新
dev_close_window ()//关闭图形窗口
dev_open_window (, , , , 'black', WindowID)//打开图形窗口
read_image (Bond, 'die/die_03')//读图到Bond变量
dev_display (Bond)//显示图像
set_display_font (WindowID, , 'mono', 'true', 'false')//设置显示的字体
disp_continue_message (WindowID, 'black', 'true')//显示继续消息,
stop ()//等待用户按F5继续执行,如下图所示
threshold (Bond, Bright, , )//阈值处理
shape_trans (Bright, Die, 'rectangle2')//形状转化

'convex':加凸壳。


'ellipse':和输入区域具有相同的长短测度的椭圆。


Ellipse with the same moments and area as the input region.


'outer_circle':包含区域的最小圆形。


'inner_circle':被区域包含的最大圆。


'rectangle1':最小包含矩形,平行于坐标轴。


'rectangle2':包含区域的最小矩形。


'inner_rectangle1': 适合区域大小的和区域最大长度方向一致的内矩形。


'inner_center':抽取内部骨架点,到区域中心距离最小

 
reduce_domain (Bond, Die, DieGrey)//重新用Die的区域定于图像Bond的定义域,并输出到DieGrey
threshold (DieGrey, Wires, , )//阈值处理
fill_up_shape (Wires, WiresFilled, 'area', , )//填充具有某种形状特征的区域,并输出填充区域。
形状特征包括:'area', 'compactness', 'convexity', 'anisometry', 'phi', 'ra', 'rb', 'inner_circle', 'outer_circle'
注: min表示符合填充的面积的最小值,max表示符合填充的面积的最大值。其他形状类同
opening_circle (WiresFilled, Balls, 15.5)//找到具有圆形结构的区域,并对圆形区域开运算,即先腐蚀再膨胀
closing_circle()是先膨胀后腐蚀
select_shape (ConnectedRegions, SelectedRegions['holes_num','rect2_len1','rect2_len2'], 'and', [,,], [,,])//选择符合数组内三个特征参数和分别在限定的区域内的 区域。操作符and与全部符合才算,or只要有一个就算
sort_region (IntermediateBalls, FinalBalls, 'first_point', 'true', 'column')//排序,按照第一个点的列排序
dev_set_colored ()//显示region 是用到的颜色数目
smallest_circle (FinalBalls, Row, Column, Radius)//计算最小外接圆的圆心坐标和半径
difference (SingleBalls, Rect, IntermediateBalls)//差异计算,计算两者的不同,并将不同的放在IntermediateBalls里
 gen_empty_region (Forbidden)//创建一个空的区域
expand_gray (IntermediateBalls, Bond, Forbidden, RegionExpand, , 'image', )//依据灰度值或颜色填充两个区域的间隙或分割重叠区域,
//将IntermediateBalls上大于6灰度值的像素全部画到Bond上,像素位置不变,并输出到RegionExpand