-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS_object.m
40 lines (31 loc) · 805 Bytes
/
S_object.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function Q = S_object(prediction,GT)
prediction_fg = prediction;
prediction_fg(~GT)=0;
O_FG = Object(prediction_fg,GT);
prediction_bg = 1.0 - prediction;
prediction_bg(GT) = 0;
O_BG = Object(prediction_bg,~GT);
u = mean2(GT);
Q = u * O_FG + (1 - u) * O_BG;
end
function score = Object(prediction,GT)
if isempty(prediction)
score = 0;
return;
end
if isinteger(prediction)
prediction = double(prediction);
end
if (~isa( prediction, 'double' ))
error('prediction should be of type: double');
end
if ((max(prediction(:))>1) || min(prediction(:))<0)
error('prediction should be in the range of [0 1]');
end
if(~islogical(GT))
error('GT should be of type: logical');
end
x = mean2(prediction(GT));
sigma_x = std(prediction(GT));
score = 2.0 * x./(x^2 + 1.0 + sigma_x + eps);
end