Main Content


Register two point clouds using NDT algorithm



tform = pcregisterndt(moving,fixed,gridStep) returns the rigid transformation that registers the moving point cloud with the fixed point cloud. The point clouds are voxelized into cubes of size gridStep.

The registration algorithm is based on the normal-distributions transform (NDT) algorithm [1] [2]. Best performance of this iterative process requires adjusting properties for your data. To improve accuracy and efficiency of registration, consider downsampling the point clouds by using pcdownsample before using pcregisterndt.

[tform,movingReg] = pcregisterndt(moving,fixed,gridStep) also returns the transformed point cloud that aligns with the fixed point cloud.

[___,rmse] = pcregisterndt(moving,fixed,gridStep) also returns the root mean square error of the Euclidean distance between the aligned point clouds, using any of the preceding syntaxes.

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


collapse all

Load point cloud data.

ld = load('livingRoom.mat');
moving = ld.livingRoomData{1};
fixed = ld.livingRoomData{2};

Figure contains an axes. The axes contains 2 objects of type scatter.

To improve the efficiency and accuracy of the NDT registration algorithm, downsample the moving point cloud.

movingDownsampled = pcdownsample(moving,'gridAverage',0.1);

Voxelize the point cloud into cubes of sidelength 0.5. Apply the rigid registration using the NDT algorithm.

gridStep = 0.5;
tform = pcregisterndt(movingDownsampled,fixed,gridStep);

Visualize the alignment.

movingReg = pctransform(moving,tform);

Figure contains an axes. The axes contains 2 objects of type scatter.

Input Arguments

collapse all

Moving point cloud, specified as a pointCloud object.

Fixed point cloud, specified as a pointCloud object.

Size of the 3-D cube that voxelizes the fixed point cloud, specified as a positive scalar.

Data Types: single | double

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: 'MaxIterations',20 stops the NDT algorithm after 20 iterations.

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.

Expected percentage of outliers with respect to a normal distribution, specified as the comma-separated pair consisting of 'OutlierRatio' and a scalar in the range [0, 1). The NDT algorithm assumes a point is generated by a mixture of a normal distribution for inliers and a uniform distribution for outliers. A larger value of 'OutlierRatio' reduces the influence of outliers.

Data Types: single | double

Maximum number of iterations before NDT stops, specified as the comma-separated pair consisting of 'MaxIterations' and a nonnegative integer.

Data Types: single | double

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

Data Types: single | double

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

Data Types: logical

Output Arguments

collapse all

Rigid transformation, returned as a rigid3d object. tform describes the rigid 3-D transformation that registers the moving point cloud, moving, to the fixed point cloud, fixed.

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

Root mean square error, returned as a positive number. rmse is the Euclidean distance between the aligned point clouds.


collapse all


  • 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

expand all

Behavior changed in R2020a


[1] Biber, P., and W. Straßer. “The Normal Distributions Transform: A New Approach to Laser Scan Matching.” Proceedings of IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS). Las Vegas, NV. Vol. 3, November 2003, pp. 2743–2748.

[2] Magnusson, M. “The Three-Dimensional Normal-Distributions Transform — an Efficient Representation for Registration, Surface Analysis, and Loop Detection.” Ph.D. Thesis. Örebro University, Örebro, Sweden, 2013.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Introduced in R2018a