Cluster 3D data

조회 수: 24 (최근 30일)
Amarbold Purev
Amarbold Purev 2021년 2월 23일
댓글: darova 2021년 2월 24일
Hello,
I have a combined X Y Z camera coordinates and I want to cluster them into 2 groups.
I have tried the following code:
n = length(camLoc);
cam_A = NaN(n,3);
cam_B = NaN(n,3);
idx = kmeans(camLoc,2, 'Distance', 'cityblock', 'Start', 'uniform', 'Replicates',5);
for i = 1:n
if idx(i) == 1
cam_A(i,:) = camLoc(i,:);
else
cam_B(i,:) = camLoc(i,:);
end
end
cam_A(any(isnan(cam_A), 2), :) = [];
cam_B(any(isnan(cam_B), 2), :) = [];
scatter3(cam_A(:,1),cam_A(:,2),cam_A(:,3),'r');
hold on
scatter3(cam_B(:,1),cam_B(:,2),cam_B(:,3),'b');
and the results is shown below.
However, I want to cluster not vertically but horizontally. In other words, I want the data, that it would look like a 2 long noodles.
Thanks in advance.

채택된 답변

darova
darova 2021년 2월 23일
  댓글 수: 2
Amarbold Purev
Amarbold Purev 2021년 2월 24일
Thank you @darova it really helped.
Simple clusterdata worked like a charm.
idx = clusterdata(camLoc,2);
darova
darova 2021년 2월 24일

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by