read_image (Image, 'particle') *获取图像 dev_display (Image) *显示图像 threshold (Image, Large, 110, 255) *灰度阈值分割图像 dilation_circle (Large, LargeDilation, 7.5) *圆角膨胀 dev_display (Image) dev_set_draw ('margin') dev_set_line_width (3) dev_set_color ('red') dev_display (LargeDilation) dev_set_draw ('fill') *显示图像 complement (LargeDilation, NotLarge) *返回补充图像,即得到去除大斑点后的图像NotLarge reduce_domain (Image, NotLarge, ParticlesRed) *减去除了NotLarge图像,即去除大斑点后的图像,减小运算 mean_image (ParticlesRed, Mean, 31, 31) *平滑处理图像 dyn_threshold (ParticlesRed, Mean, SmallRaw, 3, 'light') *选择灰度阈值;
网友详解:当前背景之间差别明显时,能够设定全局阈值进行threshold,但不少状况下因为背景不均一, *目标体常常表现为比背景局部亮一些或暗一些,没法肯定全局阈值操做,须要经过其邻域找到一个合适的阈值进 *行分割dyn_threshold。ThresholdImage是参考图像,经过与OrigImage对比找到领域肯定阈值,通常采用平滑滤波算子 *(如mean_image)获取参考图像。offset设定邻域比较的区间范围,灰度值变化在offset范围内均是能够接受的。 opening_circle (SmallRaw, Small, 2.5) *消除小区域(小于圆形结构元素)和光滑的边界地区 connection (Small, SmallConnection) *显示联通区域 dev_display (Image) *这句不加窗口显示效果会有雪花 dev_set_colored (12) dev_display (SmallConnection)