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!