1 function demoNcutClustering;
\r
4 % demo for NcutClustering
\r
5 % also initialize matlab paths to subfolders
\r
6 % Timothee Cour, Stella Yu, Jianbo Shi, 2004.
\r
8 disp('Ncut Clustering demo');
\r
10 %% make up a point data set
\r
12 [data,size_cluster] = build_scene(caseid);
\r
14 plot(data(1,:),data(2,:),'ks', 'MarkerFaceColor','k','MarkerSize',5); axis image; hold on;
\r
16 disp('This is the input data points to be clustered, press Enter to continue...');
\r
19 disp('Compute clustering...');
\r
21 % compute similarity matrix
\r
22 [W,Dist] = compute_relation(data);
\r
24 % clustering graph in
\r
27 [NcutDiscrete,NcutEigenvectors,NcutEigenvalues] = ncutW(W,nbCluster);
\r
28 disp(['The computation took ' num2str(toc) ' seconds']);
\r
30 plot(NcutEigenvectors);
\r
32 % display clustering result
\r
33 cluster_color = ['rgbmyc'];
\r
36 id = find(NcutDiscrete(:,j));
\r
37 plot(data(1,id),data(2,id),[cluster_color(j),'s'], 'MarkerFaceColor',cluster_color(j),'MarkerSize',5); hold on;
\r
39 hold off; axis image;
\r
40 disp('This is the clustering result');
\r
41 disp('The demo is finished.');
\r