-
Notifications
You must be signed in to change notification settings - Fork 175
/
performancemetrics_glas.m
96 lines (76 loc) · 1.83 KB
/
performancemetrics_glas.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
% close all;
% clear all;
% clc;
N = 79
st = 1;
Fsc=[];
MIU=[];
PA=[];
bestfsc=0;
bestmiu=0;
bestpa=0;
bestep = 0;
for k = 1:24
k
Fsc=[];
MIU=[];
PA=[];
for i = st:st+N
i;
%gname = strcat('./Brain_test/',num2str(i,'%04d'),'.png');
tname = '/media/jeyamariajose/7888230b-5c10-4229-90f2-c78bdae9c5de/Data/Projects/axialseg/KiU-Net-pytorch/results/glas/medT/';
imgname = strcat(tname,num2str(50*k),'/',num2str(i,'%02d'),'.png');
lname = '/media/jeyamariajose/7888230b-5c10-4229-90f2-c78bdae9c5de/Data/glas/resized/test/labelcol/';
labelname = strcat(lname, num2str(i,'%02d'),'.png');
I = double(imread(imgname));tmp2=zeros(128,128);
tmp2(I>130) = 255;
tmp2(I<131) = 0;
tmp = double(imread(labelname));
tmp = tmp(:,:,1);
tmp(tmp<130)=0;tmp(tmp>131)=255;
tp=0;fp=0;fn=0;tn=0;uni=0;ttp=0;lab=0;
for p =1:128
for q =1:128
if tmp(p,q)==0
if tmp2(p,q) == tmp(p,q)
tn = tn+1;
else
fp = fp+1;
uni = uni+1;
ttp = ttp+1;
end
elseif tmp(p,q)==255
lab = lab +1;
if tmp2(p,q) == tmp(p,q)
tp = tp+1;
ttp = ttp+1;
else
fn = fn+1;
end
uni = uni+1;
end
end
end
if (tp~=0)
F = (2*tp)/(2*tp+fp+fn);
MIU=[MIU,(tp*1.0/uni)];
PA=[PA,(tp*1.0/ttp)];
Fsc=[Fsc;[i,F]];
else
MIU=[MIU,1];
PA=[PA,1];
Fsc=[Fsc;[i,1]];
end
end
if bestfsc <= mean(Fsc) & (mean(Fsc) ~= 1)
bestfsc = mean(Fsc);
bestmiu = mean(MIU,2);
bestpa = mean(PA,2);
bestep = 50*k;
end
mean(Fsc)
end
bestfsc
bestmiu
bestpa
bestep