对应示例程序:
find_scratches_bandpass_fft.hdev
目标:实现不均匀光照的表面缺陷。
思路为:
先创建一个合适的带通滤波器,然后把图像(例程做了图像反转)傅里叶变换在频域滤波,加强高频部分,然后变回时域做形态学处理,最后通过line_gauss检测出缺陷。
图像:
代码:
dev_update_off ()
dev_close_window ()
read_image (Image, 'surface_scratch')
invert_image (Image, ImageInverted) //反转图像
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_display (Image)
*
* Optimize the speed of the fast fourier transform
* Message := 'Optimize the speed of the fast fourier transform.'
* Message[1] := 'Please wait...'
* disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
* optimize_rft_speed (Width, Height, 'standard')
* disp_continue_message (WindowHandle, 'black', 'true')
* stop ()
*
*