-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyseOneResult.m
65 lines (51 loc) · 2.04 KB
/
analyseOneResult.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
function [ris, vois, eigNums] = analyseOneResult(inFile, gtFile)
% function [ris, vois] = analyseOneResult(inFile, gtFile)
%
% Calculate region benchmarks for an image. Probabilistic Rand Index, and Variation of
% Information.
%
% INPUT
% inFile : a collection of segmentations in a cell 'segs' stored in a mat file
% gtFile : File containing a cell of ground truth segmentations%
%
% OUTPUT
% ris the rand index of each segmentation in the input file
% vois the variation of information of each segmentation in the input
% file
% eigNums the number of eigenvalues used for each segmentation
%
%
% Code originally written by Pablo Arbelaez <[email protected]>,
% and modified for the present experiment.
load(inFile, 'segs');
load(inFile, 'eigs');
load(gtFile, 'groundTruth');
% The ngtsegs variable holds the number of ground truth segmentations.
ngtsegs = numel(groundTruth);
if ngtsegs == 0
error(' bad gtFile !');
end
% At this point, the segmentations from my algorithm are in the variable
% segs, and the ground truth segmentations are in the variable grountTruth.
ninputsegs = numel(segs);
thresh = 1:ninputsegs; thresh=thresh';
% Now, the thresh variable is a column vector containing the numbers 1 up
% to the number of segmentations in the algorithm output (segs) variable.
ris = zeros(ninputsegs, 1);
vois = zeros(ninputsegs, 1);
eigNums = zeros(ninputsegs, 1);
% Iterate through each of the segmentations in the algorithm's output.
for t = 1 : ninputsegs
% Set the 'seg' variable to be equal to one of the segmentations output
% by the algorithm.
seg = double(segs{t});
% Get the rand index and variation of information when comparing the
% current segmentation with all of the ground truth segmentations.
% This method returns the *average* rand index, and variation of
% information of the current segmentation, over all of the ground truth
% segmentations.
[ri, voi] = match_segmentations2(seg, groundTruth);
ris(t) = ri;
vois(t) = voi;
eigNums(t) = eigs{t};
end