Blob分析---Circles.hdev(根据圆弧估算圆的参数并显示结果圆)

目录

一、程序源码分析

1、图像初始化

2、通过阈值分割,然后获取图像的边界,使用clip_region_rel算子对其进行裁剪,再以圆形膨胀分割出圆弧边界

 3、在包含边缘的图像子域中,提取亚像素精确边缘

4、根据每一段线条,对于圆的边, 估算圆的参数并显示结果圆

二、相关算子

1、fast_threshold(Image : Region : MinGray, MaxGray, MinSize : )

2、clip_region_rel(Region : RegionClipped : Top, Bottom, Left, Right : )

3、edges_sub_pix(Image : Edges : Filter, Alpha, Low, High : )

4、segment_contours_xld(Contours : ContoursSplit : Mode, SmoothCont, MaxLineDist1, MaxLineDist2 : )

5、get_contour_global_attrib_xld(Contour : : Name : Attrib)

6、fit_circle_contour_xld(Contours : : Algorithm, MaxNumPoints, MaxClosureDist, ClippingEndPoints, Iterations, ClippingFactor : Row, Column, Radius, StartPhi, EndPhi, PointOrder)

7、gen_circle_contour_xld( : ContCircle : Row, Column, Radius, StartPhi, EndPhi, PointOrder, Resolution : )


一、程序源码分析

图像中的边缘被分割成线和圆。对于圆的边, 估算圆的参数并显示结果圆

1、图像初始化

read_image (Image, 'double_circle')
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)

2、通过阈值分割,然后获取图像的边界,使用clip_region_rel算子对其进行裁剪,再以圆形膨胀分割出圆弧边界

fast_threshold (Image, Region, 0, 120, 7)
boundary (Region, RegionBorder, 'inner')
clip_region_rel (RegionBorder, RegionClipped, 5, 5, 5, 5)
dilation_circle (RegionClipped, RegionDilation, 2.5)
reduce_domain (Image, RegionDilation, ImageReduced)

ImageReduced---得到的弧形边界

 
3、在包含边缘的图像子域中,提取亚像素精确边缘

edges_sub_pix (ImageReduced, Edges, 'canny', 2, 20, 60)
segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 5, 4, 3)
count_obj (ContoursSplit, Number)

  • ContoursSplit是个元组,其中存放了分割出来的圆弧与线段

分割圆弧段与直线线段

 

4、根据每一段线条,对于圆的边, 估算圆的参数并显示结果圆

dev_display (Image)
dev_set_draw ('margin')
dev_set_color ('white')
dev_update_window ('off')

for I := 1 to Number by 1

  • 从ContoursSplit中循环读取轮廓,通过query_contour_global_attribs_xld算子得到该轮廓设置的全局参数为'cont_approx'
  • 然后通过get_contour_global_attrib_xld算子取参数的值,如果'cont_approx' = 1,可以用圆弧来近似等高线;如果'cont_approx'=-1,可以用线段来近似等高线
直线段
弧线段

    select_obj (ContoursSplit, ObjectSelected, I)
    *先找到为该段轮廓设置了哪些全局属性,再对其取值观察
    query_contour_global_attribs_xld(ObjectSelected, Attribs)
    get_contour_global_attrib_xld (ObjectSelected, 'cont_approx', Attrib)

  • 检测到该线段为弧线段,用圆近似XLD轮廓并生成圆

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

盾山狂热粉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值