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

 

*读取图像
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)

 

 

posted on 2014-10-24 15:30  浪迹枫叶  阅读(9600)  评论(0编辑  收藏  举报