語義分割metric

Precision, Recall Rate, and F-score

一般用來評估圖像分割中的邊緣檢測問題。準確度是檢測出的像素中是邊緣的比例,召回率是檢測出的正確邊緣佔所有邊緣的比例,F-score是兩者的調和平均數。

precision=detectedtrueboundarypixelsdetectedboundarypixels

recall=detectedtrueboundarypixelsalltrueboundarypixels

Fscore=2precicionrecallpresicion+recall

Pixel error

評估圖像分割問題最簡單的方法。比較預測的label和實際的label,錯誤的點除以總數,就是像素誤差。對於二值掩膜來說,歐式距離和漢明距離的結果相同。

優點是簡單,但是對於位置的偏移過分敏感,肉眼不可見的偏移都會產生大量的像素誤差。

Rand error

蘭德指數是兩個數據聚類的相似性評價方法,改造之後用來衡量分割性能,因爲分割可以看作是聚成類的像素。

給定一張圖片S,有n個像素點,同時有兩個分割X和Y(實際和預測?)

  • a:兩個分割中同屬於一個聚類的像素點數量
  • b:兩個分割中都不屬於一個聚類的像素點數量

Rand指數:

Rand index=RI=a+bC2n

RI是用來衡量相似度的,越高越好,和誤差相反,因此蘭德誤差如下:
RE=1RI

蘭德誤差作爲不一致的度量,是兩個分割對一對像素是否屬於或者不屬於同一個聚類的頻率。

Warping error

當大致檢測出來一個目標,用Pixel error會發現誤差很大,但實際上這個分割可能看着很好。在這種情況中,pixel error和rand error不是一個好的選擇。

warping error主要來衡量分割目標的拓撲形狀效果。給定L 的pixel error,候選標註T(預測值)和參考標註L (實際值)的warping error可以認爲是L 和對於T最好的L 的漢明距離。

D(T||L)=minLL||TL||2

目標檢測評價函數intersection-over-union ( IOU )

模型產生的目標窗口和原來標記窗口的交疊率。具體我們可以簡單的理解爲: 即檢測結果(DetectionResult)與 Ground Truth 的交集比上它們的並集,即爲檢測的準確率 IoU :

IOU=DetectionResultGroundTruthDetectionResultGroundTruth

如下圖所示,GT = GroundTruth; DR = DetectionResult
  • 黃色框框起來的是GTDR
  • 綠色框框起來的是GTDR
  • 最理想的情況是剛好重合,那麼這個值爲1

可以使用矩形來框面積,使用圖像分割中的掩膜。

程序如下:

# -*- coding: utf-8 -*-
"""
Created on Sun Aug 07 14:26:51 2016

@author: Eddy_zheng
"""

def IOU(Reframe,GTframe):
    """
    自定義函數,計算兩矩形 IOU,傳入爲均爲矩形對角線,(x,y)  座標。·
    """
    x1 = Reframe[0];
    y1 = Reframe[1];
    width1 = Reframe[2]-Reframe[0];
    height1 = Reframe[3]-Reframe[1];

    x2 = GTframe[0];
    y2 = GTframe[1];
    width2 = GTframe[2]-GTframe[0];
    height2 = GTframe[3]-GTframe[1];

    endx = max(x1+width1,x2+width2);
    startx = min(x1,x2);
    width = width1+width2-(endx-startx);

    endy = max(y1+height1,y2+height2);
    starty = min(y1,y2);
    height = height1+height2-(endy-starty);

    if width <=0 or height <= 0:
        ratio = 0 # 重疊率爲 0 
    else:
        Area = width*height; # 兩矩形相交面積
        Area1 = width1*height1; 
        Area2 = width2*height2;
        ratio = Area*1./(Area1+Area2-Area);
    # return IOU
    return ratio,Reframe,GTframe

參考資料

https://imagej.net/Topology_preserving_warping_error
Zhu F, Liu Q, Fu Y, et al. Segmentation of Neuronal Structures Using SARSA (λ)-Based Boundary Amendment with Reinforced Gradient-Descent Curve Shape Fitting[J]. Plos One, 2014, 9(3):e90873.
http://blog.csdn.net/eddy_zheng/article/details/52126641

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章