0
votes

I have a 3D point cloud image(.ply format). I need to cut it from center dividing into two. Tried to select only half of the Point cloud using following code but random points are obtained not the desired ones. Using following logic t divide a point cloud in Half(1/2 of original) and save the resultant in a new point cloud. Neither able to correctly slice cloud image from center nor save it in new cloud.

  stepSize = 1;
  indices = 1:stepSize:(i1.Count)/2;
  pt = select(i1, indices);

I also checked following code:

points3d = i1.Location;
points3d_1 = points3d(points3d(:, 1) < 100, :);
points3d_2 = points3d(points3d(:, 1) >= 100, :);
ptCloud1 = pointCloud(points3d_1);
ptCloud2 = pointCloud(points3d_2);
pcshow(ptCloud1);
figure
pcshow(ptCloud2);

Both the snippets are doing same randomly a part is divided and the no matter what range i try in

point3d(:,1)<range

second slice is always full original image. Also the slice image is containing background of original image as shown below. how to get only cloud region stored in new ptCloud1 and ptCloud2.

Expected results How can I get new point cloud which is sliced. Using MatalbR2014b

enter image description here

1
There is not enough information here, please provide a Minimal, Complete, and Verifiable example. How are you determining where the center of the point cloud is? What is the logic behind the code you tried?excaza
Detail added. can you please look into itBASEER ULHASSAN
This does not answer how you are determining where the center of the point cloud is. Unless your *.ply file is made from a left to right scan you're going to get useless data points, which you've seen. Even if it was scanned as such, this would be a terribly non-robust methodology. You need to look at your data in 3D space and determine where the midplane is.excaza
Manual determination is overhead. I am trying to it done generically. but the logic code i used sliced image from unexpected place( not exactly the center of cloud).BASEER ULHASSAN
@BASEERULHASSAN You don't have coded logic, you just cut your *.ply file in half. Nowhere did I say the process had to be manual, but at some point you have to establish criteria for your midplane.excaza

1 Answers

0
votes

You would need to look at the coordinates of the points, and not just their indices.

Let's say ptCloud is your pointCloud object, and you are using MATLAB R2015b or later with the Computer Vision System Toolbox.

>> points3d = ptCloud.Location;

gives you the [X,Y,Z] coordinates of your point cloud points in the form or a 3-column matrix. Let's say you want to cut your point cloud in half along the X axis by a plane X = 10. You would do that the following way:

points3d_1 = points3d(points3d(:, 1) < 10, :);
points3d_2 = points3d(points3d(:, 1) >= 10, :);
ptCloud1 = pointCloud(points3d_1);
ptCloud2 = pointCloud(points3d_2);