康耐德智能

 有光必有源,康耐德视觉光源!

 服务热线:0769-28680919   手机:15322933971

图片展示
搜索

更多资讯

分类标题

关注康耐德智能

         

电话:0769-28680919

传真:0769-28680910

邮箱:csray@csray.com

地址:东莞市南城区天安数码城C2栋507室


基于Halcon亚像素精度的边缘提取学习

作 者:康耐德智能关注:662发表时间:2018-10-24 09:21:39来源:原创

本文主要围绕Halcon的边缘提取中的两个算子Lines_gaussedges_sub_pix展开学习

1. Lines_gauss

该算子检测图像中线条及其宽度被广泛应用;

Signature

lines_gauss(Image : Lines : Sigma, Low, High, LightDark, ExtractWidth, LineModel, CompleteJunctions : )

Image:输入图像

Lines:提取出的亚像素精度线条

Sigma:应用的高斯平滑的系数

Low:后滞阈值分割的低值

High:后滞阈值分割的高值

LightDark:提取图像中的亮色或者暗色线条

ExtractWidth:是否提取线条的宽度

LineModel:提取线条的模式,有'none', 'bar-shaped', 'parabolic', 'gaussian'四种

CompleteJunctions:是否添加能够提取的接合点

 

Halcon例程1

提取前图片                                             

  

提取后图片

                                 

Halcon code

read_image (Angio, 'angio-part')

dev_set_color ('blue')

MaxLineWidth := 8

Contrast := 12

calculate_lines_gauss_parameters (MaxLineWidth, [Contrast,0], Sigma, Low, High)

lines_gauss (Angio, Lines, Sigma, Low, High, 'dark', 'true', 'parabolic', 'true')

Halcon例程2

提取前图片                                              

   

提取后图片

Halcon code

* Read an aerial image

read_image (Image, 'mreut4_3')

* Segment the image and reduce the domain

threshold (Image, Region, 160, 255)

reduce_domain (Image, Region, ImageReduced)

* Detect the lines that represent the road centers

MaxLineWidth := 5

Contrast := 70

calculate_lines_gauss_parameters (MaxLineWidth, Contrast, Sigma, Low, High)

lines_gauss (ImageReduced, RoadCenters, Sigma, Low, High, 'light', 'true', 'bar-shaped', 'true')

dev_set_color ('red')

dev_display (Image)

dev_display (RoadCenters)

2. edges_sub_pix

改算子用于精确边缘提取的亚像素(灰度图像)

Signature

edges_sub_pix(Image : Edges : Filter, Alpha, Low, High : )

Image (input_object)  :Input image.

Edges: Extracted edges.

Filter (input_control): Edge operator to be applied.

Alpha (input_control): Filter parameter: small values result in strong smoothing, and thus less detail (opposite for 'canny').

Low (input_control): Lower threshold for the hysteresis threshold operation.

High (input_control): Upper threshold for the hysteresis threshold operation.

 

Halcon例程3

提取前图片                                              

  

提取后图片

Halcon Code

read_image (Image, 'metal-parts/metal-parts-01')

threshold (Image, Region, 100, 255)

boundary (Region, RegionBorder, 'inner')

dilation_circle (RegionBorder, RegionDilation, 1.5)

reduce_domain (Image, RegionDilation, ImageReduced)

edges_sub_pix (ImageReduced, Edges, 'lanser2', 0.5, 40, 90)

segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 6, 4, 4)

sort_contours_xld (ContoursSplit, SortedContours, 'upper_left', 'true', 'column')

dev_clear_window ()

dev_display (Image)

dev_set_colored (12)

dev_display (SortedContours)

 

 

Halcon例程4

提取前图片                                               

 

提取后图片

                                

Halcon code

read_image (Rim, 'rim')

* To find the holes, we first segment the dark regions

threshold (Rim, Dark, 0, 128)

* Determine all connected components

connection (Dark, DarkRegions)

* Select regions with circular shape and an area larger than 50 pixel

select_shape (DarkRegions, Circles, ['circularity','area'], 'and', [0.85,50], [1.0,99999])

* To extract a region that contains just the edges of the circles

* use dilation and erosion.

dilation_circle (Circles, ROIOuter, 8.5)

erosion_circle (Circles, ROIInner, 8.5)

difference (ROIOuter, ROIInner, ROI)

union1 (ROI, ROIEdges)

dev_set_draw ('margin')

* Reduce the region of interest (domain) to the extracted

* regions containing the edges.

reduce_domain (Rim, ROIEdges, RimReduced)

* Extract subpixel precise edges

edges_sub_pix (RimReduced, Edges, 'canny', 4, 20, 40)

* Select only the contours with length larger than 30 pixels

select_contours_xld (Edges, RelEdges, 'length', 30, 999999, 0, 0)

dev_display (Rim)

dev_set_colored (12)

dev_display (RelEdges)

 

概念介绍

1、何谓亚像素?

 

面阵摄像机的成像面以像素为小单位。例如某CMOS摄像芯片,其像素间距为5.2微米。摄像机拍摄时,将物理世界中连续的图像进行了离散化处理。到成像面上每一个像素点只代表其附近的颜色。至于“附近”到什么程度?就很困难解释。两个像素之间有5.2微米的距离,在宏观上可以看作是连在一起的。但是在微观上,它们之间还有无限的更小的东西存在。这个更小的东西我们称它为“亚像素”。实际上“亚像素”应该是存在的,只是硬件上没有个细微的传感器把它检测出来。于是软件上把它近似地计算出来。为了大限度利用图像信息来提高分辨率,有人提出了Sub-Pixel概念。意思是说,在两个物理像素之间还有像素,称之为Sub-Pixel

 

2、何谓亚像素精度?

亚像素精度是指相邻两像素之间细分情况。输入值通常为二分之一,三分之一或四分之一。这意味着每个像素将被分为更小的单元从而对这些更小的单元实施插值算法。例如,如果选择四分之一,就相当于每个像素在横向和纵向上都被当作四个像素来计算。

广东省东莞市南城区黄金路1号天安数码城C2-507

电话:0769-28680919

手机:15322933971

邮箱:csray@csray.com

版权所有:东莞康耐德智能控制有限公司

粤ICP备18080826号-1

在线客服
联系方式
热线电话
0769-28680919
手机服务
15322933971
上班时间
周一到周五
二维码
二维码
在线客服