1.提取Region中面积最大的区域:
region_feature(Conns,'area',Areas)
select_obj (Conns, ObjectMax, sort_index(-Areas)[0] + 1)
提取Region中面积第2大的区域
region_feature(Conns,'area',Areas)
select_obj (Conns, ObjectMax, sort_index(-Areas)[1] + 1)
...
提取Region中面积最小的区域:
region_feature(Conns,'area',Areas)
select_obj (Conns, ObjectMax, sort_index(Areas)[0] + 1)
提取Region中面积第2小的区域
region_feature(Conns,'area',Areas)
select_obj (Conns, ObjectMax, sort_index(Areas)[1] + 1)
sort_index(Area,Indice)算子讲解:先将Area中各元素按升序排序,然后将排序后的每一个Area分别在原Area元组中的索引放在元组Indice 中
Area: 420 12922 38019 58 2033
Sort: 58 420 2033 12922 38019
Indice: 3 0 4 1 2
因为是升序,所以找最小不需要取反,找最大需要取反
2.再halcon上写字的3种方式
2.1dev_disp_text (Message, 'window', 12, 12, 'black', [], [])
2.2set_tposition (WindowHandle, 12, 12) write_string (WindowHandle, 'OK')
2.3disp_message (WindowHandle, 'No Model found!', true, 25, 20, 'black', 'true')
3.region集
gen_empty_obj (Contour)
for()
{...
concat_obj (Contour, TemContour, Contour)
}
4.胶路检测关键字:bead
5.等差数列 Rows:=[5:10:50]等同于Rows:=[5, 15, 25, 35, 45]
生成特定数量的常数 Cols:=gen_tuple_const(10, 6)等同于Cols:=[6, 6, 6, 6, 6, 6, 6, 6, 6, 6] 生成10个6
6. tuple_select_mask 要求两个输入的元祖长度相同
IntTuple := [0,1,2,3,4,5]
tuple_select_mask (IntTuple, [0,1,0,1,0,1], SelectSome1)
SelectSome1的结果是IntTuple里面索引为1、3、5的集合
7.二值化
threshold (Image, Region1, 128, 255):经典二值化
fast_threshold (Image, Region, 128, 255, 10):快速二值化,相当于经典二值化后+面积判断,太小的不要
8.提取边界的两个算子
edges_sub_pix (ImageReduced, Edges, 'canny', 1.7, 40, 120) //对于canny算法:1.7越大则平滑越大,1.7越大则平滑越小,对于其他算法则相反;40和120越大,对边缘的要求越高越小对边缘的要求越低越容易提取出轮廓
threshold_sub_pix (ImageReduced, Border1, 128)
9.
10.测量模型
11.半透明显示
*透明度00~ff SegTransparency:='80' *颜色 color:=['#b91ff9'] dev_set_color (color + SegTransparency) dev_display (Region)