Clustering coordinates on image
1 回表示 (過去 30 日間)
古いコメントを表示
How would i cluster these points so that i am left wth 4 sets of coordinates in a 4 by 2 matrix currently it returns a 13 by 2.
This is the returned matrix.
centers =
16.5000 9.0000
8.5000 29.0000
423.0000 29.0000
18.5000 33.0000
30.0000 35.0000
448.5000 35.0000
431.5000 36.5000
37.5000 45.5000
456.5000 435.0000
43.5000 450.0000
426.5000 450.0000
445.0000 457.5000
439.5000 469.0000
0 件のコメント
採用された回答
Image Analyst
2020 年 4 月 17 日
Try this:
centers =[...
16.5000 9.0000
8.5000 29.0000
423.0000 29.0000
18.5000 33.0000
30.0000 35.0000
448.5000 35.0000
431.5000 36.5000
37.5000 45.5000
456.5000 435.0000
43.5000 450.0000
426.5000 450.0000
445.0000 457.5000
439.5000 469.0000];
subplot(1, 2, 1);
plot(centers(:, 2), centers(:, 1), 'r+', 'MarkerSize', 9, 'LineWidth', 2);
[indexes, centroids] = kmeans(centers, 4)
axis ij; % Flip axis direction.
grid on;
subplot(1, 2, 2);
gscatter(centers(:, 2), centers(:, 1), indexes);
axis ij; % Flip axis direction.
grid on;
% Put a big circle at the centroid
hold on;
plot(centroids(:, 2), centroids(:, 1), 'bo', 'MarkerSize', 30, 'LineWidth', 2);
You now have 4 clusters.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!