Halcom 发表于 2018-6-13 22:22:23

分水岭分割

分水岭分割:
dev_update_off ()
dev_set_draw ('margin')
Path := 'lcd/mura_defects_texture_'
read_image (Image, Path + '01')
get_image_size (Image, Width, Height)
* 测试图像
read_image (Image, Path + '01')
decompose3 (Image, R, G, B)
* 高斯带阻滤波器
get_image_size (B, Width, Height)
rft_generic (B, ImageFFT, 'to_freq', 'none', 'complex', Width)
gen_gauss_filter (ImageGauss, 50, 50, 0, 'n', 'rft', Width, Height)
convol_fft (ImageFFT, ImageGauss, ImageConvol)
rft_generic (ImageConvol, ImageFFT1, 'from_freq', 'none', 'byte', Width)
* estimate_background_illumination
sub_image (B, ImageFFT1, ImageSub, 2, 100)
* median filter smooths out the fine texture, simplifying the following
* segmentation and final detection of defects
median_image (ImageSub, ImageMedian, 'circle', 9, 'mirrored')
* 分水岭分割算法
watersheds_threshold (ImageMedian, Basins, 20)
* dark patches corresponding to defects have a very low energy
cooc_feature_image (Basins, ImageMedian, 6, 0, Energy, Correlation, Homogeneity, Contrast)
tuple_find (sgn(Energy - 0.05), -1, Indices)
select_obj (Basins, Defects, Indices + 1)
*
dev_display (Image)
dev_display (Defects)


页: [1]
查看完整版本: 分水岭分割