zoukankan      html  css  js  c++  java
  • 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)
        endif
    endfor
    dev_set_colored (12)
    dev_set_line_width (3)
    dev_display (ContoursSplit)

     

     

  • 相关阅读:
    网络知识===wireshark抓包,三次握手分析
    网络知识===关于MAC地址和IP不能互相替代,缺一不可的原因
    网络知识===《图解TCP/IP》学习笔记——网络的构成要素
    python基础===获取知乎标题时候,文件编码失败的总结
    Java——新IO 通道
    Java——新IO 缓冲区与Buffer
    Java——UDP
    Java——TCP
    Java——URLEncoder和URLDecoder
    Linux学习笔记<三>
  • 原文地址:https://www.cnblogs.com/ljfy-yjw/p/4048463.html
Copyright © 2011-2022 走看看