18、ROI相关算子
1、get_obj_class(Object : : : Class) 1
2、elliptic_axis(Regions : : : Ra, Rb, Phi) 1
3、elliptic_axis_xld(XLD : : : Ra, Rb, Phi) 2
4、get_region_points(Region : : : Rows, Columns) 3
5、get_contour_xld(Contour : : : Row, Col) 4
6、get_polygon_xld(Polygon : : : Row, Col, Length, Phi) 5
7、get_region_polygon(Region : : Tolerance : Rows, Columns) 6
8、select_region_point(Regions : DestRegions : Row, Column : ) 7
9、select_xld_point(XLDs : DestXLDs : Row, Column : ) 8
10、test_region_point(Regions : : Row, Column : IsInside) 9
11、test_xld_point(XLD : : Row, Column : IsInside) 10
12、paint_gray(ImageSource, ImageDestination : MixedImage : : ) 10
13、paint_region(Region, Image : ImageResult : Grayval, Type : ) 11
14、paint_xld(XLD, Image : ImageResult : Grayval : ) 12
15、area_center(Regions : : : Area, Row, Column) 13
16、area_center_xld(XLD : : : Area, Row, Column, PointOrder) 13
17、area_holes(Regions : : : Area) 13
18、gray_projections(Region, Image : : Mode : HorProjection, VertProjection) 14
19、intensity(Regions, Image : : : Mean, Deviation) 15
20、min_max_gray(Regions, Image : : Percent : Min, Max, Range) 16
21、shape_trans(Region : RegionTrans : Type : ) 17
22、shape_trans_xld(XLD : XLDTrans : Type : ) 18
23、sort_region(Regions : SortedRegions : SortMode, Order, RowOrCol : ) 18
24、sort_contours_xld(Contours : SortedContours : SortMode, Order, RowOrCol : ) 18
25、select_obj(Objects : ObjectSelected : Index : ) 18
26、concat_obj(Objects1, Objects2 : ObjectsConcat : : ) 对象既可以使region也可以是xld polygons、xld contours 19
27、copy_obj(Objects : ObjectsSelected : Index, NumObj : ) 20
28、edges_color_sub_pix(Image : Edges : Filter, Alpha, Low, High : ) 21
29、smooth_contours_xld(Contours : SmoothedContours : NumRegrPoints : ) 22
31、get_contour_global_attrib_xld(Contour : : Name : Attrib) 23
32、smallest_circle(Regions : : : Row, Column, Radius) 24
33、smallest_circle_xld(XLD : : : Row, Column, Radius) 24
34、smallest_rectangle1(Regions : : : Row1, Column1, Row2, Column2) 25
35、smallest_rectangle1_xld(XLD : : : Row1, Column1, Row2, Column2) 25
36、smallest_rectangle2(Regions : : : Row, Column, Phi, Length1, Length2) 25
37、smallest_rectangle2_xld(XLD : : : Row, Column, Phi, Length1, Length2) 26
38、count_obj(Objects : : : Number) 26
39、select_shape(Regions : SelectedRegions : Features, Operation, Min, Max : ) 26
40、select_shape_std(Regions : SelectedRegions : Shape, Percent : ) 27
41、select_shape_xld(XLD : SelectedXLD : Features, Operation, Min, Max : ) 28
42、select_contours_xld(Contours : SelectedContours : Feature, Min1, Max1, Min2, Max2 : ) 29
43、region_to_bin(Region : BinImage : ForegroundGray, BackgroundGray, Width, Height : ) 29
44、clip_contours_xld(Contours : ClippedContours : Row1, Column1, Row2, Column2 : ) 30
45、clip_region(Region : RegionClipped : Row1, Column1, Row2, Column2 : ) 31
46、write_contour_xld_arc_info(Contours : : FileName : ) 32
47、read_contour_xld_arc_info( : Contours : FileName : ) 32
48、write_contour_xld_dxf(Contours : : FileName : ) 32
49、read_contour_xld_dxf( : Contours : FileName, GenParamNames, GenParamValues : DxfStatus) 32
50、dev_display(Object : : : ) 32
1、get_obj_class(Object : : : Class)
功能:获取图像对象的类名(常见的类名有'image' 'region' 'xld_cont' 'xld_poly' 'xld_parallel')
read_image(Image,'lena')
draw_polygon (PolygonRegion, 3600)
gen_contour_region_xld (PolygonRegion, Contours, 'border')
gen_polygons_xld (Contours, Polygons2, 'ramer', 2)
get_obj_class (Image, Class0)
get_obj_class (PolygonRegion, Class1)
get_obj_class (Contours, Class2)
get_obj_class (Polygons2, Class3)
2、elliptic_axis(Regions : : : Ra, Rb, Phi)
draw_region (Region, 3600)//绘制region
elliptic_axis (Region, Ra, Rb, Phi)//计算等效椭圆
gen_ellipse (Ellipse, 140, 437, Phi, Ra, Rb)//把这个等效椭圆绘制出来
作用:再进行特征筛选时,可以知道每个region的椭圆相关参数,从而选择适当的值进行筛选
3、elliptic_axis_xld(XLD : : : Ra, Rb, Phi)
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
elliptic_axis_xld (ContOut, Ra, Rb, Phi)
gen_ellipse (Ellipse, 140, 437, Phi, Ra, Rb)
4、get_region_points(Region : : : Rows, Columns)
get_region_points (Region, Rows, Columns)
5、get_contour_xld(Contour : : : Row, Col)
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
get_contour_xld (ContOut, Row, Col)
6、get_polygon_xld(Polygon : : : Row, Col, Length, Phi)
Polygon:输入多边形
Length:点i和点i+1之间的线段长度
Phi:点i和点i+1之间的线段的角度
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
gen_polygons_xld (ContOut, Polygons, 'ramer', 2)
get_polygon_xld (Polygons, Row, Col, Length, Phi)
7、get_region_polygon(Region : : Tolerance : Rows, Columns)
get_region_polygon (Region, 5, Rows, Columns)
gen_region_polygon (Region1, Rows, Columns)
8、select_region_point(Regions : DestRegions : Row, Column : )
concat_obj (Region1, Region2, ObjectsConcat)//连接区域
select_region_point (ObjectsConcat, DestRegions, 123, 137)
9、select_xld_point(XLDs : DestXLDs : Row, Column : )
draw_xld (XLD1, 3600, 'true', 'true', 'true', 'true')
draw_xld (XLD2, 3600, 'true', 'true', 'true', 'true')
concat_obj (XLD1, XLD2, UNION_XLD)//连接区域
select_xld_point (UNION_XLD, DestXLDs,128, 155)
10、test_region_point(Regions : : Row, Column : IsInside)
test_region_point (Region, 138, 249, IsInside)
11、test_xld_point(XLD : : Row, Column : IsInside)
12、paint_gray(ImageSource, ImageDestination : MixedImage : : )
decompose3 (Image, R, G, B)//分离三通道
get_image_size (B, Width, Height)//获取图片大小
gen_image_const (Image2, 'byte', Width, Height)//创建一张空图片
paint_gray (B, Image2, MixedImage)//把B通道的灰度值绘制到空图片上
13、paint_region(Region, Image : ImageResult : Grayval, Type : )
Image:输入图像必须是单通道的灰度图
Grayval:填充的像素值
Type:以填充还是线条的方式
read_image (Image, 'lena')
decompose3 (Image, R, G, B)
draw_region (Region, 3600)
paint_region (Region, R, ImageResult, 50, 'fill')
注:最后的结果是一个整体的图像
14、paint_xld(XLD, Image : ImageResult : Grayval : )
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
paint_xld (ContOut, B, ImageResult, 255)
15、area_center(Regions : : : Area, Row, Column)
16、area_center_xld(XLD : : : Area, Row, Column, PointOrder)
17、area_holes(Regions : : : Area)
difference (Region1, Region2, Difference)//差集,使其产生孔洞
area_holes (Difference, Area)//计算孔洞的面积
18、gray_projections(Region, Image : : Mode : HorProjection, VertProjection)
draw_line (3600, Row1, Column1, Row2, Column2)
gen_region_line (RegionLines, Row1, Column1, Row2, Column2)
gray_projections (RegionLines, Image, 'simple', HorProjection, VertProjection)
19、intensity(Regions, Image : : : Mean, Deviation)
intensity (Region, Image, Mean, Deviation)
20、min_max_gray(Regions, Image : : Percent : Min, Max, Range)
min_max_gray (Region, Image, 0, Min, Max, Range)
21、shape_trans(Region : RegionTrans : Type : )
read_image (Image, 'C:/picture/1.jpg')
rgb1_to_gray (Image, GrayImage)
threshold (GrayImage, Regions1, 91, 255)
shape_trans (Regions1, RegionTrans, 'convex')
22、shape_trans_xld(XLD : XLDTrans : Type : )
功能:轮廓后多边形xld形状转换,跟21中的region类似
23、sort_region(Regions : SortedRegions : SortMode, Order, RowOrCol : )
SortMode:排序的模式
Order:升序还是降序
RowOrCol:先按行排列还是先按列排
例子:参考例程:ball.hdev
24、sort_contours_xld(Contours : SortedContours : SortMode, Order, RowOrCol : )
25、select_obj(Objects : ObjectSelected : Index : )
concat_obj (Region1, Region2, Concat12)//连接12区域
concat_obj (Concat12, Region3, Concat123)//连接123区域
select_obj (Concat123, Selected, 2)//选择第二个区域
26、concat_obj(Objects1, Objects2 : ObjectsConcat : : ) 对象既可以使region也可以是xld polygons、xld contours
concat_obj (re1, re2, ObjectsConcat)
gen_circle_contour_xld (ContCircle1, 200, 200, 100, 0, 1, 'positive', 1)
gen_circle_contour_xld (ContCircle, 200, 200, 100, 2, 3, 'positive', 1)
concat_obj (ContCircle1, ContCircle, ObjectsConcat)
27、copy_obj(Objects : ObjectsSelected : Index, NumObj : )
Index:起始索引
NumObj:数量
concat_obj (Region1, Region2, Concat12)//连接12区域
concat_obj (Concat12, Region3, Concat123)//连接123区域
copy_obj (Concat123, ObjectsSelected, 1, 2)
28、edges_color_sub_pix(Image : Edges : Filter, Alpha, Low, High : )
功能:使用Deriche,Lanser,Shen,Canny滤波器提取亚像素精度边缘
Filter:提取边缘的滤波器,默认为'canny'
Alpha:平滑滤波参数。值越小滤波效果越强,获得的边缘细节越少。对于'canny',刚好相反,值喜悦小,滤波
效果越落,获得边缘细节越多。
Low:输入磁滞阈值操作的低阈值
High:输入磁滞阈值操作的高阈值
read_image (Image123, 'C:/123.JPG')
edges_color_sub_pix (Image123, Edges, 'canny', 10, 50, 200)
磁滞阈值说明:例如在canny中,它是基于sobel边缘。即canny算子中有两个磁滞阈值,一个是低阈值,一个是高阈值,这个两个阈值分别对图片进行sobel边缘检测,在低阈值的结果图像有,由于使用宽松阈值,不必要的边缘也被检测到;高阈值中得到的是重要轮廓边缘。Canny算子就是综合低阈值和高阈值的结果得到最后的结果即如果存在连续的边缘路径,将低阈值图像中的边缘点与高阈值图像中的边缘边相连接,那么这样高阈值图像中所有的边缘点保存下来,同事移除低阈值图像中所有的孤立的边缘点。
29、smooth_contours_xld(Contours : SmoothedContours : NumRegrPoints : )
NumRegrPoints:输入用于计算结果中回归线的点的个数
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
smooth_contours_xld (ContOut, SmoothedContours, 5)
30、segment_contours_xld(Contours : ContoursSplit : Mode, SmoothCont, MaxLineDist1, MaxLineDist2 : )
Mode:分割模式'line'直线 'line-circles'直线和圆 'lines_ellipses'直线和椭圆
MaxLineDist1:第一次迭代运算时,轮廓和相似线(回归线)的最大距离
MaxLineDist2:第二次迭代********
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
segment_contours_xld (ContOut, ContoursSplit, 'lines_circles', 5, 4, 2)
31、get_contour_global_attrib_xld(Contour : : Name : Attrib)
注:Name = 'cont_approx' Attrib = -1 ,输入轮廓与直线最相似;Attrib = 0,输入轮廓与椭圆弧最相似;Attrib
32、smallest_circle(Regions : : : Row, Column, Radius)
smallest_circle (Region, Row, Column, Radius)
gen_circle (Circle, Row, Column, Radius)
33、smallest_circle_xld(XLD : : : Row, Column, Radius)
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
smallest_circle_xld (ContOut, Row, Column, Radius)
gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, 6.28318, 'positive', 1)
34、smallest_rectangle1(Regions : : : Row1, Column1, Row2, Column2)
smallest_rectangle1 (Region, Row1, Column1, Row2, Column2)
gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
35、smallest_rectangle1_xld(XLD : : : Row1, Column1, Row2, Column2)
36、smallest_rectangle2(Regions : : : Row, Column, Phi, Length1, Length2)
smallest_rectangle2 (Region, Row, Column, Phi, Length1, Length2)
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
37、smallest_rectangle2_xld(XLD : : : Row, Column, Phi, Length1, Length2)
38、count_obj(Objects : : : Number)
concat_obj (Region1, Region2, Concat12)//连接12区域
concat_obj (Concat12, Region3, Concat123)//连接123区域
39、select_shape(Regions : SelectedRegions : Features, Operation, Min, Max : )
这个算子是结合特征直方图使用,可以选择多种特征来筛选,Operation参数表示这些特征的连接模式是AND 还
是OR 。
注:具体每个特征在《Halcon工业应用实用教程 第二册》 378页中详细介绍
灰度直方图操作的是region对象,并不支持廓
40、select_shape_std(Regions : SelectedRegions : Shape, Percent : )
功能:根据指定形状选择区域,算子对比自身的区域和指定的形状,若在Percent相似度之内则把它输出
Regions:输入区域
SelectedRegions:输出区域
Shape:指定形状特征
'max_area' :选择最大面积的区域
'rectangle1' :如果区域和最小外接齐轴矩形的相似度大于Percent,则把该区域作为输出
'rectangle2':如果区域和最小外接仿射矩形的相似度大于Percent,则把该区域作为输出
Percent:相似性度量
draw_region (Region1, 3600)
draw_region (Region2, 3600)
draw_region (Region3, 3600)
concat_obj (Region1, Region2, Concat12)//连接12区域
concat_obj (Concat12, Region3, Concat123)//连接123区域
select_shape_std (Concat123, SelectedRegions, 'rectangle1', 85)
注:详细在《Halcon工业应用实用教程 第二册》 381详细介绍
41、select_shape_xld(XLD : SelectedXLD : Features, Operation, Min, Max : )
Features:指定形状特征
Operation:and or
draw_xld (XLD1, 3600, 'true', 'true', 'true', 'true')
draw_xld (XLD2, 3600, 'true', 'true', 'true', 'true')
draw_xld (XLD3, 3600, 'true', 'true', 'true', 'true')
concat_obj (XLD1, XLD2, XLD12)//连接12xld
concat_obj (XLD12, XLD3, XLD123)//连接123xld
select_shape_xld (XLD123, SelectedXLD, 'width', 'and', 300, 400)
注:详细在《Halcon工业应用实用教程 第二册》 381详细介绍
42、select_contours_xld(Contours : SelectedContours : Feature, Min1, Max1, Min2, Max2 : )
Feature:'contour_length'
'maximum_extent'
'direction'
'curvature'
'closed'
'open'
这个算子使用了双阈值模式,它的特征只限于上面6个。在上面六个的特征中,有一些特征如'closed'等参数。Max1,
Min2, Max2对它无效。具体那个阈值对那个特征有效要看说明文档。
例子:
如在说明文档中的'closed':
only contours for which the distance between their start point and their end point is less or equal Max1 pixels are returned. (Min1, Min2 and Max2 have no influence here.)
即是说当选择为'closed'特征时,输入的xld数组可以不是全封闭的,只要符合首点跟末点的距离小于
draw_xld (ContOut1, 3600, 'true', 'true', 'true', 'true')
draw_xld (ContOut2, 3600, 'true', 'true', 'true', 'true')
concat_obj (ContOut1, ContOut2, ObjectsConcat)
select_contours_xld (ObjectsConcat, SelectedContours, 'closed', 50, 50, 50, 50)
43、region_to_bin(Region : BinImage : ForegroundGray, BackgroundGray, Width, Height : )
region_to_bin (Region, BinImage, 255, 0, 512, 512)
44、clip_contours_xld(Contours : ClippedContours : Row1, Column1, Row2, Column2 : )
功能:根据矩形剪裁xld轮廓,矩形以内的轮廓线作为输出(与矩形相交的不输出)
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
draw_rectangle1 (3600, Row1, Column1, Row2, Column2)
gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
clip_contours_xld (ContOut, ClippedContours, Row1, Column1, Row2, Column2)
45、clip_region(Region : RegionClipped : Row1, Column1, Row2, Column2 : )
draw_rectangle1 (3600, Row1, Column1, Row2, Column2)
gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
clip_region (Region, out, Row1, Column1, Row2, Column2)
46、write_contour_xld_arc_info(Contours : : FileName : )
功能:把xld轮廓用ARC/INFO生成格式保存为 .gen文件
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
write_contour_xld_arc_info (ContOut, 'C:/1.gen')
47、read_contour_xld_arc_info( : Contours : FileName : )
48、write_contour_xld_dxf(Contours : : FileName : )
draw_xld (ContOut, 3600, 'true', 'true', 'true', 'true')
write_contour_xld_dxf (ContOut, 'C:/11.dxf')
49、read_contour_xld_dxf( : Contours : FileName, GenParamNames, GenParamValues : DxfStatus)










浙公网安备 33010602011771号