• 边缘提取二—实例 行远


     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,需要加强理解,比那个好用。
     
  • 相关阅读:
    第二次作业——结对项目需求分析与原型设计
    调研《构建之法》指导下的历届作品
    软件工程的实践项目课程的自我目标
    使用@Scheduled注解做定时任务
    ng2中的百度echarts3.0使用——(echarts-ng2)
    angular-cli.json配置参数解释,以及依稀常用命令的通用关键参数解释
    SpringData实现Mongodb的CRUD:MongoTemplate框架
    idea利用jdbc连接ORACLE数据库实现一个查询显示
    dbvisualizer的使用
    DUBBO开发问题:添加无法生成主键
  • 原文地址:https://www.cnblogs.com/xingyuanzier/p/16124072.html
Copyright © 2020-2023  润新知