Demo step by step: Data
Clustering with Normalized Cuts
(file demoNcutClustering.m)
%% make up a point data set
caseid = 3;
[data,size_cluster] = build_scene(caseid);
figure(1);clf;
plot(data(1,:),data(2,:),'ks',
'MarkerFaceColor','k','MarkerSize',5); axis image; hold on;
disp('This is the input data points to be clustered, press Enter
to continue...');
pause;
This is the input data points to be
clustered, press Enter to continue...
disp('Compute clustering...');
Compute clustering
% compute similarity matrix
[W,Dist] = compute_relation(data);
% clustering graph in
nbCluster = 4;
tic;
[NcutDiscrete,NcutEigenvectors,NcutEigenvalues]
= ncutW(W,nbCluster);
disp(['The computation took ' num2str(toc) ' seconds']);
The
computation took 0.546 seconds
% display clustering result
cluster_color = ['rgbmyc'];
figure(2);clf;
for j=1:nbCluster,
id = find(NcutDiscrete(:,j));
plot(data(1,id),data(2,id),[cluster_color(j),'s'],
'MarkerFaceColor',cluster_color(j),'MarkerSize',5); hold on;
end
hold off; axis image;
disp('This is the clustering result');
disp('The demo is finished.');
This is the clustering result
The demo is finished.