1. 选择的素材
第二步:编写halcon代码
* This programm shows the extraction of surface scratches via
* local thresholding and morphological post-processing
*
dev_update_off ()
dev_close_window ()
*
* Step 1: Acquire image
*
* 读取图片
read_image(Image,'/data/home/hfg/photo/2023-01-10/8059523121337139678.jpg')
* 获取图片信息
get_image_size (Image, Width, Height)
* 打开窗口
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
* 显示图片
dev_display (Image)
* 通过灰度计算分割区域
threshold (Image, Region, 128, 255)
* 进行打散
connection (Region, ConnectedRegions)
* 进行区域选择
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 329231, 330000)