问题描述
- 图像显著性检测评价指标P-R,F值等相关问题
-
求~这些评价指标的matlab程序~~需要比较多种检测方法的结果,生成比较图~~求助求助
解决方案
贴一个码,不过我还没有调试成功
function Plot_PreRecallThousand
%%
clear;
% Mapdir = 'E:BenchMapmapBerke';
% Mapdir = 'E:BenchMapEqup';
% Mapdir = 'e:BenchMapGbvsMapSED1';
% Mapdir = 'e:OURCMREWberkelmap';
Mapdir = 'E:BenchMapmapBerke';
%GroundDir = 'E:pagerankgrdsed2';bijaohao
% GroundDir = 'E:datasetBSD300Masks';
% GroundDir = 'E:OURCMREBSD300Masks';
% GroundDir = 'E:OURCMREgrdsed1';
GroundDir = 'E:OURCMREbinary mask';
cd (GroundDir);
ImgEnum=dir('*.bmp'); ImgNum=length(ImgEnum);%图像数量
Pre = zeros(21,1);
Recall = zeros(21,1);
% FMeasure = zeros(21,1);
jj=0; PreF = 0; RecallF = 0; FMeasureF = 0; FigAnd = 0; bigthreshold = 0; ThresholdAnd = 0;
for i=1:ImgNum
i
cd(GroundDir);
Binary = imread( ImgEnum(i).name );
NumOne= length( find(Binary(:,:,1) >0) );
[height,width] = size( Binary(:,:,1) );
cd (Mapdir);
mapImg = imread( strcat( ImgEnum(i).name(1:end-4),'_sparse.jpg' ) );
% Label2 = imread( ImgEnum(i).name );
Label2 = mat2gray( mapImg );
%% thou berke Pre recall
if NumOne ~= 0
jj=jj+1; mm = 1;
for j = 0 : .05 : 1
Label3 = zeros( height, width );
Label3( Label2>=j )=1;
NumRec = length( find( Label3==1 ) );
LabelAnd = Label3 & Binary(:,:,1);
NumAnd = length( find( LabelAnd==1 ) );
if NumAnd == 0
FigAnd = FigAnd + 1;
break;
end
Pretem = NumAnd/NumRec;
Recalltem = NumAnd/NumOne;
Pre(mm) = Pre(mm) + Pretem;
Recall(mm) = Recall(mm) + Recalltem;
% FMeasure(mm) = FMeasure(mm) + ( (1 + .3) * Pretem * Recalltem ) / ( .3 * Pretem + Recalltem );
mm = mm + 1;
end
sumLabel = 2* sum( sum(Label2) ) / (height*width) ;
if ( sumLabel >= 1 )
sumLabel = .902 ; bigthreshold = bigthreshold +1;
end
Label3 = zeros( height, width );
Label3( Label2>=sumLabel ) = 1;
NumRec = length( find( Label3==1 ) );
LabelAnd = Label3 & Binary(:,:,1);
NumAnd = length( find ( LabelAnd==1 ) );
if NumAnd == 0
ThresholdAnd = ThresholdAnd +1;
continue;
end
PreFtem = NumAnd/NumRec;
RecallFtem = NumAnd/NumOne;
PreF = PreF + PreFtem;
RecallF = RecallF + RecallFtem;
FMeasureF = FMeasureF + ( ( ( 1 + .3) * PreFtem * RecallFtem ) / ( .3 * PreFtem + RecallFtem ) );
end
end
%% Mean Pre Recall
FigAnd
ThresholdAnd
bigthreshold
cd 'E:ourcmremapcodemap';
Pre = Pre ./jj ;
Recall = Recall ./jj;
% FMeasure = FMeasure ./ jj;
PreF = PreF /jj
RecallF = RecallF /jj
FMeasureF = FMeasureF / jj
save( Mapdir( end-13: end-1) , 'Pre', 'Recall', 'FMeasureF','PreF','RecallF'); % 'FMeasure',
figure(1);
hold on;
plot(Recall ,Pre, 'r' );
xlabel('Recall');
ylabel('Precision');
grid on;
hold off;
% figure(2);
% hold on;
% plot(Pre, 'r' );
% xlabel('Threshold');
% ylabel('Pre');
% grid on;
% hold off;
%
% figure(3);
% hold on;
% plot(Recall, 'r' );
% xlabel('Threshold');
% ylabel('Recall');
% grid on;
% hold off;
%
% figure(4);
% hold on;
% plot( FMeasure, 'r' );
% xlabel('Threshold');
% ylabel('FMeasure');
% grid on;
% hold off;