Register two point clouds using ICP algorithm
pcregrigid is not recommended. Use
tform = pcregrigid(moving,fixed)
[tform,movingReg] = pcregrigid(moving,fixed)
[___,rmse] = pcregrigid(moving,fixed)
[___] = pcregrigid(moving,fixed,Name,Value)
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
Point cloud normals are required by the registration algorithm when you
'pointToPlane' metric. Therefore, if the input
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.
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.
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 single 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
Minimization metric, specified as the comma-separated pair consisting
Metric' and the
'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
'pointToPlane' can reduce the number of
iterations to process. However, this metric requires extra algorithmic
steps within each iteration. The
metric 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||Point Cloud A Downsample Method||Point Cloud B Downsample Method|
Extrapolation, specified as the comma-separated pair consisting of
Extrapolate' and the boolean
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 . 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
'Tolerance'— Tolerance between consecutive ICP iterations
[0.01, 0.009](default) | 2-element vector
Tolerance between consecutive ICP iterations, specified as the
comma-separated pair consisting of '
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
'InitialTransform'— Initial rigid transformation
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
'Verbose'— Display progress information
Display progress information, specified as the comma-separated pair
consisting of '
Verbose' and a logical scalar. Set
true to display
tform— Rigid transformation
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.
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 the Euclidean distance between the aligned point clouds.
 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.