How to take a slice of 3d pointcloud

Hi All,

I am still reading the help of open3d, but wondering if there is a way to take a slice of 3d point cloud and visualize it.

For example, take a slice of point cloud at give Z value, so I can have a point cloud (withina buffer [Z-d, Z+d], d can be any number) in 2D View (top view, XY plane). Similarly for front view (XZ) and side view (YZ).

I really appreciate if anyone can help. Thanks

You can convert the point cloud to a NumPy array and then process it.

http://www.open3d.org/docs/release/tutorial/Basic/working_with_numpy.html

Here’s an example Python snippet for slicing the top view:

import open3d as o3d
import numpy as np

# Load a sample point cloud file
pointcloud = o3d.io.read_point_cloud('../examples/test_data/fragment.ply')

# For visualizing in a window
o3d.visualization.draw_geometries([pointcloud])

# Convert points to a numpy array so that you can process it
pointcloud_as_array = np.asarray(pointcloud.points)

# Top view (where you don't care about the Z value)
# Set X and Y limits for XY plane
X = 2
Y = 1
d = 0.2

# Go through each point in the array for "slicing"
final_pointcloud_array = []
for point in pointcloud_as_array:
    if X - d < point[0] < X + d and Y - d < point[1] < Y + d:
        final_pointcloud_array.append(point)

# Create Open3D point cloud object from array
final_pointcloud = o3d.geometry.PointCloud()
final_pointcloud.points = o3d.utility.Vector3dVector(final_pointcloud_array)
o3d.visualization.draw_geometries([final_pointcloud])
1 Like

@satej1210 Thanks. I will give it a try!