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).
- 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).
- 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ᵢ.
- 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.
| Transform | What it does | Degrees of freedom (2D) | What stays the same |
|---|---|---|---|
| Translation | Shift only | 2 | Distances, angles, direction |
| Rigid | Turn + shift | 3 | Distances, angles |
| Similarity | + size (same ratio across and up) | 4 | Angles, ratios of distances |
| Affine | + shear, a different size per axis | 6 | Straight lines, parallel lines |
| Non-rigid | A different shift at each spot | Many | Only 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.
| Part | What it does | Examples |
|---|---|---|
| Transform | Which ways the moving side may move | The ladder in section 2 |
| Similarity metric | One number for how well the two overlap now | Mean squares, correlation, mutual information (Mattes and others), Demons. For points, the sum of squared distances between partners |
| Optimizer | Adjusts the transform's numbers in the direction that improves the metric | Methods like gradient descent |
| Interpolation | When a moved spot falls between pixels, fills in its value from the nearby pixels | SimpleITK 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
aᵢ: point i on the moving side.bᵢ: its partner on the fixed side.n: the number of pairs.ā,b̄: the center (centroid, the mean of the coordinates) of each set.aᵢ′,bᵢ′: coordinates with the center subtracted. The smallₓandᵧmean the across and up values.R(θ): the rotation matrix that turns by θ,[[cos θ, −sin θ], [sin θ, cos θ]].t: the shift (across, up).Σ: add up over i = 1 to n.atan2(y, x): the angle of the point (x, y), from −180° to 180° (most languages have it).
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).
| i | aᵢ | bᵢ | aᵢ′ | bᵢ′ | a′ₓb′ᵧ − a′ᵧb′ₓ | a′ₓb′ₓ + a′ᵧb′ᵧ |
|---|---|---|---|---|---|---|
| 1 | (0, 0) | (5, 1) | (−1, −1) | (1, −1) | 2 | 0 |
| 2 | (3, 0) | (5, 4) | (2, −1) | (1, 2) | 5 | 0 |
| 3 | (0, 3) | (2, 1) | (−1, 2) | (−2, −1) | 5 | 0 |
- Centers. ā = (1, 1), b̄ = (4, 2). The aᵢ′ and bᵢ′ in the table have these subtracted.
- Angle. First sum 2 + 5 + 5 = 12, second sum 0 + 0 + 0 = 0. θ = atan2(12, 0) = 90°.
- Shift. R(90°) sends (x, y) to (−y, x). t = (4, 2) − R(90°)(1, 1) = (4, 2) − (−1, 1) = (5, 1).
- 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)
T(aᵢ): source point i moved by the transform T.bᵢ: the target point paired with it.nᵢ: the normal of target point bᵢ (a vector of length 1 standing straight out of the surface there).·is the dot product.E: the objective (smaller means a better overlap).n: the number of 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.
You can also drag the control points in the picture.
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₄
u(x): the shift at spot x (the displacement field).d₁, d₂, d₃, d₄: how far the four corner control points of the cell around x have been moved (top left, top right, bottom left, bottom right).s,r: where x sits inside the cell, across and down. Left and top are 0, right and bottom are 1.
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
| Option | Good | Bad | Use it when |
|---|---|---|---|
| Rigid registration | Few numbers to decide (3 in 2D). It never changes the shape, so it cannot bend in strange ways | Cannot 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 registration | Also matches size and shear | Cannot match bending | Stitching camera photos (affine or beyond) |
| Non-rigid registration (B-spline, displacement field) | Bends differently at each spot to match | Many numbers to decide. Without regularization it can fold in strange ways | A breathing organ, a face changing expression |
| ICP point-to-point | No correspondence needed. Once the pairs are set, solved in one go | The start has to be roughly right (experiment 1) | Point clouds. Get the initial transformation from global registration |
| ICP point-to-plane | Open3D documentation: converges faster than point-to-point | Every target point needs a normal | Point clouds scanned from surfaces |
Where it is used
- Joining point clouds. Bringing point clouds captured several times by drone or lidar into one coordinate system is registration too (3D vision).
- Medical images. Lay a CT and an MRI of the same patient, or scans from different days, on top of each other to compare the same spot.
- Photos. Stitch several photos into one, or overlay two photos of the same place taken at different times to find what changed.
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 here | What books call it |
|---|---|
| finding the transform that lays one over the other | registration, image registration |
| the side kept still · the side moved | fixed image · moving image, target · source |
| which point belongs with which | correspondence, corresponding points |
| turn + shift · plus size · plus shear | rigid transformation · similarity transformation · affine transformation |
| a different shift at each spot | non-rigid registration, deformable registration, displacement field |
| how many numbers a transform has | degrees of freedom |
| how well they overlap | similarity metric: mean squares, correlation, mutual information |
| the way to adjust the numbers · filling in values between pixels | optimizer · interpolation, bilinear interpolation |
| pairing with the nearest point, again and again | ICP (iterative closest point) |
| distance between partners · distance straight out of the surface | point-to-point · point-to-plane, normal |
| the rough starting place | initial transformation, global registration |
| stopping in the wrong place | local minimum |
| average distance between partners · share of points with a partner | RMSE (root mean square error) · fitness, inlier |
| bending the board with grid points · keeping it smooth | B-spline transform, control point · regularization |
| the middle of a set | centroid |
Sources
- Open3D documentation: ICP registration (the inputs of ICP and the initial transformation, global registration, the loop of finding pairs and updating the transform, the point-to-point and point-to-plane objectives and their convergence speed, fitness and inlier RMSE).
- SimpleITK documentation: Registration Overview (the definition of registration, the four choices of transform, similarity metric, optimizer and interpolator, the types of transforms, the types of similarity metrics, and that linear interpolation is usually enough).
← 3D vision: voxels, point clouds and NeRFConfusion matrix, precision, recall and F1 →