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)