dev_get_window (WindowHandle)
dev_update_window ('off')
*生成高斯低通滤波器
gen_gauss_filter (Gauss1, 8, 8, 0, 'none', 'dc_center', 652, 494)
list_image_files ('./images', 'default', [], ImageFiles1)
imgNum:=|ImageFiles1|
for Index := 0 to imgNum-1 by 1
read_image (Image, ImageFiles1[Index])
*将原图转为频域
fft_generic (Image, ImageFFT, 'to_freq', -1, 'sqrt', 'dc_center', 'complex')
*使用滤波器滤波
convol_fft (ImageFFT, Gauss1, ImageConvol)
*将频域图转换成空域图
fft_image_inv (ImageConvol, ImageFFTInv)
*对原图进图像切割
dyn_threshold (Image, ImageFFTInv, RegionDynThresh, 8, 'dark')
*将不相连的区域独立出来
connection (RegionDynThresh, ConnectedRegions1)
*筛选出缺陷
select_shape (ConnectedRegions1, SelectedRegions, 'area', 'and', 408.07, 5000)
*获取每个缺陷的面积
area_c