Registration: from rigid to non-rigid

Capture the same thing twice and the two data sets will not line up. Finding the transform that lays one over the other, so the same spot lands in the same place, is called registration. Press one step at a time: pair each point with its nearest neighbor, then move to fit those pairs.

Short answer. Registration finds the transform that lays the moving side over the fixed side. If the transform may only turn and shift, it is rigid registration. If every spot may move its own way, it is non-rigid registration. For point clouds where nobody knows which point belongs with which, ICP (iterative closest point) repeats "pair each point with the nearest one, then turn and shift to fit those pairs".

Green is the fixed side (target), orange the moving side (source). RMSE (root mean square error) squares the distances between partners, averages them and takes the square root; 0 means a perfect overlap. Orange is a copy of green, turned around the origin and shifted by (0.5, 0.5), so the right partner of orange point i is green point i. ICP does not know this; the colors for right and wrong pairs are only for you. The gaps between points are uneven on purpose. With an even 0.5 spacing, even a slightly-off start stopped one gap away from the answer (RMSE 0.21).

Try this. 1. As it starts (slightly off), press "Next" to the end. In five iterations RMSE drops 0.7 → 0.34 → 0.22 → 0.17 → 0.08 → 0 and the right pairs grow 5, 6, 8, 10, 12, reaching the answer. Only five pairs are right in the first iteration, yet after moving, the pairs get better. 2. Press "Far off" and go to the end. RMSE drops from 1.93 to 0.72 and stops, but the right pairs stay at 0 the whole way. Four points of the orange upright bar end up paired with the green flat bar, and the five points of the orange flat bar with the green upright bar. A falling RMSE does not mean you reached the right place.

Definitions

The text below explains with the points and the sheet on a plane in the lab. Here are the definitions of the ideas this page uses. A point's coordinates are written as a vector x, and a transform is written in the direction this page uses: it moves points of the moving side (source) onto the fixed side (target). Some tools write it the other way (section 1).

registration
Given two data sets of the same thing, keeping the fixed side as it is and finding a transform T that, applied to the moving side, brings the same places to the same positions.
correspondence
When a point aᵢ on the moving side and a point bᵢ on the fixed side stand for the same place, the pair aᵢ ↔ bᵢ.
rigid transformation
A transform made of a rotation matrix R and a translation vector t. R satisfies Rᵀ R = I and det R = 1, so it does not change distances or angles between points. In 2D it has 3 degrees of freedom (one rotation angle, two for translation).

𝐱′=R𝐱+𝐭

affine transformation
A linear transformation by a matrix A plus a translation t. Besides rotation and translation, it can shear and scale each axis by a different amount. In 2D it has 6 degrees of freedom (4 matrix entries, 2 for translation).

𝐱′=A𝐱+𝐭

ICP (iterative closest point)
When the correspondences are unknown, a method that repeats two things: for each moving-side point moved by the current transform T, take the closest fixed-side point as its pair, then find the T that makes the objective E for those pairs smallest. The point-to-point and point-to-plane objectives are below, where nᵢ is the normal at bᵢ.

E=∑i=1n‖T(𝐚i)−𝐛i‖2

E=∑i=1n((T(𝐚i)−𝐛i)·𝐧i)2

non-rigid transformation, displacement field
A transform that moves each position x by its own displacement vector u(x). This u is called the displacement field. Because it has many degrees of freedom, a regularization that asks the displacement field to be smooth is added.

𝐱′=𝐱+𝐮(𝐱)

1. What registration is: the fixed side and the moving side

You have two data sets of the same object, place or person: photos from two drone flights, two scans from different sides as a point cloud (a set of points, each with x, y and z), or a CT and an MRI of the same patient. They were captured from different places and angles, so laid on top of each other they do not match. Keep one still, move the other, and find the transform that brings the same spot to the same place. That is registration.

The side you keep still is the fixed side, and the side you move is the moving side. For images they are the fixed image and the moving image. For point clouds they are the target and the source. The SimpleITK documentation describes registration as estimating the transform that maps points from the fixed image to corresponding points in the moving image, while ICP in Open3D finds the transform that aligns the source to the target. The two tools write the transform in opposite directions, so when you switch tools, check whether you need the inverse.

Knowing which point belongs with which is the correspondence. If you know it, the problem is easy (section 4). If not, you must find the correspondence and the transform together (section 5).

2. The ladder of transforms and degrees of freedom

The first choice is how free the transform may be. Going down, it can do more, and it has more numbers to decide (degrees of freedom). The counts are for 2D.

TransformWhat it doesDegrees of freedom (2D)What stays the same
TranslationShift only2Distances, angles, direction
RigidTurn + shift3Distances, angles
Similarity+ size (same ratio across and up)4Angles, ratios of distances
Affine+ shear, a different size per axis6Straight lines, parallel lines
Non-rigidA different shift at each spotManyOnly the smoothness you ask for (section 6)

An affine transform is a linear transformation done by one matrix, plus a shift (4 matrix entries + 2 for the shift = 6). The turn in a rigid transform is an orthogonal matrix, which keeps lengths and angles. SimpleITK offers these transform types: translation, Euler (the rigid transform in 2D and 3D), similarity, affine, BSpline and displacement field. Non-rigid registration is also called deformable registration.

3. The four parts of registration

The SimpleITK documentation says registration needs four choices.

PartWhat it doesExamples
TransformWhich ways the moving side may moveThe ladder in section 2
Similarity metricOne number for how well the two overlap nowMean squares, correlation, mutual information (Mattes and others), Demons. For points, the sum of squared distances between partners
OptimizerAdjusts the transform's numbers in the direction that improves the metricMethods like gradient descent
InterpolationWhen a moved spot falls between pixels, fills in its value from the nearby pixelsSimpleITK documentation: linear interpolation is usually enough

ICP fills the four like this: the transform is rigid, the metric is the sum of squared distances between partners, the optimizer is the closed formula of section 4 (solved in one go), and since it only moves points and never reads pixel values, it needs no interpolation.

4. Rigid registration by hand: when the pairs are known

If you know the pairs (aᵢ with bᵢ), the best turn and shift take only a few lines. You are making the sum of squared distances as small as possible, so it is a least squares problem.

goal         the θ and t that make Σ |R(θ) aᵢ + t − bᵢ|² as small as possible
centers      ā = (a₁ + … + aₙ) ÷ n,    b̄ = (b₁ + … + bₙ) ÷ n
subtract     aᵢ′ = aᵢ − ā,    bᵢ′ = bᵢ − b̄
angle        θ = atan2( Σ (a′ₓ b′ᵧ − a′ᵧ b′ₓ),  Σ (a′ₓ b′ₓ + a′ᵧ b′ᵧ) )
shift        t = b̄ − R(θ) ā
moved point  aᵢ  →  R(θ) aᵢ + t

Why this formula. Once the two centers match, the shift drops out and only the turn is left. What remains is to find the θ that makes Σ bᵢ′ · R(θ) aᵢ′ as large as possible. Written out, that is cos θ × (the second sum in the angle line) + sin θ × (the first sum), which is largest at θ = atan2(first sum, second sum).

Hand example. The moving points a = (0, 0), (3, 0), (0, 3) pair in order with the fixed points b = (5, 1), (5, 4), (2, 1).

iaᵢbᵢaᵢ′bᵢ′a′ₓb′ᵧ − a′ᵧb′ₓa′ₓb′ₓ + a′ᵧb′ᵧ
1(0, 0)(5, 1)(−1, −1)(1, −1)20
2(3, 0)(5, 4)(2, −1)(1, 2)50
3(0, 3)(2, 1)(−1, 2)(−2, −1)50
  1. Centers. ā = (1, 1), b̄ = (4, 2). The aᵢ′ and bᵢ′ in the table have these subtracted.
  2. Angle. First sum 2 + 5 + 5 = 12, second sum 0 + 0 + 0 = 0. θ = atan2(12, 0) = 90°.
  3. Shift. R(90°) sends (x, y) to (−y, x). t = (4, 2) − R(90°)(1, 1) = (4, 2) − (−1, 1) = (5, 1).
  4. Check. a₂ = (3, 0) → R(90°)(3, 0) = (0, 3) → + (5, 1) = (5, 4) = b₂. All three points land exactly on their partners.

In 3D a turn cannot be written as one angle, so this formula does not carry over as it is. The rotation matrix is usually found with the singular value decomposition (SVD).

5. ICP: when the pairs are unknown

Real point clouds do not come with pairs. ICP (iterative closest point) assumes "the nearest point right now is probably the partner", solves section 4, moves, and pairs up again, over and over. In the Open3D documentation the inputs are the source and target point clouds and an initial transformation that roughly aligns the source to the target.

input   source points, target points, initial transformation T
repeat
  1. pair:    for each source point moved by T, take the nearest target point as its partner
  2. update:  find the T that makes the objective over those pairs smallest (point-to-point: section 4)
  3. stop:    (in this page's experiment) stop when the pairs are the same as last iteration

Finding the single nearest point is the same search as k-nearest neighbors with k = 1. The Open3D documentation gives two objectives.

point-to-point   E = Σ |T(aᵢ) − bᵢ|²
point-to-plane   E = Σ ((T(aᵢ) − bᵢ) · nᵢ)²
RMSE             √(E ÷ n)        (point-to-point, n pairs)

Point-to-point counts the full squared distance between partners. Point-to-plane counts only the distance straight out of the target surface, so sliding along the surface is not punished. The Open3D documentation says point-to-plane converges faster than point-to-point. Results are judged by fitness (the share of points with an inlier correspondence; higher is better) and inlier RMSE (the RMSE of the inlier correspondences; lower is better). This page's experiment pairs every point with no distance limit and measures RMSE.

The start has to be roughly right. Because the partner is "the nearest point", a start that is far off begins with wrong pairs. ICP moves to the best place for those wrong pairs, makes wrong pairs again, and at some point the pairs stop changing and it stops. A place like this, where no better direction can be seen nearby, is a local minimum. "Far off" in experiment 1 is one. That is why the Open3D documentation says the initial transformation usually comes from global registration.

6. Non-rigid registration: a different shift at each spot

When the shape itself changes, like a breathing organ or a face changing expression, turning and shifting cannot match it. Give every spot x its own shift vector u(x) and move x to x + u(x). This u is the displacement field. A separate shift for every pixel is far too many numbers, so a common way is to move only the control points of a coarse grid and fill the space between them smoothly. That is the B-spline transform.

With that much freedom, the board can fold or overlap in strange ways just to improve the metric. So non-rigid registration also adds regularization that asks the displacement field to stay smooth.

The bending here is drawn with simple bilinear interpolation, not with a B-spline. It mixes straight between control points, so the board shows a crease along the rows and columns of control points. The green box is the orange box bent by moving only control point 5 up by 1.5.

moved spot  x  →  x + u(x)
u(x)        = (1 − s)(1 − r) d₁ + s (1 − r) d₂ + (1 − s) r d₃ + s r d₄

Try this. 1. Stay in rigid mode and move the sliders. RMSE starts at 0.62, and raising shift y to 0.6 gives 0.21. Adding a 10° turn makes it worse, 0.37. The best rigid place found with the formula of section 4 is also turn 0°, shift (0, 0.58), RMSE 0.21, so no slider setting gets below that. 2. Switch to non-rigid and raise control point 5 by 1: RMSE 0.21. Raise it to 1.5: 0. The board bends and the shapes overlap exactly. 3. Raise point 2 (top middle) by 1.5 instead of point 5: 0.5. Which control point you move matters.

7. When to use what

OptionGoodBadUse it when
Rigid registrationFew numbers to decide (3 in 2D). It never changes the shape, so it cannot bend in strange waysCannot match a shape that changed (the floor of 0.21 in experiment 2)Bones, buildings, scanned solid objects. Joining point clouds captured several times by drone or lidar
Similarity or affine registrationAlso matches size and shearCannot match bendingStitching camera photos (affine or beyond)
Non-rigid registration (B-spline, displacement field)Bends differently at each spot to matchMany numbers to decide. Without regularization it can fold in strange waysA breathing organ, a face changing expression
ICP point-to-pointNo correspondence needed. Once the pairs are set, solved in one goThe start has to be roughly right (experiment 1)Point clouds. Get the initial transformation from global registration
ICP point-to-planeOpen3D documentation: converges faster than point-to-pointEvery target point needs a normalPoint clouds scanned from surfaces

Where it is used

Common questions

Are registration and ICP the same thing?

No. Registration is the name of the whole job of finding a transform that lays one data set over another. ICP is one method inside it, for two point sets whose correspondence is unknown. To register images, you usually measure a similarity metric on the pixel brightness and let an optimizer adjust the transform instead.

What do I do when ICP stops in the wrong place?

ICP takes the nearest point as the partner, so when the start is far off it begins with wrong pairs and can stop in the wrong place. The L turned by 150° in experiment 1 on this page does exactly that. That is why ICP is given an initial transformation that roughly aligns the source to the target. The Open3D documentation says this initial transformation usually comes from global registration.

What are fitness and inlier RMSE?

They are the two numbers Open3D uses to evaluate an ICP result. Fitness is the share of points that have an inlier correspondence (a partner found within a set distance); higher is better. Inlier RMSE is the RMSE of those inlier correspondences; lower is better.

Words

Plain words used hereWhat books call it
finding the transform that lays one over the otherregistration, image registration
the side kept still · the side movedfixed image · moving image, target · source
which point belongs with whichcorrespondence, corresponding points
turn + shift · plus size · plus shearrigid transformation · similarity transformation · affine transformation
a different shift at each spotnon-rigid registration, deformable registration, displacement field
how many numbers a transform hasdegrees of freedom
how well they overlapsimilarity metric: mean squares, correlation, mutual information
the way to adjust the numbers · filling in values between pixelsoptimizer · interpolation, bilinear interpolation
pairing with the nearest point, again and againICP (iterative closest point)
distance between partners · distance straight out of the surfacepoint-to-point · point-to-plane, normal
the rough starting placeinitial transformation, global registration
stopping in the wrong placelocal minimum
average distance between partners · share of points with a partnerRMSE (root mean square error) · fitness, inlier
bending the board with grid points · keeping it smoothB-spline transform, control point · regularization
the middle of a setcentroid

Sources

← 3D vision: voxels, point clouds and NeRFConfusion matrix, precision, recall and F1 →