Main Content

pcregrigid

(To be removed) Register two point clouds using ICP algorithm

pcregrigid will be removed in a future release. Use pcregistericp instead.

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

  1. Load point cloud data.

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

  2. 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);
  3. Transform the point cloud.

    ptCloudTformed = pctransform(ptCloud,tform1);
    
    figure
    pcshow(ptCloudTformed);
    title("Transformed Teapot");
  4. Apply the rigid registration.

    tform = pcregrigid(ptCloudTformed,ptCloud,Extrapolate=true);
  5. Compare the result with the true transformation.

    disp(tform1.T);
    tform2 = invert(tform);
    disp(tform2.T);

Input Arguments

collapse all

Moving point cloud, specified as a pointCloud object.

Fixed point cloud, specified as a pointCloud object.

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: 'Metric','pointToPoint' sets the metric for the ICP algorithm to the 'pointToPoint'.

Minimization metric, specified as the comma-separated pair consisting of 'Metric' and 'pointToPoint' or 'pointToPlane'. 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.

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

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.

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.

Version History

Introduced in R2015a

collapse all

R2023b: pcregrigid will be removed in a future release

The pcregrigid function will be removed in a future release. Use the pcregistericp object to perform ICP point cloud registration, instead.