Clustering coordinates on image

조회 수: 1 (최근 30일)
jg
jg 2020년 4월 17일
댓글: jg 2020년 4월 19일
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

채택된 답변

Image Analyst
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개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by