-
Notifications
You must be signed in to change notification settings - Fork 2
/
SimpleSimilarityScore.m
32 lines (29 loc) · 1.04 KB
/
SimpleSimilarityScore.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
%% Calculates Simple Similarity Score for multiclass segmentation
% function rearranges estimated segmentation and choses the best score
% it provides a way to properly evaluate unsupervised segmentation
%---input---------------------------------------------------------
% gt: Ground Truth segmentation
% est: Estimated segmentation
% k: Number of segmentation classes
%---output--------------------------------------------------------
% dsc: Simple Similarity Score
% map: Estimated segmentation
function [dsc, map] = SimpleSimilarityScore(gt, est, k)
dscs = zeros(1, k);
inv_est = -est;
t_est = zeros(size(est));
combinations = perms(1:k);
combinations_len = size(combinations, 1);
maps = zeros([combinations_len, numel(gt)]);
for i=1:combinations_len
% get next combination
for j=1:k
t_est(inv_est==-j) = combinations(i, j);
end
% Simple Similarity Score
dscs(i) = sum(t_est(:)==gt(:))/numel(gt);
% Save current label map
maps(i, :) = t_est(:);
end
[dsc, ind] = max(dscs);
map = maps(ind, :);