0
点赞
收藏
分享

微信扫一扫

halcon知识:edges_image和edges_sub_pix比较

棒锤_45f2 2022-02-11 阅读 192

一、说明

halcon中取区域边缘的算子很多,但是哪个效果更好,本文比较edges_image和edges_sub_pix进行对比

二、edges_image的示例代码

read_image (Image, 'D:/images/taps/gtape')
edges_image (Image, ImaAmp, ImaDir, 'lanser2', 0.5, 'nms', 12, 22)
threshold (ImaAmp, Edges, 1, 255)
skeleton (Edges, Skeleton)
gen_contours_skeleton_xld (Skeleton, Contours, 1, 'filter')
dev_display (Image)
dev_set_colored (6)
dev_display (Contours)

三、 edges_sub_pix函数

read_image (Image, 'D:/images/taps/gtape')
* 
* Init window
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle1)
* 
* Segment a region containing the edges
fast_threshold (Image, Region, 0, 140, 7)
boundary (Region, RegionBorder, 'inner')
* clip_region_rel (RegionBorder, RegionClipped, 5, 5, 5, 5)
dilation_circle (RegionBorder, RegionDilation, 2.5)
reduce_domain (Image, RegionDilation, ImageReduced)
* 
* In the subdomain of the image containing the edges,
* extract subpixel precise edges.
set_color(WindowHandle1, 'green')
*'deriche1', 'lanser1', 'deriche2', 'lanser2', 'shen', 'mshen', 'canny', 'sobel', and 'sobel_fast'
edges_sub_pix (ImageReduced, Edges, 'lanser2', 2, 20, 60)

四、结果分析

用edges_image的结果:

 edges_sub_pix的结果:

 可以看出,上边红线只是包络边缘,可以判定不能达到亚像素级别;edges_sub_pix的边缘横跨黑白之间,达到亚像素测量,edges_sub_pix测量时要好。

举报

相关推荐

0 条评论