Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

pcregrigid

Register two point clouds using ICP algorithm

Syntax

tform = pcregrigid(moving,fixed)
[tform,movingReg] = pcregrigid(moving,fixed)
[___,rmse] = pcregrigid(moving,fixed)
[___] = pcregrigid(moving,fixed,Name,Value)

Description

example

tform = pcregrigid(moving,fixed) returns a rigid transformation that registers a moving point cloud to a fixed point cloud.

The registration algorithm is based on the "iterative closest point" (ICP) algorithm. Best performance of this iterative process requires adjusting properties for your data. Consider downsampling point clouds using pcdownsample before using pcregrigid to improve accuracy and efficiency of registration.

Point cloud normals are required by the registration algorithm when you select the 'pointToPlane' metric. Therefore, if the input point cloud’s Normal property is empty, the function fills it. When the function fills the Normal property, it uses 6 points to fit the local plane. Six points may not work under all circumstances. If registration with the 'pointToPlane' metric fails, consider calling the pcnormals function which allows you to select the number of points to use.

[tform,movingReg] = pcregrigid(moving,fixed) additionally returns the transformed point cloud that aligns with the fixed point cloud.

[___,rmse] = pcregrigid(moving,fixed) additionally returns the root mean squared error of the Euclidean distance between the aligned point clouds, using any of the preceding syntaxes.

[___] = pcregrigid(moving,fixed,Name,Value) uses additional options specified by one or more Name,Value pair arguments.

Examples

collapse all

Load point cloud data.

ptCloud = pcread('teapot.ply');
figure
pcshow(ptCloud); 
title('Teapot');

Create a transform object with 30 degree rotation along z -axis and translation [5,5,10].

A = [cos(pi/6) sin(pi/6) 0 0; ...
    -sin(pi/6) cos(pi/6) 0 0; ...
            0         0  1 0; ...
            5         5 10 1];
tform1 = affine3d(A);

Transform the point cloud.

ptCloudTformed = pctransform(ptCloud,tform1);

figure
pcshow(ptCloudTformed);
title('Transformed Teapot');

Apply the rigid registration.

tform = pcregrigid(ptCloudTformed,ptCloud,'Extrapolate',true);

Compare the result with the true transformation.

disp(tform1.T);
    0.8660    0.5000         0         0
   -0.5000    0.8660         0         0
         0         0    1.0000         0
    5.0000    5.0000   10.0000    1.0000
tform2 = invert(tform);
disp(tform2.T);
    0.8660    0.5000   -0.0000         0
   -0.5000    0.8660    0.0000         0
    0.0000   -0.0000    1.0000         0
    5.0000    5.0000   10.0000    1.0000

Input Arguments

collapse all

Moving point cloud, specified as a pointCloud object.

Fixed point cloud, specified as a pointCloud object.

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 single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Metric','pointToPoint' sets the metric for the ICP algorithm to the 'pointToPoint' character vector.

collapse all

Minimization metric, specified as the comma-separated pair consisting of 'Metric' and the 'pointToPoint' or 'pointToPlane' character vector. The rigid transformation between the moving and fixed point clouds are estimated by the iterative closest point (ICP) algorithm. The ICP algorithm minimizes the distance between the two point clouds according to the given metric.

Setting 'Metric' to 'pointToPlane' can reduce the number of iterations to process. However, this metric requires extra algorithmic steps within each iteration. The 'pointToPlane' metric improves the registration of planar surfaces.

Downsample Method Selection:
Downsample the point clouds using the pcdownsample function. Use either the 'random' or 'gridAverage' input for thepcdownsample function according to the Metric table below.

MetricPoint Cloud A Downsample MethodPoint Cloud B Downsample Method
'pointToPoint''random''random'
'gridAverage''gridAverage'
'pointToPlane''gridAverage''gridAverage'
'random''nonuniformGridSample'

collapse all

Extrapolation, specified as the comma-separated pair consisting of 'Extrapolate' and the boolean true or false. When you set this property to true, the function adds an extrapolation step that traces out a path in the registration state space, that is described in [2]. Setting this property to true can reduce the number of iterations to converge.

Percentage of inliers, specified as the comma-separated pair consisting of 'InlierRatio' and a scalar value. Use this value to set a percentage of matched pairs as inliers. A pair of matched points is considered an inlier if its Euclidean distance falls within the percentage set of matching distances. By default, all matching pairs are used.

Maximum number of iterations, specified as the comma-separated pair consisting of 'MaxIterations' and a positive integer. This value specifies the maximum number of iterations before ICP stops.

Tolerance between consecutive ICP iterations, specified as the comma-separated pair consisting of 'Tolerance' and a 2-element vector. The 2-element vector, [Tdiff, Rdiff], represents the tolerance of absolute difference in translation and rotation estimated in consecutive ICP iterations. Tdiff measures the Euclidean distance between two translation vectors. Rdiff measures the angular difference in radians. The algorithm stops when the average difference between estimated rigid transformations in the three most recent consecutive iterations falls below the specified tolerance value.

Initial rigid transformation, specified as the comma-separated pair consisting of 'InitialTransform' and an affine3d object. The initial rigid transformation is useful when you provide an external coarse estimation.

Display progress information, specified as the comma-separated pair consisting of 'Verbose' and a logical scalar. Set Verbose to true to display progress information.

Output Arguments

collapse all

Rigid transformation, returned as an affine3d object. The rigid transformation registers a moving point cloud to a fixed point cloud. The affine3d object describes the rigid 3-D transform. The iterative closest point (ICP) algorithm estimates the rigid transformation between the moving and fixed point clouds.

Transformed point cloud, returned as a pointCloud object. The transformed point cloud is aligned with the fixed point cloud.

Root mean square error, returned as the Euclidean distance between the aligned point clouds.

Algorithms

References

[1] Chen, Y. and G. Medioni. “Object Modelling by Registration of Multiple Range Images.” Image Vision Computing. Butterworth-Heinemann . Vol. 10, Issue 3, April 1992, pp. 145-155.

[2] Besl, Paul J., N. D. McKay. “A Method for Registration of 3-D Shapes.” IEEE Transactions on Pattern Analysis and Machine Intelligence. Los Alamitos, CA: IEEE Computer Society. Vol. 14, Issue 2, 1992, pp. 239-256.

Introduced in R2015a