Dividing the point cloud in 10x10 ways

4 views (last 30 days)
Hello, my problem is that I am working on a 3-dimensional point cloud like in the title and I want to split it into 10x10 pieces over x and y. As I am new to Matlab, I didn't know how to do this for now.

Answers (2)

Adam Danz
Adam Danz on 29 Mar 2021
Edited: Adam Danz on 1 Apr 2021
Load built-in pointcloud data and look at the pointcloud object pc
load('xyzPoints');
pc = pointCloud(xyzPoints)
pc =
pointCloud with properties: Location: [5184×3 single] Count: 5184 XLimits: [-3 3.4338] YLimits: [-2 2] ZLimits: [0.0016 3.1437] Color: [] Normal: [] Intensity: []
X/Y/ZLimits are the range of x,y,z points. Create a 10x10 grid within the x and y ranges. The bounds are defined in xyBounds (nx2).
[x,y] = meshgrid(linspace(pc.XLimits(1), pc.XLimits(2), 10), ...
linspace(pc.YLimits(1), pc.YLimits(2), 10));
xyBounds = [x(:),y(:)]
xyBounds = 100×2
-3.0000 -2.0000 -3.0000 -1.5556 -3.0000 -1.1111 -3.0000 -0.6667 -3.0000 -0.2222 -3.0000 0.2222 -3.0000 0.6667 -3.0000 1.1111 -3.0000 1.5556 -3.0000 2.0000
Use indexing to access a particular section of points.
Get all points within the bin #n
  • pc.Location are all [x,y,z] coordinates.
  • idx is a logical vector identifying points in pc.Location that are in the bin
  • section are the [x,y,z] coordinates within the bin.
n = 50; % 50th bin xyBounds(n,:)
xIdx = pc.Location(:,1) >= xyBounds(n,1) & pc.Location(:,1) < xyBounds(n+1,1);
yIdx = pc.Location(:,2) >= xyBounds(n+1,2) & pc.Location(:,2) < xyBounds(n,2);
idx = xIdx & yIdx;
section = pc.Location(idx,:)
section = 1150×3
0 -1.5000 2.4000 0 -1.4537 2.4694 0 -1.4099 2.4977 0 -1.3830 2.4849 0 -1.3874 2.4309 0.0705 -1.4758 2.4399 0.0682 -1.4290 2.4887 0.0665 -1.3919 2.4964 0.0658 -1.3789 2.4630 0.1421 -1.4936 2.4000
Some bins will not have any points and will return a 0x3 empty matrix.
  11 Comments
Ahmet Selim Arslan
Ahmet Selim Arslan on 10 Apr 2021
When I say show with plot, it shows such a result.
Ahmet Selim Arslan
Ahmet Selim Arslan on 11 Apr 2021
Okay, let's take it over again, I apologize for not being able to explain it in a nice and understandable language.As you can see, I want to divide the point cloud into 100 equal parts and distribute the height randomly and see this in the graph. I'm sorry if I haven't been revealing before

Sign in to comment.


darova
darova on 24 Mar 2021
see this example
clc,clear
x = rand(10,10,10);
y = rand(10,10,10);
z = rand(10,10,10);
ix = round(5*x);
iy = round(5*y);
plot3(x(:),y(:),z(:),'.b');
hold on
h = plot3(0,0,0,'or');
hold off
view(15,60)
for i = 1:5
for j = 1:5
ind = (i==ix) & (j==iy);
set(h,'xdata',x(ind))
set(h,'ydata',y(ind))
set(h,'zdata',z(ind))
pause(0.2)
end
end
  4 Comments
darova
darova on 29 Mar 2021
Can you explain how exactly you want to divide the region?
Ahmet Selim Arslan
Ahmet Selim Arslan on 29 Mar 2021
In the point cloud, I want to divide the x and y axes into 10 equal parts and create 100 equal parts in this way.

Sign in to comment.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!