-
Notifications
You must be signed in to change notification settings - Fork 1
/
getAllSegs.m
48 lines (37 loc) · 1.68 KB
/
getAllSegs.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% If you find the code useful for your research, please cite the paper %
% below: %
% %
% D. Huang, C.-D. Wang, H. Peng, J. Lai, & C.-K. Kwoh. "Enhanced Ensemble %
% Clustering via Fast Propagation of Cluster-wise Similarities."To appear %
% in IEEE Transactions on Systems, Man, and Cybernetics: Systems. %
% DOI: 10.1109/TSMC.2018.2876202 %
% %
% The code has been tested in Matlab R2016a and Matlab R2016b. %
% %
% www.researchgate.net/publication/328581758 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [bcs, baseClsSegs] = getAllSegs(baseCls)
% Dong Huang. 19 April, 2013.
% Optimized for speed by Nejc Ilc, 5 June 2014
[N,nBC] = size(baseCls);
% n: the number of data points.
% nBase: the number of base clusterings.
% nCls: the number of clusters (in all base clusterings).
bcs = baseCls;
nClsOrig = max(bcs,[],1);
C = cumsum(nClsOrig);
bcs = bsxfun(@plus, bcs,[0 C(1:end-1)]);
nCls = nClsOrig(end)+C(end-1);
baseClsSegs = zeros(nCls,N);
for i=1:nBC
if i == 1
startK = 1;
else
startK = (C(i-1)+1);
end
endK = C(i);
searchVec = startK:endK;
F = bsxfun(@eq,bcs(:,i),searchVec);
baseClsSegs(searchVec,:) = F';
end