Main Content

pointCloud

Object for storing 3-D point cloud

Description

ThepointCloudobject creates point cloud data from a set of points in 3-D coordinate system The points generally represent thex,y, andzgeometric coordinates of a samples surface or an environment. Each point can also be represented with additional information, such as RGB color. The point cloud data is stored as an object with the properties listed inProperties. UseObject Functionsto retrieve, select, and remove desired points from the point cloud data.

Creation

Description

ptCloud= pointCloud(xyzPoints)returns a point cloud object with coordinates specified byxyzPoints.

example

ptCloud= pointCloud(xyzPoints,Name,Value)creates apointCloudobject with properties specified as one or moreName,Valuepair arguments. For example,pointCloud(xyzPoints,'Color',[0 0 0])sets theColorproperty of the pointxyzPointsas [0 0 0]. Enclose each property name in quotes. Any unspecified properties have default values.

Input Arguments

expand all

3-D coordinate points, specified as anM-by-3 list of points or anM-by-N-by-3 array for an organized point cloud. The 3-D coordinate points specify thex,y, andzpositions of a point in the 3-D coordinate space. The first two dimensions of an organized point cloud correspond to the scanning order from sensors such as RGBD or lidar. This argument sets theLocationproperty.

Data Types:single|double

Output Arguments

expand all

Point cloud, returned as apointCloudobject with the properties listed inProperties.

Properties

expand all

This property is read-only.

Position of the points in 3-D coordinate space, specified as anM-by-3 orM-by-N-by-3 array. Each entry specifies thex,y, andzcoordinates of a point in the 3-D coordinate space. You cannot set this property as a name-value pair. Use thexyzPointsinput argument.

  • For unorganized point clouds,Locationmust be specified as anM-by-3 array, whereMis the total number of points in the point cloud.

  • For organized point clouds,Locationmust be specified as anM-by-N-by-3 array. The three channels represent thex,y, andzcoordinates of the points. Points obtained from a projective camera, such as Kinect®or a lidar sensor, are stored as an organized point cloud.

Data Types:single|double

Point cloud color, specified as anM-by-3 orM-by-N-by-3 array. Use this property to set the color of points in point cloud. Each entry specifies the RGB color of a point in the point cloud data. Therefore, you can specify the same color for all points or a different color for each point.

  • The specified RGB values must lie within the range [0, 1], when you specify the data type forColorassingleordouble.

  • The specified RGB values must lie within the range [0, 255], when you specify the data type forColorasuint8.

Coordinates Valid assignment ofColor
M-by-3 array M-by-3 array containing RGB values for each point

M-by-N-by-3 array M-by-N-by-3 array containing RGB values for each point

Data Types:uint8

Surface normals, specified as aM-by-3 orM-by-N-by-3 array. Use this property to specify the normal vector with respect to each point in the point cloud. Each entry in the surface normals specifies thex,y, andzcomponent of a normal vector.

Coordinates Surface Normals
M-by-3 array M-by-3 array, where each row contains a corresponding normal vector.
M-by-N-by-3 array M-by-N-by-3 array containing a 1-by-1-by-3 normal vector for each point.

Data Types:single|double

灰度强度每一点,指定为aM-by-1 vector orM-by-Nmatrix. The function maps each intensity value to a color value in the current colormap.

Coordinates Intensity
M-by-3 array M-by-1 vector, where each row contains a corresponding intensity value.
M-by-N-by-3 array M-by-Nmatrix containing intensity value for each point.

Data Types:single|double|uint8

This property is read-only.

Number of points in the point cloud, stored as a positive integer.

This property is read-only.

Range of coordinates alongx-axis, stored as a 1-by-2 vector.

This property is read-only.

Range of coordinates alongy-axis, stored as a 1-by-2 vector.

This property is read-only.

Range of coordinates alongz-axis, stored as a 1-by-2 vector.

Object Functions

findNearestNeighbors Find nearest neighbors of a point in point cloud
findNeighborsInRadius Find neighbors within a radius of a point in the point cloud
findPointsInROI Find points within a region of interest in the point cloud
removeInvalidPoints Remove invalid points from point cloud
select Select points in point cloud
copy Copy array of handle objects

Examples

collapse all

Read the 3-D coordinate points into the workspace.

load('xyzPoints');

Create a point cloud object from the input point coordinates.

ptCloud = pointCloud(xyzPoints);

Inspect the properties of the point cloud object.

ptCloud
ptCloud = pointCloud with properties: Location: [5184x3 single] Count: 5184 XLimits: [-3 3.4338] YLimits: [-2 2] ZLimits: [0.0016 3.1437] Color: [] Normal: [] Intensity: []

Display the point cloud by usingpcshow.

pcshow(ptCloud)

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

Modify Color of Point Cloud Data

Create an RGB color array of size same as the size of the point cloud data. Set the point colors to Red.

cmatrix = ones(size(ptCloud.Location)).*[1 0 0];

Create the point cloud object with the color property set to the RGB color array.

ptCloud = pointCloud(xyzPoints,'Color',cmatrix); pcshow(ptCloud)

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

Add Surface Normals to Point Cloud Data

Compute surface normals corresponding to the point cloud data usingpcnormals.

normals = pcnormals(ptCloud);

Create point cloud object from input point coordinates. Add the computed surface normals to point cloud object.

ptCloud = pointCloud(xyzPoints,'Normal',normals);

Display the point cloud and plot the surface normals.

pcshow(ptCloud) x = ptCloud.Location(:,1); y = ptCloud.Location(:,2); z = ptCloud.Location(:,3); u = normals(:,1); v = normals(:,2); w = normals(:,3); holdonquiver3(x,y,z,u,v,w); holdoff

Figure contains an axes object. The axes object contains 2 objects of type scatter, quiver.

Tips

ThepointCloudobject is ahandle对象。如果你想创建一个单独的副本point cloud, you can use the MATLAB®copymethod.

ptCloudB=copy(ptCloudA)

If you want to preserve a single copy of a point cloud, which can be modified by point cloud functions, use the same point cloud variable name for the input and output.

ptCloud=pcFunction(ptCloud)

Extended Capabilities

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

Introduced in R2015a