首页 > 代码库 > Halcon 10.0:Sample 分割边缘拟合圆Circles.hdev
Halcon 10.0:Sample 分割边缘拟合圆Circles.hdev
处理流程:快速二值化(区域)->获取区域边缘->截取边缘->膨胀边缘区域(定位)->定位区域进行边缘检测->边缘分割:线和圆->选择属性为圆的弧->拟合圆
*读取图像read_image (Image, ‘double_circle‘)dev_close_window ()get_image_size (Image, Width, Height)dev_open_window (0, 0, Width, Height, ‘black‘, WindowHandle)*快速二值化fast_threshold (Image, Region, 0, 120, 7)*取region的边界boundary (Region, RegionBorder, ‘inner‘)*剪切、膨胀定位弧形区域clip_region_rel (RegionBorder, RegionClipped, 5, 5, 5, 5)dilation_circle (RegionClipped, RegionDilation, 2.5)reduce_domain (Image, RegionDilation, ImageReduced)*在弧形区域进行边缘检测edges_sub_pix (ImageReduced, Edges, ‘lanser2‘, 0.5, 40, 60)*分割边缘:线和圆segment_contours_xld (Edges, ContoursSplit, ‘lines_circles‘, 5, 4, 3)count_obj (ContoursSplit, Number)dev_display (Image)dev_set_draw (‘margin‘)dev_set_color (‘white‘)dev_update_window (‘off‘)for i := 1 to Number by 1 *选择轮廓并根据特性确定是否拟合圆:* Attrib = -1 线段 0 椭圆 1圆 select_obj (ContoursSplit, ObjectSelected, i) get_contour_global_attrib_xld (ObjectSelected, ‘cont_approx‘, Attrib) if (Attrib > 0) *逼近结果生成一个圆轮廓 fit_circle_contour_xld (ObjectSelected, ‘ahuber‘, -1, 2, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder) gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, rad(360), ‘positive‘, 1.0) dev_display (ContCircle) endifendfordev_set_colored (12)dev_set_line_width (3)dev_display (ContoursSplit)
Halcon 10.0:Sample 分割边缘拟合圆Circles.hdev
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。