pcregistericp
Register two point clouds using ICP algorithm
Description
tform = pcregistericp(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
pcregistericp 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.
[___,rmse] = pcregistericp(moving,fixed)
additionally returns the root mean square error of the Euclidean distance
between the inlier aligned points, using any of the preceding syntaxes.
[___] = pcregistericp(moving,fixed,Name,Value)
uses additional options specified by one or more Name,Value
pair arguments.
Examples
Align Two Point Clouds Using ICP Algorithm
Load point cloud data.
ptCloud = pcread('teapot.ply');
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);
pcshow(ptCloudTformed);
title('Transformed Teapot');
Apply the rigid registration.
tform = pcregistericp(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
moving — Moving point cloud
pointCloud object
Moving point cloud, specified as a pointCloud object.
fixed — Fixed point cloud
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 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.
'Metric' — Minimization metric
'pointToPoint' (default) | 'pointToPlane'
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 the
pcdownsample function according to the
Metric table below.
MetricMoving PointCloud Downsample
MethodFixed Point Cloud Downsample
Method'pointToPoint''random''random'
'gridAverage''gridAverage'
'pointToPlane''gridAverage''gridAverage'
'random''nonuniformGridSample'
'Extrapolate' — Extrapolation
false (default) | true
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.
'InlierRatio' — Percentage of inliers
1 (default) | scalar
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.
'MaxIterations' — Maximum number of iterations
20 (default) | positive integer
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' — Tolerance between consecutive ICP iterations
[0.01, 0.05] (default) | 2-element vector
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 degrees. The algorithm stops when the average difference
between estimated rigid transformations in the three most recent
consecutive iterations falls below the specified tolerance value.
'InitialTransform' — Initial rigid transformation
rigid3d object
Initial rigid transformation, specified as the comma-separated pair
consisting of 'InitialTransform' and a rigid3d object. The initial rigid transformation is useful
when you provide an external coarse estimation.
The rigid3d object contains a translation that moves
the center of the moving point cloud to the center of the fixed point
cloud.
'Verbose' — Display progress information
true (default) | false
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
tform — Rigid transformation
rigid3d object
Rigid transformation, returned as a rigid3d object. The rigid transformation registers a moving
point cloud to a fixed point cloud. The rigid3d object
describes the rigid 3-D transform. The iterative closest point (ICP)
algorithm estimates the rigid transformation between the moving and fixed
point clouds.
movingReg — Transformed point cloud
pointCloud object
Transformed point cloud, returned as a pointCloud object. The transformed point cloud is
aligned with the fixed point cloud.
rmse — Root mean square error
positive numeric
Root mean square error, returned as a positive numeric value that represents the Euclidean
distance between the inlier aligned points.
Algorithms
Tips
For ground vehicle point clouds, you can improve performance and accuracy
by removing the ground using pcfitplane or segmentGroundFromLidarData before registration. For details
on how to do this, see the helper function,
helperProcessPointCloud in the Build a Map from Lidar Data(Automated Driving Toolbox)
example.
To merge more than two point clouds, you can use pccat function instead of the pcmerge function.
Compatibility Considerations
The pcregistericp function returns a rigid3d object
Behavior changed in R2020a
Starting in R2020a, the pcregistericp function returns a rigid3d
object. Prior to R2020a, the function returned an affine3d
object.
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 R2018a