顯著性目標檢測模型評價指標 之 F-measure原理與實現代碼
目錄
一、F-measure原理
上篇博客中,我們介紹了PR曲線,但是很多情況下,不管是查準率Precision還是查全率Recall均不能比較全面地對我們模型所提的顯著性圖片進行評估。因此,人們提出了F度量值(F-measure):查全率和查準率在非負權重 下的加權調和平均值(Weighted Harmonic Mean) [1],計算公式如下:
的取值:由許多做顯著性目標檢測的工作[2],[3],[4]經驗所得, 一般取值爲0.3,即增加了Precision的權重值,認爲查準率比查全率要重要些。因爲當模型將輸出圖全部標爲目標區域時,查全率Recall將等於100%,但是查準率Precision卻很低。
閾值選取:如上篇博客中所講,計算Precision和Recall值時,需要將輸出圖譜S先進行二值化,因爲計算F-measure值不需要繪製曲線,所以我們不需像PR曲線那樣從0到255來取閾值。我們對於不同的顯著性圖S自適應地來確定二值化閾值,自適應閾值定義爲顯著性圖譜S像素均值的二倍,計算公式如下:
其中W和H分別爲模型輸出的顯著性圖譜S的長和高,S(x,y)爲在點(x,y)處S的取值。
三、 Matlab代碼
function [Fmeasure]=F_measureHanle
%本程序的功能是對顯著性特徵提取的結果計算F-measure值。
%by [email protected]
clc
clear
imnames=dir(path_output);
imnames2=dir(path_target);
num=length(imnames);
belt2=0.3;
reca = zeros(num,1);
prec = zeros(num,1);
for i=1:num
Target=imread(imnames2(i).name);%讀圖
mark = Target(:,:,1);
mark = mark/max(mark(:));%二值化Ground-truth
Output=imread(imnames(i).name);
thresh=2*mean(mean(mean(Output))); %自適應閾值
label=reshape(mark,1,256*256);
score=reshape(Output(:,:,1),1,256*256);
sco_th0=(score)>thresh;
sco_th=uint8(sco_th0);
TP = length(find((label == 1) & (sco_th == 1)));
FP = length(find((label == 0) & (sco_th == 1)));
FN = length(find((label == 1) & (sco_th == 0)));
reca(i,1) = TP/(TP+FN);
prec(i,1) = TP/(TP+FP);
i
end
P=mean(prec);
R=mean(reca);
Fmeasure=((1+belt2)*P*R)/(belt2*P+R)
著作權歸作者所有。商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。
參考文獻
[1]: A. Borji, M.-M. Cheng, H. Jiang, and J. Li. Salient object detection: A benchmark. IEEE TIP, 24(12):5706–5722, 2015.
[2]:R. Achanta, S. Hemami, F. Estrada, and S. Süsstrunk, “Frequencytuned salient region detection,” in Proc. IEEE Conf. CVPR, Jun. 2009, pp. 1597–1604.
[3]:M.-M. Cheng, N. J. Mitra, X. Huang, P. H. S. Torr, and S.-M. Hu, “Global contrast based salient region detection,” IEEE Trans. Pattern Anal. Mach. Intell., vol. 37, no. 3, pp. 569–582, Mar. 2015.
[4]:F. Perazzi, P. Krahenbuhl, Y. Pritch, and A. Hornung, “Saliency filters: Contrast based filtering for salient region detection,” in Proc. IEEE Conf. CVPR, Jun. 2012, pp. 733–740.