forked from egeyosunkaya/ImageAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
complexityAdaptiveDistance.m
38 lines (25 loc) · 1.13 KB
/
complexityAdaptiveDistance.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
function distance = complexityAdaptiveDistance(image,edgeImg, labels , labelCounts , graphDistances ,colorHists,gradient, numLabels, labelSet1 , labelSet2 , labelIndices)
highCompLevel = 0.2;
boundary = 4;
DL = getLowComplexityDistance(image, labels , graphDistances , colorHists,gradient, labelSet1, labelSet2 , edgeImg , labelIndices);
DH = getHighComplexityDistance(image,labels , graphDistances , colorHists,gradient, labelSet1, labelSet2 , labelIndices);
rm = 0;
rn = 0;
for i = labelSet1
rm = rm + (double(labelCounts(1,i))) / double(numLabels);
end
for j = labelSet2
rn = rn + double(labelCounts(1,j)) / double(numLabels);
end
Ds = rm + rn;
temp = (length(labelSet1) + length(labelSet2));
temp = double(temp) / double(numLabels);
alpha = double(-1*double(log2(temp)));
temp = double(boundary - alpha) / double(highCompLevel);
p = double(1 + double(exp(temp)));
p = double(1.0 / double(p));
%p = 1/10;
%disp(sprintf("Tm = %d | Tn = %d | p = %0.4f" ,length(labelSet1), length(labelSet2),p));
%disp(sprintf("DL = %f | DH = %f | DS = %f | p = %0.4f" ,DL, DH ,Ds ,p));
distance = p*DL +(1-p)*DH + Ds;
end