說說幾個常用的閾值分割算子


說說幾個常用的閾值分割算子

  1. threshold(Image : Region : MinGray, MaxGray : )
    全局閾值分割,適用於環境穩定,目標與背景存在明顯的灰度差的場合。
    利用灰度直方圖確定閾值進行圖像分割。一般是物體與背景之間存在一個明顯的灰度差,直方圖會存在兩個波峰一個是目標一個是背景,那么閾值就是物體與背景之間的最小值。

    read_image (Image, 'clip')
    gray_histo (Image, Image, AbsoluteHisto, RelativeHisto)
    gen_region_histo (Region, AbsoluteHisto, 255, 255, 1)
    *利用直方圖獲取閾值
    histo_to_thresh (AbsoluteHisto,10, MinThresh, MaxThresh)
    *期望閾值
    TarGetGray:=23
    for Index := |MinThresh|-1 to 0 by -1
    if(MinThresh[Index]<=TarGetGray)
    MinThresh:= MinThresh[Index]
    break
    endif
    endfor
    for Index1 := 0 to |MaxThresh|-1 by 1
    if (MaxThresh[Index1]>=TarGetGray)
    MaxThresh:=MaxThresh[Index1]
    break
    endif
    endfor
    *全局閾值分割
    threshold (Image, Region1, MinThresh, MaxThresh)

  2. binary_threshold(Image : Region : Method, LightDark : UsedThreshold)
    自動全局閾值分割,主要對灰度直方圖存在兩個波峰圖像的自動閾值分割。提供兩種方法“max_separability”和“smooth_histo”。
    最大限度的可分性(max_separability):
    根據“灰度直方圖的閾值選擇方法”的灰度直方圖自動閾值調用。該算法首先計算圖像的直方圖,然后利用統計矩找到將像素分割為前景和背景的最優閾值,並最大化這兩個類之間的可分性。此方法僅適用於byte和uint2圖像。
    直方圖平滑(smooth_histo):
    首先確定灰度值的相對直方圖。然后,從直方圖提取相關的最小值,作為閾值操作的參數。為了減少最小值,直方圖被平滑處理為一個高斯函數,就像在auto_threshold中一樣。在平滑直方圖中,掩模尺寸增大,直到得到2個波峰的最小值。然后,閾值設置為這個最小值的位置。
    read_image (Image, 'clip')
    binary_threshold (Image, Region, 'max_separability', 'dark', UsedThreshold)

  3. dyn_threshold(OrigImage, ThresholdImage : RegionDynThresh : Offset, LightDark : )
    局部閾值分割,當前背景之間差異明顯時,可以設定全局閾值進行threshold,但很多情況下由於背景不均一,目標體經常表現為比背景局部亮一些或暗一些,無法確定全局閾值操作,需要通過其鄰域找到一個合適的閾值進行分割這時就要用到局部閾值分割了。

  4. var_threshold(Image : Region : MaskWidth, MaskHeight, StdDevScale, AbsThreshold, LightDark : )
    均值和標准偏差局部閾值分割,能夠較好的分開目標和背景,對不適合的參數設置不敏感。MaskWidth、 MaskHeight是用於濾波平滑的掩膜單元;StdDevScale是標准差乘數因子(簡稱標准差因子);AbsThreshold是設定的絕對閾值;LightDark有4個值可選,’light’、’dark’、’equal’、’not_equal’。
    需要強調的是var_threshold算子和dyn_threshold算子極為類似。不同的是var_threshold集成度更高,並且加入了“標准差×標准差因子”這一變量。可以有效地減少噪聲對分割的影響。

  5. auto_threshold(Image : Regions : Sigma : )
    根據直方圖確定閾值自動全局閾值分割,運行原理,第一,計算灰度直方圖。第二,高斯平滑后從直方圖提取最小值。第三,根據提取的最小值進行閾值分割。sigma越大提取區域越少。
    read_image (Image, 'fabrik')
    median_image (Image, Median, 'circle', 3, 'mirrored')
    auto_threshold (Median, Regions, 3)

  6. fast_threshold(Image : Region : MinGray, MaxGray, MinSize : )
    快速全局閾值分割,灰度值滿足MinGray<=g<=MaxGra聚合為一個區域,為了節省時間按兩步執行。第一,先處理行列間隔Minsize的所有像素點。第二,處理上一步選擇點的領域。和threshold相比分割速度快。

  7. watersheds(Image : Basins, Watersheds : : )
    分水嶺圖像分割。可以分割出分水嶺和盆地。
    read_image (Br2, 'particle')
    gauss_filter (Br2, ImageGauss, 9)
    invert_image (ImageGauss, ImageInvert)
    watersheds (ImageInvert, Basins, Watersheds)
    dev_set_draw ('margin')
    dev_set_colored (12)
    dev_display (Br2)
    dev_display (Basins)

  8. watersheds_threshold(Image : Basins : Threshold : )
    使用閾值分水嶺圖像分割,可以提取分水嶺盆地。

上面這些,全局threshold分割和局部的dyn_threshold分割用的比較多。
尤其是圖片光照不均勻,而dyn_threshold選對兩個分割圖,再對結果做些篩選處理,效果會很好。
一般用適當尺度的均值濾波圖和原圖,還有用灰度開閉的圖來局部分割。


看了感覺怎么樣?來說說吧。。。
喜歡記得關注起來!趕緊的。



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM