Exclude some nodes from a 3D point cloud (select only neighboring nodes)

4 views (last 30 days)
Hi! I would need code to create a matrix of nodes excluding those circled in red. Is there any code that I could use?
I would need a code where, for example, I select a node I am interested in and it automatically selects all neighboring nodes (within a certain distance x,y,z).
selection = importdata("selection.mat");
figure
plot3(selection(:,1),selection(:,2),selection(:,3),'b.','Markersize',5)
grid on
hold on
axis equal
xlabel('x')
ylabel('y')
zlabel('z')

Accepted Answer

Matt J
Matt J on 13 May 2023
Edited: Matt J on 13 May 2023
X=load('selection').selection; %shorten data name
G=graph(pdist2(X,X)<=10);
T=conncomp(G);
[~,i]=max(histcounts(T,[unique(T),inf]));
I=T==i;
plot3(X(I,1),X(I,2),X(I,3),'b.','Markersize',5); hold on
plot3(X(~I,1),X(~I,2),X(~I,3),'r.','Markersize',5); hold off
grid on
axis equal
xlabel('x'),ylabel('y'),zlabel('z')

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!