Register two point clouds using ICP algorithm
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
Point cloud normals are required by the registration algorithm
when you select the
'pointToPlane' metric. Therefore,
if the input point cloud’s
is empty, the function fills it. When the function fills the
it uses 6 points to fit the local plane. Six points may not work under
all circumstances. If registration with the
fails, consider calling the
which allows you to select the number of points to use.
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.
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
comma-separated pairs of
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
'pointToPoint'sets the metric for the ICP algorithm to the
Metric — Minimization metric
'pointToPoint' (default) |
Minimization metric, specified as the comma-separated pair consisting
Metric' and the
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.
reduce the number of iterations to process. However, this metric requires
extra algorithmic steps within each iteration. The
improves the registration of planar surfaces.
Downsample Method Selection:
Downsample the point clouds using the
Use either the
'gridAverage' input for the
pcdownsample function according to the
Metric table below.
|Metric||Moving PointCloud Downsample Method||Fixed Point Cloud Downsample Method|
Extrapolate — Extrapolation
false (default) |
Extrapolation, specified as the comma-separated pair consisting
Extrapolate' and the boolean
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 . Setting this property to
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
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
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
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.
rigid3d object contains a translation that moves
the center of the moving point cloud to the center of the fixed point
Verbose — Display progress information
true (default) |
Display progress information, specified as the comma-separated
pair consisting of '
Verbose' and a logical scalar.
true to display
tform — Rigid transformation
Rigid transformation, returned as a
rigid3d object. The rigid transformation registers a moving
point cloud to a fixed point cloud. The
describes the rigid 3-D transform. The iterative closest point (ICP)
algorithm estimates the rigid transformation between the moving and fixed
movingReg — Transformed point cloud
Transformed point cloud, returned as a
pointCloud object. The transformed point cloud is
aligned with the fixed point cloud.
rmse — Root mean square error
Root mean square error, returned as a positive numeric value that represents the Euclidean distance between the inlier aligned points.
For ground vehicle point clouds, you can improve performance and accuracy by removing the ground using
segmentGroundFromLidarDatabefore registration. For details on how to do this, see the helper function,
helperProcessPointCloudin the Build a Map from Lidar Data (Automated Driving Toolbox) example.
 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.
 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.