You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
580 B
16 lines
580 B
6 years ago
|
function clusterIdx = mySpectralClustering (anAffinityMat, k)
|
||
|
%Implementation of spectral clustering
|
||
|
% Usage clusterIdx = mySpectralClustering (anAffinityMat, k), where:
|
||
|
% Inputs
|
||
|
% - anAffinityMat is a rectagular, symmetrical affinity matrix
|
||
|
% representation of an image
|
||
|
% - k is the desired number of clusters
|
||
|
% Output
|
||
|
% - clusterIdx is a vector storing the cluster Id of each node
|
||
|
|
||
|
L = diag(sum(anAffinityMat, 2)) - anAffinityMat;
|
||
|
[eigenvectorsMatrix, ~] = eigs(L, k, 'sm');
|
||
|
clusterIdx = kmeans(eigenvectorsMatrix, k);
|
||
|
end
|
||
|
|