pcshow

Plot 3-D point cloud

Syntax

pcshow(ptCloud)
pcshow(xyzPoints)
pcshow(xyzPoints,color)
pcshow(xyzPoints,colorMap)
pcshow(filename)
pcshow(___,Name,Value)
ax = pcshow(___)

Description

example

pcshow(ptCloud) displays points using the locations and colors stored in the point cloud object.

pcshow(xyzPoints) displays points specified by the xyzPoints matrix.

pcshow(xyzPoints,color) displays points contained in the xyzPoints matrix, with colors specified by color.

pcshow(xyzPoints,colorMap) displays points contained in the xyzPoints matrix, with colors specified by colorMap.

pcshow(filename) displays the point cloud stored in the file specified by filename.

pcshow(___,Name,Value) uses additional options specified by one or more Name,Value pair arguments, using any of the preceding syntaxes.

ax = pcshow(___) returns the plot axes.

Examples

collapse all

Generate a sphere consisting of 600-by-600 faces.

numFaces = 600;
[x,y,z] = sphere(numFaces);

Plot the sphere using the default color map.

figure;
pcshow([x(:),y(:),z(:)]);
title('Sphere with Default Color Map');
xlabel('X');
ylabel('Y');
zlabel('Z');

Load and display an image for texture mapping.

I = im2double(imread('visionteam1.jpg'));
imshow(I);

Resize and flip the image for mapping the coordinates.

J = flipud(imresize(I,size(x)));

Plot the sphere with the color texture.

pcshow([x(:),y(:),z(:)],reshape(J,[],3));
title('Sphere with Color Texture');
xlabel('X');
ylabel('Y');
zlabel('Z');

Input Arguments

collapse all

Point cloud, specified as a pointCloud object. The object contains the locations, intensities, and RGB colors to render the point cloud.

Point Cloud PropertyColor Rendering Result
Location only Maps the z-value to a color value in the current color map.
Location and IntensityMaps the intensity to a color value in the current color map.
Location and ColorUse provided color.
Location, Intensity, and ColorUse provided color.

Point cloud filename, specified as a character vector. The file must be supported by pcread. pcshow calls pcread to read the point cloud from the file, but does not store the data in the MATLAB® workspace.

Point cloud x, y, and z locations, specified as either an M-by-3 or an M-by-N-by-3 numeric matrix. The xyzPoints numeric matrix contains M or M-by-N [x,y,z] points. The z values in the matrix, which generally corresponds to depth or elevation, determine the color of each point. When you do not specify the C input color, the function maps the z value to a color in the current colormap.

Point cloud color of points, specified as one of:

You can specify the same color for all points or a different color for each point. When you set C to single or double, the RGB values range between [0, 1]. When you set C to uint8, the values range between [0, 255].

Points InputColor SelectionValid Values of C
xyzPointsSame color for all pointsColorSpec (Color Specification) color character vector or a 1-by-3 RGB vector

Different color for each pointM-by-3 matrix or M-by-N-by-3 matrix containing RGB values for each point.

Point cloud color of points, specified as one of:

  • M-by-1 vector

  • M-by-N matrix

Points InputColor SelectionValid Values of C
xyzPointsDifferent color for each pointVector or M-by-N matrix. The matrix must contain values that are linearly mapped to a color in the current colormap.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'VerticalAxisDir','Up' sets the vertical axis direction to up.

Diameter of marker, specified as the comma-separated pair consisting of 'MarkerSize' and a positive scalar. The value specifies the approximate diameter of the point marker. MATLAB graphics define the unit as points. A marker size larger than six can reduce the rendering performance.

Vertical axis, specified as the comma-separated pair consisting of 'VerticalAxis' and a character vector specifying the vertical axis: 'X', 'Y', or 'Z'.

Vertical axis direction, specified as the comma-separated pair consisting of 'VerticalAxisDir' and a character vector specifying the direction of the vertical axis: 'Up' or 'Down'.

Output axes, specified as the comma-separated pair consisting of 'Parent' and an axes graphics object that displays the point cloud visualization.

Output Arguments

collapse all

Plot axes, returned as an axes graphics object.

You can set the default center of rotation for the point cloud viewer to rotate around the axes center or around a point. Set the default behavior from the Computer Vision Toolbox Preferences.

Tips

  • To improve performance, pcshow automatically downsamples the rendered point cloud during interaction with the figure. The downsampling occurs only for rendering the point cloud and does not affect the saved points.

  • To view point data or modify color display values, hover over the axes toolbar and select one of the following options.

    FeatureDescription
    Datatip

    Click Data Tips to view the data point values for any point in the point cloud figure. For a normal point cloud, the Data Tips displays the x,y,z values. Additional data properties for the depth image and lidar are:

    Point Cloud DataData Value Properties
    Depth image (RGB-D sensor)Color, row, column
    LidarIntensity, range, azimuth angle, elevation angle, row, column

    Background color

    Click Rotate and then right-click in the figure for background options.

    Colormap value

    Click Rotate and then right-click in the figure for colormap options. You can modify colornap values for the coordinate and range values available, depending on the type of point cloud displayed.

    View

    Click Rotate to change the viewing angle of the point cloud figure to the XZ, ZX,YZ, ZY, XY, or the YX plane. Click Restore View to reset the viewing angle.

  • pcplayer supports the 'opengl' option for the Renderer figure property only.

Introduced in R2015b