像这种轻微划痕,普通算法鲁棒性差,通用性也不是很好,通过一些特殊处理,基本上可以满足客户需求.
图像处理,检测无非这个几个步骤.
预处理----分割----筛选—满足设定条件NG
read_image (Image, ‘轻微划痕.bmp’)
dev_close_window()
get_image_size(Image, Width, Height)
dev_open_window(0, 0, Width, Height, ‘black’, WindowHandle)
set_display_font(WindowHandle, 16, ‘mono’, ‘true’, ‘false’)
dev_set_line_width(2)
dev_display(Image)
disp_continue_message(WindowHandle, ‘black’, ‘true’)
stop()
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)
mean_image(ImageTexture, ImageMean,5, 30)
dyn_threshold(ImageTexture, ImageMean, RegionDynThresh, 20, ‘light’)
connection(RegionDynThresh, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, ‘area’, ‘and’, 44.08, 587)
union1(SelectedRegions, RegionUnion)
closing_circle(RegionUnion, RegionClosing, 6)
skeleton(RegionClosing, Skeleton)
dev_display(Image)
dev_set_color(‘red’)
dev_display(Skeleton)
stop()
多的不说,直接看代码,学习是一个过程,熟能生巧就是这么来的,坚持学习一项技能,才能有容身之地.