少有人走的路

勇哥的工业自动化技术网站

halcon处理:划痕、油污、瑕疵

划痕、油污、瑕疵,常用的方法有傅里叶变换和Blob分析。

1.表面划痕

invert_image(Image,ImageInvert1) 
mult_image(ImageInvert1, ImageInvert1, ImageResult,0.01, 0) 

gen_sin_bandpass (ImageBandpass, 0.6, 'none', 'rft', Width, Height)
rft_generic (ImageResult, ImageFFT, 'to_freq', 'none', 'complex', Width) 
convol_fft (ImageFFT, ImageBandpass, ImageConvol) 
rft_generic (ImageConvol, Lines, 'from_freq', 'n', 'byte', Width)

texture_laws (Lines, ImageTexture, 'el',3, 5)

为更好的突出前景,一般情况下要求背景颜色较深,可以先用invert_image算子进行灰度值转换。之后的图像相乘,是将对比度进一步扩大。

生成一个正弦形状的带通滤波器,可以去除图像中的噪声。然后傅里叶变换凸显出要检测的划痕。

texture_laws是纹理滤波,适用于布匹表面的划痕,是整个算法的关键所在。


2.亮点、暗点

*找到亮点
mean_image (ImageScaleMax, ImageMean, 9, 9)
dyn_threshold(ImageScaleMax,ImageMean,RegionDynThresh,5,'light' )
connection(RegionDynThresh,ConnectedRegions)

*找到暗点
mean_image(ImageScaleMax,ImageMean,7,7)
dyn_threshold(ImageScaleMax,ImageMean,RegionDynThresh1,5,'dark' )
connection(RegionDynThresh1,ConnectedRegions1)

平滑,动态阈值分割。


3.金属表面疤痕

* 加强图像的对比度
emphasize(Image,ImageEmphasize,Width, Height, 5)
threshold(ImageEmphasize, Region, 0, 5)
fill_up(Region, RegionFillUp2)
connection(RegionFillUp2, ConnectedRegions1)
select_shape(ConnectedRegions1, SelectedRegions2, 'area', 'and', 55000, 60000)
closing_circle(SelectedRegions2, RegionClosing, 13.5)

通过emphasize算子,增强图像对比度,当然前景的突出不仅仅只用这种方法。


4.油污

Sigma1 := 30.0 
Sigma2 := 5.0 
gen_gauss_filter (GaussFilter1, Sigma1, Sigma1, 0.0, 'none', 'rft', Width, Height) 
gen_gauss_filter (GaussFilter2, Sigma2, Sigma2, 0.0, 'none', 'rft', Width, Height) 
sub_image (GaussFilter1, GaussFilter2, Filter, 1, 0) 
rgb1_to_gray (Image, GrayImage) 
rft_generic (Image, ImageFFT, 'to_freq', 'none', 'complex', Width) 
convol_fft (ImageFFT, Filter, ImageConvol) 
rft_generic (ImageConvol, ImageFiltered, 'from_freq', 'n', 'real', Width) 
scale_image_range (ImageFiltered, ImageScaled, 0, 255)

与表面划痕相似,通过两次高斯滤波,结合傅里叶变换。scale_iamge_range算子的作用:Scale the gray values of an image from the interval [Min,Max] to [0,255]。可以将油污的灰度值凸显出来。


--------------------- 

作者:J-A 

来源:CSDN 

原文:https://blog.csdn.net/lxy_2011/article/details/48930285 

版权声明:本文为博主原创文章,转载请附上博文链接!

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

«    2026年1月    »
1234
567891011
12131415161718
19202122232425
262728293031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接

Powered By Z-BlogPHP 1.7.3

Copyright www.skcircle.com Rights Reserved.

鄂ICP备18008319号


站长QQ:496103864 微信:abc496103864