pysdic.PointCloud.filter_points#

PointCloud.filter_points(mask, inplace=False)[source]#

Filter points in the point cloud based on a boolean mask.

This method returns a new PointCloud object containing only the points where the mask is True. The mask should be a 1D boolean NumPy array with the same length as the number of points in the point cloud. All the properties associated with the points are also filtered accordingly.

See also

Parameters:
  • mask (ArrayLike) – A 1D boolean NumPy array of shape \((N_p,)\) where \(N_p\) is the number of points in the point cloud. Each element should be True to keep the corresponding point, or False to remove it.

  • inplace (bool, optional) – If True, modifies the current point cloud in place and returns itself. If False, returns a new PointCloud instance (default is False).

Returns:

A new PointCloud object containing only the filtered points or the modified current instance if inplace is True.

Return type:

PointCloud

Raises:

ValueError – If the input mask is not a 1D boolean array of the correct length.

Examples

Create a PointCloud from a random NumPy array.

1import numpy as np
2from pysdic import PointCloud
3
4# Create a random point cloud with 100 points
5random_points = np.random.rand(100, 3)  # shape (100, 3)
6point_cloud = PointCloud.from_array(random_points)

Filtering points with x-coordinate greater than 0.5.

1# Create a boolean mask for points with x > 0.5
2mask = point_cloud.points[:, 0] > 0.5
3
4# Filter the point cloud using the mask
5filtered_point_cloud = point_cloud.filter_points(mask)
6print(filtered_point_cloud.points)
7# Output: A NumPy array containing only the points with x > 0.5