Main Content

pcmerge

Merge two 3-D point clouds

Description

ptCloudOut = pcmerge(ptCloudA,ptCloudB,gridStep) returns a merged point cloud using a box grid filter in the region of overlap. gridStep specifies the size of the 3-D box for the filter.

example

ptCloudOut = pcmerge(___,GridFilter=gridFilterMethod) sets the method to downsample the region of overlap between the merged point clouds.

Examples

collapse all

Create a point cloud with X, Y, Z points in [0, 100].

ptCloudA = pointCloud(100*rand(1000,3));

Create a partially overlapping point cloud.

ptCloudB = pointCloud([70 20 30] + 100*rand(1000,3));

Merge the two point clouds using a box filter.

ptCloudOut = pcmerge(ptCloudA, ptCloudB, 1);
pcshow(ptCloudOut);

Figure contains an axes object. The axes object contains an object of type scatter.

Input Arguments

collapse all

Point cloud A, specified as a pointCloud object.

Point cloud B, specified as a pointCloud object.

Size of 3-D box for grid filter, specified as a positive scalar. Increasing the value of gridStep can reduce memory usage by merging more points, but it can also reduce the amount of detail captured. The grid filter returns a single point per 3-D box.

Data Types: single | double

Method to downsample region of overlap between the merged point clouds, specified as one of:

  • "average" (default) — Selects a point in the voxel by averaging the location, color, intensity, and normal of all points within the voxel.

  • "nearest" — Selects the voxel's location, color, intensity, and normal based on the point nearest to the centroid of the voxel.

Output Arguments

collapse all

Merged point cloud, returned as a pointCloud object. The function computes the axis-aligned bounding box for the overlapped region between two point clouds. The bounding box is divided into grid boxes of the size specified by gridStep. Points within each grid box are downsampled using the specified grid filter type. Points outside the overlapped region are untouched.

Tips

  • If the two point clouds do not have the same set of properties filled, such as Color or Normal, these properties will be cleared in the returned point cloud. For example, if ptCloudA has color but ptCloudB does not, then ptCloudOut will not contain color.

  • The function filters out points with NaN or Inf values.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2015a