码迷,mamicode.com
首页 > 其他好文 > 详细

Halcon 10.0:Sample 分割边缘拟合圆Circles.hdev

时间:2014-10-24 16:09:56      阅读:921      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   for   sp   

处理流程:快速二值化(区域)->获取区域边缘->截取边缘->膨胀边缘区域(定位)->定位区域进行边缘检测->边缘分割:线和圆->选择属性为圆的弧->拟合圆

 

*读取图像
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)
    endif
endfor
dev_set_colored (12)
dev_set_line_width (3)
dev_display (ContoursSplit)

 

bubuko.com,布布扣bubuko.com,布布扣

 

Halcon 10.0:Sample 分割边缘拟合圆Circles.hdev

标签:style   blog   http   color   io   os   ar   for   sp   

原文地址:http://www.cnblogs.com/ljfy-yjw/p/4048463.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!