对应示例程序:
surface_scratch.hdev
目标:通过图像预处理和形态学处理提取划痕
思路为:
1.读取图像
2.自动阈值分割
3.连通域分割,提取出面积最大的区域
4.形态学处理,得到干净的目标图像
5.进行显示
图像:
代码:
dev_update_off ()
dev_close_window ()
*
* Step 1: Acquire image 读取图像
*
read_image (Image, 'surface_scratch')
get_image_size (Image, Width, Height)
dev_open_window_fit_image (Image, 0, 0, Width, Width, WindowID)
set_display_font (WindowID, 16, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (4)
dev_display (Image)
Message := 'This program shows the extraction of'
Message[1] := 'surface scratches via local thresholding'
Message[2] := 'and morphological post-processing'
disp_message (Win