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]。可以将油污的灰度值凸显出来。

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值