Main Content

pcsegplanes

Segment point cloud into planar surfaces

Since R2024b

Description

[labels,numPlanes] = pcsegplanes(ptCloud) segments a point cloud into planar surfaces. pcsegplanes assigns an integer planar surface label to each point in the point cloud, and returns the labels of all points. The function also returns the number of segmented planar surfaces.

The function uses the robust statistics approach for detecting planes. For more information on this approach, see [1].

example

[labels,numPlanes,planeNormals] = pcsegplanes(ptCloud) additionally returns the normals of the segmented surface planes.

[___] = pcsegplanes(ptCloud,Name=Value) specifies options using one or more name-value arguments in addition to any combination of arguments from previous syntaxes. For example, MinNumPoints=100 sets the minimum number of points that must be present to fit a planar surface to 100.

Examples

collapse all

Load an unorganized point cloud.

filepath = fullfile(toolboxdir("lidar"),"lidardata","lcc","bboxGT.mat");
load(filepath,"pc");

Estimate the normal vectors by using the pcnormals function.

numOfNeighbors = 50;
normals = pcnormals(pc,numOfNeighbors);
pc.Normal = normals;

Segment point cloud into planar surfaces.

[labels,numPlanes,planeNormals] = pcsegplanes(pc);

Display the segmented point cloud.

figure
pcshow(pc.Location,labels)
colormap(jet(double(numPlanes)))
title("Segmented Point Cloud")

Figure contains an axes object. The axes object with title Segmented Point Cloud contains an object of type scatter.

Input Arguments

collapse all

Point cloud, specified as a pointCloud object.

Note

The surface normals of the specified pointCloud object must be a nonempty array. Use the pcnormals function to estimate the surface normals of the point cloud.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: [labels,numPlanes] = pcsegplanes(ptCloud,MinNumPoints=100) sets the minimum number of points that must be present to fit a planar surface to 100.

Maximum absolute angular distance between the normal vector of a detected plane and point normals, specified as a positive scalar in the range (0, 60]. Units are in degrees. Specify a smaller value to get fewer planes with better detection quality.

Data Types: single | double

Maximum coplanar distance, specified as a positive scalar in the range [75, 90). Units are in degrees. Maximum coplanar distance is the angular distance between the arbitrary vector joining the farthest inlier point from the center of the detected plane and the normal vector of the detected plane.

Data Types: single | double

Reference orientation constraint to detect a plane in the input point cloud, specified as a 1-by-3 vector representing xyz-coordinates.

Data Types: single | double

Angular tolerance between the orientations of the detected plane and the reference vector, specified as a positive scalar. Units are in degrees.

Data Types: single | double

Maximum outlier ratio, specified as a scalar in the range [0, 1]. This value controls the maximum allowed percentage of outliers relative to the total number of points in a set that is being fit with a planar surface.

Data Types: single | double

Minimum number of points in detected planar surface, specified as a positive scalar. By default, this value is total number of points in the input point cloud multiplied by 0.001.

Data Types: single | double

Minimum size of a detected planar surface, specified as a positive scalar. The largest edge of the segmented planar surface must be greater than this value. Otherwise the function rejects the planar surface. By default, this value is total number of points in the input point cloud multiplied by 0.01

Data Types: single | double

Output Arguments

collapse all

Segmented plane labels, returned as an M-by-1 vector or M-by-N matrix of nonnegative integers. The value 0 represents invalid points.

  • For an unorganized point cloud of the form M-by-3, the function returns labels as an M-by-1 vector.

  • For an organized point cloud of the form M-byN-by-3, the function returns labels as an M-by-N matrix.

Number of planes, returned as a positive integer. The number of planes excludes the label value 0, which is reserved for invalid points.

Plane normals, returned as an N-by-3 matrix. N is the number of segmented planes. Each matrix row represents the xyz-coordinates of a plane normal.

References

[1] Araújo, Abner M. C., and Manuel M. Oliveira. “A Robust Statistics Approach for Plane Detection in Unorganized Point Clouds.” Pattern Recognition 100 (April 2020): 107115. https://doi.org/10.1016/j.patcog.2019.107115.

Version History

Introduced in R2024b

See Also

Objects

Functions