-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfn_find_group.m
73 lines (58 loc) · 1.61 KB
/
fn_find_group.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
function fn_find_group(filepath,names,nclique)
fprintf('fn_find_group.... ');
load([filepath, '\features\match.mat']);
load([filepath, '\features\sift_total.mat']);
nframes = size(names,1);
% make a similarity matrix S
Si = zeros(nmatches,1);
Sj = zeros(nmatches,1);
Ss = ones(nmatches,1);
idx = 1;
for i=1:nframes
for j=i+1:nframes
nnmatches = size(M{i,j},2);
ms = M{i,j};
if size(ms,2)==0
continue;
end
mi = ms(1,:) + nfeatcum(i);
mj = ms(2,:) + nfeatcum(j);
s = ms(3,:);
Si(idx:idx+nnmatches-1) = mi;
Sj(idx:idx+nnmatches-1) = mj;
Ss(idx:idx+nnmatches-1) = s;
idx = idx+nnmatches;
end
end
fid = fopen([filepath '\features\match.grh'],'w');
fprintf(fid,'%d,%d,\r\n',[[Si;Sj],[Sj;Si]]');
fclose(fid);
% execute external binary
MIN_CLIQUE_NUM = min(nframes,nclique);
system(['runmaximalclique ' filepath ' ' num2str(MIN_CLIQUE_NUM)]);
% read output
text = fileread([filepath '\features\match_maximal_clique.grh']);
text = regexp(text,'[^\n]*','match');
nmatch = size(text,2);
sizes = zeros(nmatch,1);
tempcell = cell(nmatch,1);
for i=1:nmatch
temp = text{i};
temp2 = regexp(temp,'[\S]*','match');
nelement = size(temp2,2);
vec = zeros(nelement,1);
for j=1:nelement
vec(j) = str2double(temp2{j});
end
tempcell{i} = vec;
sizes(i) = nelement;
end
[sizes,comid] = sort(sizes,'descend');
nneighvec = sizes;
featsort = cell(nmatch,1);
for i=1:nmatch
id = comid(i);
featsort{i} = tempcell{id};
end
save([filepath, '\features\selected.mat'],'featsort','nneighvec');
fprintf('done.\n');