Main Content

pcshowpair

Visualize difference between two point clouds

Description

pcshowpair(ptCloudA,ptCloudB) creates a visualization depicting the differences between the two input point clouds. The differences are displayed using a blending of magenta for point cloud A and green for point cloud B.

example

pcshowpair(ptCloudA,ptCloudB,Name=Value) specifies options using one or more name-value arguments in addition to any combination of arguments from previous syntaxes. For example, pchowpair(ptCloudA,ptCloudB,BackgroundColor="yellow"), sets the figure background color to yellow.

ax = pcshowpair(___) returns the plot axes to the visualization of the differences, using any of the preceding syntaxes.

Examples

collapse all

Load two point clouds that were captured using a Kinect device in a home setting.

load("livingRoom");

pc1 = livingRoomData{1};
pc2 = livingRoomData{2};

Plot and set the viewpoint of point clouds.

figure
pcshowpair(pc1,pc2,VerticalAxis="Y",VerticalAxisDir="Down")
title("Difference Between Two Point Clouds")
xlabel("X(m)")
ylabel("Y(m)")
zlabel("Z(m)")

Figure contains an axes object. The axes object with title Difference Between Two Point Clouds, xlabel X(m), ylabel Y(m) contains 2 objects of type scatter.

Input Arguments

collapse all

Point cloud A, specified as a pointCloud object. The function uses levels of magenta to represent ptCloudA and a pure magenta when the point cloud contains no color information.

Point cloud B, specified as a pointCloud object. The function uses levels of green to represent ptCloudB and a pure green when the point cloud contains no color information.

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.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: pchowpair(ptCloudA,ptCloudB,BackgroundColor="yellow"), sets the figure background color to yellow.

Approximate diameter of the point marker, specified as a positive scalar. The units are in points. A marker size larger than six can reduce the rendering performance.

Background color, specified as an RGB triplet, hexadecimal color code, or a character vector that specifies a long or short color name.

Vertical axis, specified as "X", "Y", or "Z". When you reload a saved figure, any action on the figure resets the vertical axis to the z-axis.

Vertical axis direction, specified as "Up" or "Down". When you reload a saved figure, any action on the figure resets the direction to the up direction.

Camera projection for 3-D views, specified as one of these values:

  • "perspective" — Projects the viewing volume as the frustum of a pyramid (a pyramid whose apex has been cut off parallel to the base). Objects further from the camera appear smaller. Distance causes foreshortening, which enables you to perceive the depth of 3-D objects. This projection type is useful when you want to display realistic views of real objects. Perspective projection does not preserve the relative dimensions of objects. Instead, it displays a distant line segment smaller than a nearer line segment of the same length. Lines that are parallel in the data might not appear parallel in the scene.

  • "orthographic" — This projection type maintains the correct relative dimensions of graphics objects regarding the distance of a given point from the viewer. Relative distance from the camera does not affect the size of objects. Lines that are parallel in the data parallel appear parallel on the screen. This projection type is useful when it is important to maintain the actual size of objects and the angles between objects.

Plane to visualize point cloud, specified as "XY", "YX", "XZ", "ZX", "YZ", "ZY". The ViewPlane sets the line of site from the camera, centered in the selected plane, to the center of the plot.

Point cloud property for color map, specified as "auto","X", "Y", "Z", "Intensity", "Color", "Row", "Column". The pcshow function uses the value of ColorSource to assign a color map for rendering the point cloud. The values use these properties:

  • "X"x coordinates in the Location property of the input point cloud.

  • "Y"y coordinates in the Location property of the input point cloud.

  • "Z"z coordinates in the Location property of the input point cloud.

  • "Intensity"Intensity property of the input point cloud.

  • "Color"Color property of the input point cloud.

  • "Row" — Using the row values of an organized point cloud.

  • "Column" — Using the column values of an organized point cloud.

When you set ColorSource to "auto", the function sets the color map depending on which property values are available in the input point cloud object:

Available Point Cloud PropertyColor Source
Location only Maps the Z-value to a color value in the current color map.
Location and Intensity Maps the z-value to a color value in the current color map.
Location and Color Maps the color values to the current color map.
Location, Intensity, and Color Maps the color values to the current color map.

State of axes visibility, specified as "on" or "off", or as numeric or logical 0 (false) or 1 (true). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • "on" — Display the axes and its children.

  • "off" — Hide the axes without deleting it. You still can access the properties of an invisible axes object. (Child objects such as lines remain visible.)

Axes on which to display the visualization, specified as an Axes object. To create an Axes object, use the axes function. To display the visualization in a new figure, leave "Parent" unspecified.

Output Arguments

collapse all

Plot axes, returned as an axes graphics object. Points with NaN or Inf coordinates are not displayed.

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.

More About

collapse all

Axes Toolbar Operations

Keyboard shortcuts are enabled only for the rotate (default) mode. To view the axes toolbar operations, point to the figure and select one of these options. Click the Restore View icon to reset the display.

Figure toolbar

FeatureDescription
Vertical AxisSelect an X-, Y-, or Z-direction to set the direction of that axis of the point cloud as the positive vertical direction. Use the keyboard arrow keys to move the point cloud with respect to the direction selected.
View Plane

Select the viewing angle of the point cloud figure as the XY, YX, XZ, ZX, YZ, or ZY plane.

Background ColorDisplay a color chart from which you can select a background color.
Axes On/OffTurn the display axes on or off.
ProjectionSelect perspective or orthogonal view.
Export
  • Save as icon— Save the content as a tightly cropped image or PDF.

  • Copy content as an image icon— Copy the content as an image.

  • Copy as vector graphic icon— Copy the content as a vector graphic.

BrushEnable data brushing mode.
Data Tips

View the point data values of a point by selecting it in the point cloud figure. The Data Tips display shows the x, y, and z values of the points. Point clouds for depth images and lidar contain these additional data properties:

Point Cloud Data SourceData Value Properties
Depth image (RGB-D sensor)Color, Row, and Column
LidarIntensity, Range, Azimuth angle, Elevation angle, Row, and Column

Rotate 3D

Drag to rotate the point cloud figure. You can also right-click any point on the point cloud figure and select Rotate Around a Point to specify that point as the center of rotation for the figure. To return to axes rotation, right-click again and select Rotate Around Axes Center.

While in Rotate 3D mode, you can also select the color source for the point cloud by right-clicking anywhere in the point cloud figure and selecting Color Source, and then selecting an option from the list. The figure applies the active colormap to the point cloud based on the values in the selected source. For a point cloud of only position data, the Color Source options are X, Y, Z, and User Specified. Point clouds for depth image and lidar data include these additional color source options:

Point Cloud Data SourceColor Source Options
Depth image (RGB-D sensor)Color, Row, and Column
LidarIntensity, Range, Azimuth angle, Elevation angle, Row, and Column

Pan, Zoom in, and Zoom outManeuver the point cloud in the figure, or zoom the point cloud figure in or out.
Restore ViewRestore the original view of the axes.

Move Camera Through Scene

To navigate into a point cloud and observe the scene, use these keyboard shortcuts:

ActionKeyboard ShortcutExample
Move forward or backwards through the scene. The camera and the target can move.

w — Forward

s — Backward

Animation displaying forward, backward, left, and right movement.

Move left or right through the scene. The camera and the target can move.

a — Left

d — Right

Look around the scene (pitch/yaw rotation of the camera). Camera position is fixed, target moves.

Up arrow — Camera pitches up

Down arrow — Camera pitches down

Left arrow — Camera turns left in yaw

Right arrow — Camera turns right in yaw

Animation displaying the view in a scene using pitch and yaw capability.

Roll the scene (roll rotation of the camera).

q — Camera moves clockwise. (Scene appears to move counterclockwise.)

e — Camera moves counterclockwise. (Scene appears to move clockwise.)

Animation displaying the view in a scene using the roll capability.

Rotate the scene (rotate the camera around the point cloud). Camera position changes, target is fixed.

Shift + Left or Right — Camera orbits horizontally around the point cloud. (Scene appears to stand still as camera moves externally around it horizontally.)

Shift + Up or Down — Camera orbits vertically around the point cloud. (Scene appears to stand still as camera moves externally around it vertically.)

Animation displaying the view with the camera rotating around a point capability.

Zoom in or out.

z — Zoom in

x — Zoom out

Animation displaying the view in a scene using the zoom capability.

Look at a view plane.

1 — XY

2 — YX

3 — XZ

4 — ZX

5 — YZ

6 — ZY

Camera positioned in the selected plane with a line of sight to the center of the plot.

Animation displaying the view in a scene using view plane capability.

Switch between rotate and pan.Spacebar — Press and hold the spacebar to switch the interaction to pan. Release the spacebar to switch back to rotate.

Animation displaying the view in a scene using the ability to switch between rotate and pan.

Rotate in X-, Y-, and Z- dimensions.T — Adds rotate interaction in the third dimension.

Animation displaying the view in a scene using the capability to rotate between the X-, Y-, and Z- dimensions.

Color Formats

Color NameShort NameRGB TripletAppearance
"red""r"[1 0 0]

Sample of the color red

"green""g"[0 1 0]

Sample of the color green

"blue""b"[0 0 1]

Sample of the color blue

"cyan" "c"[0 1 1]

Sample of the color cyan

"magenta""m"[1 0 1]

Sample of the color magenta

"yellow""y"[1 1 0]

Sample of the color yellow

"black""k"[0 0 0]

Sample of the color black

"white""w"[1 1 1]

Sample of the color white

Performance and Tips

  • To improve performance, the function automatically downsamples the rendered point cloud when you rotate, pan, or zoom in or out by clicking the mouse. Downsampling is not applied for zoom in or out by using the mouse scroll mechanism. When using data tips, the figure does not apply downsampling. The downsampling occurs only for rendering the point cloud and does not affect the saved points.

  • The keyboard shortcuts described in Move Camera Through Scene are not supported when loading a saved figure or for popped-out windows using Live Editor.

  • When you reload a saved figure, any action on the figure resets the vertical axis to the z-axis and in the up direction.

  • To visualize a large point cloud (greater than one million points), use the pcviewer object.

Version History

Introduced in R2015b

expand all