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
| Data = double(Data);
Data = normalizeData(Data);
if isequal(roundColors, 1)
fac = 10^roundDigits;
rData = round(Data * fac) / fac;
else
rData=Data;
end
[~, ind, order] = unique(rData', 'rows', 'R2012a');
Data = Data(:, ind);
fprintf('creating Similary Graph...\n');
SimGraph = SimGraph_NearestNeighbors(Data, Neighbors, 1);
try
comps = graphconncomp(SimGraph, 'Directed', false);
fprintf('- %dconnectes componenets found\n', comps);
end
fprintf('Clustering Data...\n');
C = SpectralClustering(SimGraph,k,2);
D = convertClusterVector(C);
D = D(order);
if k == 2
map = [0 0 0; 1 1 1];
else
map = zeros(3, k);
for ii = 1:k
ind = find(D == ii, 1);
map(: , ii) = rData(:, ind);
end
map=map';
end
set(gca, 'Position', [0 0 1 1], 'Units' , 'Normalized');
if isequal(markEdges, 1)
figure(4)
imshow(Img, 'Border', 'tight');
ls = label2rgb(S);
BW=Imgbw(ls, graythresh(ls));
[B, L] = bwboundaries(BW, 'holes');
hold on ;
for k = 1:length(B)
boundary = B{k};
plot(boundary(:, 2), boundary(:, 1), 'r', 'LineWidth', 2)
end
hold off;
else
figure
imshow(S, map, 'Border', 'tight')
end
hold on;
axis off;
truesize;
hold off; |
Partager