• 边缘提取二—实例 行远


     1 read_image (DoubleCircle, 'E:/学习/Halcon/玩套路之边缘检测/玩套路之边缘检测/DoubleCircle/double_circle.png')
     2 
     3 *获取ROI区域
     4 threshold (DoubleCircle, Regions, 0, 39)
     5 connection(Regions, ConnectedRegions)
     6 select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 99687.5, 200000)
     7 *形态学处理
     8 dilation_circle(SelectedRegions, RegionDilation, 5.5)
     9 * erosion_circle(SelectedRegions, RegionErosion, 5.5)
    10 * closing_circle(SelectedRegions, RegionClosing, 15.5)
    11 
    12 * difference(RegionDilation, RegionErosion, RegionDifference)
    13 *fill_up(RegionDifference, RegionFillUp)
    14 closing_circle(SelectedRegions, RegionClosing, 5.5)
    15 difference(RegionDilation, RegionClosing, RegionDifference)
    16 
    17 reduce_domain(DoubleCircle, RegionDifference, ImageReduced)
    18 
    19 edges_sub_pix(ImageReduced, Edges, 'canny',1.5, 5, 40)
    20 smooth_contours_xld(Edges, SmoothedContours, 3)
    21 segment_contours_xld(SmoothedContours, ContoursSplit, 'lines_circles', 5, 4, 2)
    22 count_obj(ContoursSplit, Number)
    23 dev_clear_window()
    24 dev_display(ImageReduced)
    25 dev_display(ContoursSplit)
    26 for I:=0 to Number-1 by 1
    27         select_obj(ContoursSplit, ObjectSelected, I+1)
    28         get_contour_global_attrib_xld(ObjectSelected, 'cont_approx', Attrib)
    29         if(Attrib == -1)
    30             fit_line_contour_xld(ObjectSelected, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
    31             dev_set_color('red')
    32             disp_line(3600, RowBegin, ColBegin, RowEnd, ColEnd)
    33         elseif(Attrib == 1)
    34             fit_circle_contour_xld(ObjectSelected, 'algebraic', -1, 0, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)          
    35             dev_set_color('green')
    36             dev_set_draw('margin')
    37             gen_circle(Circle, Row, Column, Radius)
    38         endif
    39 endfor

     此例就是按照上篇方法对轮廓的提取,

    edges_sub_pix(ImageReduced, Edges, 'canny',1.5, 5, 40) 此算子,参数如何设置没有太多的理解。
    get_contour_global_attrib_xld,算子第一次使用,感觉不同于上篇中提到的get_contour_attrib_xld,需要加强理解,比那个好用。
     
  • 相关阅读:
    [Linear Algebra] Inverse and Transpose
    使用vue-cli4快速搭建项目环境、使用webpack4打包自己的library类库、封装vue插件并发布
    Python多线程批量Ping主机IP的脚本
    rk3288 系统设置中无法正常使用wifi分析
    chrome 修改为linux的ua
    js生成用户编号(时间戳+随机数)
    【软考】信息系统开发方法
    【软考】信息安全审计
    【软考】信息系统安全等级保护
    【软考】软件测试
  • 原文地址:https://www.cnblogs.com/xingyuanzier/p/16124072.html
Copyright © 2020-2023  润新知