ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

【图像处理】 Halcon 实现亚像素边缘检测

2021-11-30 10:00:52  阅读:205  来源: 互联网

标签:轮廓 set Image xld dev 像素 图像处理 circle Halcon


目录

1 Halcon软件使用简要指导

halcon的函数调用,返回值变量在()参数中去定义,比如我要初始化一个用Test(A,B)函数实现某个功能,A 是传入的参数,B是返回值参数。

在这里插入图片描述

3 实现

边缘检测,轮廓拟合,并对轮廓进行彩色绘图

*读取图片
read_image (Image, 'Pic1_1.bmp')
* 关闭窗口
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
* 
* Segment a region containing the edges
*基于全局阈值的图像快速阈值化
fast_threshold (Image, Region, 0, 120, 7)
*获取一个边界区域
boundary (Region, RegionBorder, 'inner')

*用圆形结构元素扩张一个区域。
dilation_circle (RegionBorder, RegionDilation, 3.5)

*获得特定区域Region位置的图像
reduce_domain (Image, RegionDilation, ImageReduced)
* 
* In the subdomain of the image containing the edges,
* extract subpixel precise edges.
*提取亚像素精密边缘轮廓
edges_sub_pix (ImageReduced, Edges, 'canny', 2, 20, 60)

*将一个XLD轮廓分割为直线段、圆(圆弧)、椭圆弧
segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 5, 4, 3)
* dev_display (Edges)

*计算个数
count_obj (ContoursSplit, Number)
dev_display (Image)

*定义region填充模式
dev_set_draw ('margin')
dev_set_color ('white')
dev_update_window ('off')
for I := 1 to Number by 1
    *选择一个元素
    select_obj (ContoursSplit, ObjectSelected, I)
    
    *返回XLD轮廓的全局属性值
    get_contour_global_attrib_xld (ObjectSelected, 'cont_approx', Attrib)
    * Fit a circle to the line segment that are arcs of a circle
    if (Attrib > 0)
         
        *用圆近似XLD轮廓
        fit_circle_contour_xld (ObjectSelected, 'ahuber', -1, 2, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)
         
        *创建对应于圆或圆弧的XLD轮廓
        gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, rad(360), 'positive', 1.0)
    endif
endfor
dev_set_colored (12)
dev_set_line_width (3)
dev_display (ContoursSplit)

检测效果如下
在这里插入图片描述

标签:轮廓,set,Image,xld,dev,像素,图像处理,circle,Halcon
来源: https://blog.csdn.net/weixin_43935696/article/details/121624756

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有