Algorithmadvanced
Robust point matching
Also called TPS-RPM, softassign point matching.
Softassign RPM (Gold et al.): match two point sets with outliers by alternating a soft match matrix, normalized by Sinkhorn with slacks, and a pose fit, while annealing the temperature.
- Solves
- Point cloud registration
- Time
- Θ(N K n m) worst · averageΘ(N n m) best
- Space
- Θ(n m) extra
- Where
- K = the number of Sinkhorn sweeps per update; N = the number of pose updates over the whole schedule; m = the number of points in Y; n = the number of points in X
- Model
- Real RAM
- Properties
- deterministicnot exactofflineiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Steven Gold, Anand Rangarajan, Chien Ping Lu, Suguna Pappu, Eric Mjolsness, 1998
Robust point matching (RPM) finds both a map between two point sets and the correspondence between their points, when neither is known, some points have no partner, and some are outliers. This page is about the softassign method of Gold, Rangarajan, Lu, Pappu and Mjolsness (1998). Instead of a hard 0 or 1 match for each pair, as in the assignment problem, it keeps a soft match matrix whose entries lie between 0 and 1. An extra slack row and slack column take the mass of points with no partner. The method alternates two steps: compute from the current map by softassign, an exponential of the distances followed by Sinkhorn normalization of the rows and columns, then fit the map to all pairs weighted by , as in weighted least squares. A temperature controls how soft is. It starts high, so that every point matches every point a little, and goes down slowly, so that hardens into a one-to-one match. This is deterministic annealing.
In plain words
You have two sets of dots and want to slide and stretch one onto the other, but you do not know which dot goes with which, and some dots have no partner.
Do not decide at once. Let each dot spread a little interest over all dots of the other set, more over near ones. Make sure each dot hands out exactly one unit of interest in total, with an extra "no partner" box that can take some of it. Now move the first set to best fit all these soft pairings at once. Then share out the interest again from the new position.
At first, keep the interest very spread out, so only the rough shape matters. Step by step, make it sharper, so that each dot ends up with one clear partner or with none.
The problem
Input. Two finite point sets in the plane, and , and a reward for each match.
Output. An affine map and a partial one-to-one match between and such that matched points lie close, , and as many points as possible are matched. Points with no good partner stay unmatched.
The energy that RPM lowers, at the inverse temperature , is
where the last sum runs over all entries, the slacks included, and each row of and each column of of , with its slack, sums to 1. The entropy term makes strictly convex in . As it vanishes and the best becomes a 0 or 1 matrix: a match pays off exactly when its squared distance is below . This is a hard, non-convex problem in the match and the map together.
The algorithm
RPM(X, Y, α, β₀, β_f, r)- 1
A ← I ; t ← 0 ; β ← β₀ - 2
while β ≤ β_f - 3
repeat a few times - 4
d_jk ← |x_j - A y_k - t|² - 5
M_jk ← exp(β(α - d_jk)) ; slack entries ← 1 - 6
Sinkhorn: divide each row of X, with its slack, by its sum - 7
divide each column of Y, with its slack, by its sum ; repeat L6 and L7 until the sums are 1 - 8
(A, t) ← argmin Σ M_jk |x_j - A y_k - t|² + λ|A - I|² - 9
β ← β · r - 10
return A, t, and the matches read off from M
Lines L4 to L7 are softassign. Line L5 turns each distance into a positive weight; the slack column entry of row and the slack row entry of column start at , the weight of a pair at the squared distance . Lines L6 and L7 are the iteration of Sinkhorn (1964): each step only scales a row or a column, so the result has the form . The slack column is part of the rows of , and the slack row is part of the columns of , but the slacks themselves have no sum constraint, so a point can give most of its mass to its slack. Line L8 is a small linear system: for each row of , three unknowns . Line L10 reads off a match when is the largest entry of its row and of its column and larger than both slacks.
Gold et al. handle rigid and affine maps in 2D and 3D, with a penalty on the affine part. The reference code uses the simple penalty with a weight that is strong at the start and weak at the end; this schedule is a choice of the code. It starts at , ends at , multiplies by , and does three updates and up to 30 Sinkhorn sweeps at each .
Example
Softassign on three and two points. Let , , the map the identity and . The squared distances from are 0 and 1, from are 1 and 0, and from are 9 and 4. After Sinkhorn has converged:
| , row | , row | , row | slacks of | slacks of | |
|---|---|---|---|---|---|
| 1 | 0.380, 0.138 | 0.141, 0.376 | 0.000, 0.014 | 0.482, 0.483, 0.986 | 0.479, 0.472 |
| 4 | 0.683, 0.013 | 0.013, 0.683 | 0.000, 0.000 | 0.304, 0.304, 1.000 | 0.304, 0.304 |
| 20 | 0.989, 0.000 | 0.000, 0.989 | 0.000, 0.000 | 0.004, 0.004, 1.000 | 0.011, 0.011 |
Every row of with its slack sums to 1, and so does every column of . At the match is very soft: gives about half of its mass to its slack. As grows, the two good pairs take nearly all the mass, and the far point goes to its slack: it is an outlier.
A full run. has 15 random points in . holds the images of 13 of them under and , with noise of standard deviation 0.01, plus 3 random outliers, in random order. With , the run has 38 values of :
| Step | largest error in and | total real mass in | ||
|---|---|---|---|---|
| 0 | 0.5 | 10.0 | 0.365 | 11.34 |
| 12 | 4.5 | 1.12 | 0.291 | 8.78 |
| 18 | 13.3 | 0.376 | 0.166 | 7.72 |
| 24 | 39.8 | 0.126 | 0.041 | 8.75 |
| 30 | 118.7 | 0.042 | 0.013 | 11.88 |
| 37 | 425.3 | 0.012 | 0.007 | 12.58 |
The real mass first drops, while the map is poor and many points prefer their slacks, and then rises as the map locks on. All 13 true pairs are found, and the 3 outliers of and the 2 points of without an image go to their slacks.
Correctness
At a fixed and , both steps lower the same energy . Sinkhorn only scales rows and columns, so its result has the form ; once the sums are 1, this form satisfies the optimality conditions of the strictly convex problem in , so it is the unique minimizer of over the match matrices with these sums. The pose step minimizes a strictly convex quadratic in , since . So the inner loop is block coordinate descent, and never rises within it. The full proof is in proofs/correctness.md.
The annealing itself has no such guarantee. When grows the energy changes, and the whole method is a heuristic that can end in a local minimum. In the tests, a run with a small fixed lets the affine part go wrong early and never recovers.
Proof: Softassign and the pose step each minimize the same energy at a fixed temperaturefull
We use the notation of the page and of the reference code. has points and has points . The map is , and . The match matrix has the real entries , a slack column with entries for the rows, and a slack row with entries for the columns. The constraints are
Call this set . With , the energy at the inverse temperature is
Line L5 sets and , up to a common factor in each row. Lines L6 and L7 divide each row, then each column, by its sum, and repeat. Line L8 computes the pose step.
Lemma 1: Sinkhorn keeps the scaling form
After line L5 and any number of sweeps of lines L6 and L7, there are numbers and such that
After a row step, every row sums to 1; after a column step, every column sums to 1.
Proof. At line L5 this holds with and the common factor of row (zero, or the shift that the code subtracts to avoid overflow). A row step divides and by the same positive number , which adds to . A column step divides and by the same number, which adds to . The slack column entry is changed only by the row step of row , and the slack row entry only by the column step of column , so the form holds after every step. The sums are 1 right after their own step by construction.
Lemma 2: a converged softassign minimizes the energy over the match matrix
Fix , and . If a matrix of the form of Lemma 1 lies in , then it is the unique minimizer of over .
Proof. Over , the energy is a linear function of plus times a sum of the strictly convex functions , so it is strictly convex, and the constraints are linear. For such a problem, a feasible point at which the gradient of the energy is a linear combination of the gradients of the constraints is the unique minimizer (the Karush-Kuhn-Tucker conditions are sufficient for a convex problem, and the inequality constraints are not active). With multipliers for the rows and for the columns, the conditions read
since . The form of Lemma 1 satisfies them with and .
Lemma 3: the pose step minimizes the energy over the map
Fix with , and let . Then has a unique minimizer over , and line L8 returns it.
Proof. Only the terms depend on . They split into two independent problems, one for each row of with the matching entry : minimize
where is row of . This is a quadratic in with the matrix
With , the Schur complement of is , which is positive definite. So is positive definite, the quadratic is strictly convex, and its unique minimizer solves with . Line L8 forms exactly and and solves the system by Gaussian elimination.
Theorem
At a fixed and a fixed , if Sinkhorn converges at each step of the inner loop of line L3, then the energy never rises from one step of the inner loop to the next.
Proof. Let be the state after one step. The next step first replaces by , the minimizer over for the fixed (Lemmas 1 and 2), so . Then it replaces by the minimizer for the fixed (Lemma 3), so .
This is block coordinate descent on one energy. The test test_energy_never_rises_at_fixed_beta checks it with Sinkhorn run to a tolerance of .
What this does not prove
- Convergence of Sinkhorn. The theorem assumes that the sweeps reach . The row and column steps are alternating projections onto the two sets of constraints in the Kullback-Leibler sense. Sinkhorn (1964) proved that the iteration converges for a square positive matrix scaled to doubly stochastic form; the form with slacks here is a related case, and we do not prove its convergence. The reference code stops after a fixed number of sweeps, so at large it uses a matrix that is only close to .
- Annealing. When grows, or when shrinks, the energy itself changes, so the energy of the whole run need not decrease. The hope behind deterministic annealing is that the minimum at a small , where is nearly convex in , leads by small changes to a good minimum at a large . This is a heuristic, not a theorem; the test
test_fixed_small_penalty_can_failshows a case where a different schedule fails. - Global optimum. The joint energy is not convex in , so the method can stop in a local minimum.
- Hard matches. At a finite the matrix is soft. The rule that the code uses to read off the matches, the largest entry of both its row and its column and above the slacks, is a choice of this code.
Complexity
The model is the real RAM. Line L4 computes distances, and line L5 exponentials. One Sinkhorn sweep reads every entry twice, in time. Line L8 sums over all entries and solves two systems. So one update with sweeps takes time, and a run with updates takes time; if each Sinkhorn call stops after one sweep, it takes . With multiplied by from to and a fixed number of updates per , is proportional to . The match matrix needs space.
Properties
- Joint. It solves for the match and the map together, not one after the other.
- Robust to outliers and missing points. The slacks let points stay unmatched; the reward sets the distance beyond which a match does not pay.
- One-to-one in the limit. The Sinkhorn constraints make close to a partial permutation at large , unlike ICP, where many points can share one nearest neighbour.
- Wide basin. At a small every point sees all points, so the first maps depend on the overall shape, not on the nearest points. This gives a much wider basin than ICP, but no guarantee.
- Deterministic. There is no random choice; the same input and schedule give the same result.
- Quadratic. Each update costs time and space, which limits it to a few thousand points.
Variants and improvements
- Non-rigid maps. Chui and Rangarajan (2003) replace the affine map by a thin-plate spline, with a bending energy as the regularizer, and anneal its weight together with the temperature. This is the best known form of RPM; see non-rigid registration.
- Probabilistic view. Coherent point drift uses a Gaussian mixture and EM. Its posterior matrix is a softassign with only one of the two normalizations, plus a uniform outlier term, and its variance plays the part of the temperature.
- Rigid and 3D. The same scheme works for rotations and translations in 2D or 3D, with the pose step solved by the SVD instead of a linear system.
- Graph matching. The softassign idea also applies to matching graphs, where the cost is quadratic in , as in the quadratic assignment problem.
When to use it
Use RPM when two point sets of moderate size must be matched without features, the start pose is poor, and points may be missing or extra on both sides, for example landmarks on two shapes or contour points. For a known one-to-one match with no outliers, the Hungarian algorithm gives the exact assignment for a fixed map. For large scans that already overlap well, ICP is much cheaper. For smooth non-rigid maps of larger sets, coherent point drift is a common choice.
Pitfalls
- The reward alpha. It sets the distance at which a point becomes an outlier, in squared units of the data. Too small, and true pairs with noise go to the slacks; too large, and outliers get matched. Normalize the data first.
- The schedule. A fast increase of freezes the match too early, in a poor local minimum; a slow one costs time. The range of must match the scale of the data: well below and well above .
- The penalty. With a weak penalty at the start, the affine map can shrink or shear the set onto a few points. Start with a strong penalty and relax it.
- Overflow. At a large , overflows. Subtract the largest exponent of each row before the exponential; the row step cancels the common factor.
- Sinkhorn sweeps. At a large , Sinkhorn converges slowly. A fixed number of sweeps leaves the sums off by a little, which is usually harmless but breaks the energy argument.
- Memory. The matrix has entries. Subsample large sets.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/robust-point-matching/. The authors are listed in prov/P020QC.jsonl.
"""Robust point matching (RPM) with softassign, after Gold, Rangarajan, Lu,
Pappu and Mjolsness (Pattern Recognition, 1998), for a 2D affine map.
X has n points x_j, Y has m points y_k. The map is y -> A y + t. The match
matrix M (n x m) has an extra slack column (a point of X with no partner)
and an extra slack row (a point of Y with no partner). At the inverse
temperature beta the code lowers
E(M, A, t) = sum_jk M_jk (|x_j - A y_k - t|^2 - alpha) + lam |A - I|_F^2
+ (1/beta) sum over all entries, slacks included, of M (log M - 1)
subject to: every row j of X sums to 1 over the m columns and the slack
column, and every column k of Y sums to 1 over the n rows and the slack row.
alpha is the squared distance below which a match pays off.
The M step is softassign: M_jk = exp(beta (alpha - d_jk)), slack entries
start at exp(0) = 1, then Sinkhorn normalizes the rows and the columns in
turn. The (A, t) step is a weighted least squares fit with the penalty
lam |A - I|^2, which keeps the affine part near the identity at the start.
This penalty, and its weight that shrinks as beta grows, are simple choices
of this code. beta grows by a fixed factor: deterministic annealing.
"""
from __future__ import annotations
import math
from typing import Dict, List, Sequence, Tuple
Point = Sequence[float]
Matrix = List[List[float]]
def apply(A: Matrix, t: Sequence[float], y: Point) -> List[float]:
return [A[0][0] * y[0] + A[0][1] * y[1] + t[0], A[1][0] * y[0] + A[1][1] * y[1] + t[1]]
def sq_dists(X: Sequence[Point], Y: Sequence[Point], A: Matrix, t: Sequence[float]) -> Matrix:
Ty = [apply(A, t, y) for y in Y]
return [[(x[0] - z[0]) ** 2 + (x[1] - z[1]) ** 2 for z in Ty] for x in X]
def sinkhorn(M: Matrix, sc: List[float], sr: List[float], iters: int,
tol: float = 1e-9) -> int:
"""Normalize in place: rows j (with the slack column entry sc[j]) and
columns k (with the slack row entry sr[k]) to sum 1, in turn. Stops when
every row and column sum is within tol of 1. Returns the number of
sweeps."""
n, m = len(M), len(sr)
for sweep in range(1, iters + 1):
for j in range(n): # @line L6
s = sum(M[j]) + sc[j]
M[j] = [v / s for v in M[j]]
sc[j] /= s
worst = 0.0
for k in range(m): # @line L7
s = sum(M[j][k] for j in range(n)) + sr[k]
for j in range(n):
M[j][k] /= s
sr[k] /= s
for j in range(n):
worst = max(worst, abs(sum(M[j]) + sc[j] - 1.0))
if worst <= tol:
return sweep
return iters
def softassign(X, Y, A, t, beta: float, alpha: float, iters: int,
tol: float = 1e-9) -> Tuple[Matrix, List[float], List[float]]:
D = sq_dists(X, Y, A, t)
# Subtract the largest exponent of each row: a common factor of a row
# cancels in the row step, and avoids overflow at large beta.
M = []
sc = []
for row in D:
top = max(0.0, max(beta * (alpha - d) for d in row))
M.append([math.exp(beta * (alpha - d) - top) for d in row]) # @line L5
sc.append(math.exp(-top))
sr = [1.0] * len(Y)
sinkhorn(M, sc, sr, iters, tol)
return M, sc, sr
def _solve(S: Matrix, r: Sequence[float]) -> List[float]:
"""Gaussian elimination with partial pivoting for a small system."""
k = len(r)
a = [list(S[i]) + [r[i]] for i in range(k)]
for c in range(k):
p = max(range(c, k), key=lambda i: abs(a[i][c]))
a[c], a[p] = a[p], a[c]
for i in range(c + 1, k):
f = a[i][c] / a[c][c]
for j in range(c, k + 1):
a[i][j] -= f * a[c][j]
out = [0.0] * k
for i in reversed(range(k)):
out[i] = (a[i][k] - sum(a[i][j] * out[j] for j in range(i + 1, k))) / a[i][i]
return out
def pose_step(X, Y, M: Matrix, lam: float) -> Tuple[Matrix, List[float]]:
"""The A and t that minimize sum M_jk |x_j - A y_k - t|^2 + lam |A - I|^2.
Each output coordinate r gives a 3 x 3 system in (A[r][0], A[r][1], t[r])."""
n, m = len(X), len(Y)
sw = swy0 = swy1 = s00 = s01 = s11 = 0.0
sx = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] # per r: sum w x_r y0, sum w x_r y1, sum w x_r
for j in range(n):
x = X[j]
for k in range(m):
w = M[j][k]
y = Y[k]
sw += w
swy0 += w * y[0]
swy1 += w * y[1]
s00 += w * y[0] * y[0]
s01 += w * y[0] * y[1]
s11 += w * y[1] * y[1]
for r in range(2):
sx[r][0] += w * x[r] * y[0]
sx[r][1] += w * x[r] * y[1]
sx[r][2] += w * x[r]
S = [[s00 + lam, s01, swy0], [s01, s11 + lam, swy1], [swy0, swy1, sw]]
A = [[0.0, 0.0], [0.0, 0.0]]
t = [0.0, 0.0]
for r in range(2):
rhs = [sx[r][0] + (lam if r == 0 else 0.0), sx[r][1] + (lam if r == 1 else 0.0), sx[r][2]]
a0, a1, tr = _solve(S, rhs)
A[r] = [a0, a1]
t[r] = tr
return A, t
def energy(X, Y, M, sc, sr, A, t, alpha: float, lam: float, beta: float) -> float:
D = sq_dists(X, Y, A, t)
e = lam * sum((A[i][k] - (1.0 if i == k else 0.0)) ** 2 for i in range(2) for k in range(2))
for j, row in enumerate(M):
for k, v in enumerate(row):
e += v * (D[j][k] - alpha) + (v * math.log(v) - v) / beta if v > 0.0 else 0.0
for v in list(sc) + list(sr):
if v > 0.0:
e += (v * math.log(v) - v) / beta
return e
def rpm(X: Sequence[Point], Y: Sequence[Point], alpha: float, lam0: float = 10.0,
lam_final: float = 0.01, beta0: float = 0.5, beta_final: float = 500.0,
rate: float = 1.2, inner: int = 3, sinkhorn_iters: int = 30) -> Dict[str, object]:
"""Returns the map (A, t), the match matrix with its slacks, and the hard
matches: pairs (j, k) where M_jk is the largest entry of its row and of
its column, slacks included. The penalty weight is lam0 * beta0 / beta,
but not below lam_final: strong at the start, weak at the end."""
A = [[1.0, 0.0], [0.0, 1.0]] # @line L1
t = [0.0, 0.0]
beta = beta0
M, sc, sr = None, None, None
while beta <= beta_final: # @line L2
lam = max(lam_final, lam0 * beta0 / beta)
for _ in range(inner): # @line L3
M, sc, sr = softassign(X, Y, A, t, beta, alpha, sinkhorn_iters) # @line L4
A, t = pose_step(X, Y, M, lam) # @line L8
beta *= rate # @line L9
n, m = len(X), len(Y)
matches = []
for j in range(n):
k = max(range(m), key=lambda c: M[j][c])
if M[j][k] > sc[j] and all(M[j][k] >= M[i][k] for i in range(n)) and M[j][k] > sr[k]:
matches.append((j, k))
return {"A": A, "t": t, "M": M, "slack_col": sc, "slack_row": sr, "matches": matches} # @line L10
test_robust_point_matching.py 126 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/robust-point-matching/. The authors are listed in prov/P020QC.jsonl.
import math
import random
import unittest
from robust_point_matching import (apply, energy, pose_step, rpm, sinkhorn, softassign,
sq_dists)
def cloud(rng, n):
return [[rng.uniform(-1.0, 1.0), rng.uniform(-1.0, 1.0)] for _ in range(n)]
def objective(X, Y, M, A, t, lam):
D = sq_dists(X, Y, A, t)
e = lam * sum((A[i][k] - (1.0 if i == k else 0.0)) ** 2 for i in range(2) for k in range(2))
return e + sum(M[j][k] * D[j][k] for j in range(len(X)) for k in range(len(Y)))
class TestSoftassign(unittest.TestCase):
def test_sinkhorn_sums(self):
rng = random.Random(1)
M = [[rng.uniform(0.1, 2.0) for _ in range(5)] for _ in range(4)]
sc = [rng.uniform(0.1, 1.0) for _ in range(4)]
sr = [rng.uniform(0.1, 1.0) for _ in range(5)]
sinkhorn(M, sc, sr, 500, 1e-12)
for j in range(4):
self.assertAlmostEqual(sum(M[j]) + sc[j], 1.0, places=9)
for k in range(5):
self.assertAlmostEqual(sum(M[j][k] for j in range(4)) + sr[k], 1.0, places=9)
def test_scaling_form(self):
# M_jk / (slack_j * slack_k) = exp(beta (alpha - d_jk)) after any number
# of sweeps: Sinkhorn only scales rows and columns.
rng = random.Random(2)
X, Y = cloud(rng, 6), cloud(rng, 5)
A, t = [[1.1, 0.2], [-0.1, 0.9]], [0.1, -0.2]
beta, alpha = 3.0, 0.2
D = sq_dists(X, Y, A, t)
for iters in (1, 3, 50):
M, sc, sr = softassign(X, Y, A, t, beta, alpha, iters)
for j in range(6):
for k in range(5):
self.assertAlmostEqual(math.log(M[j][k] / (sc[j] * sr[k])),
beta * (alpha - D[j][k]), places=9)
class TestPoseStep(unittest.TestCase):
def test_exact_with_hard_matches(self):
rng = random.Random(3)
Y = cloud(rng, 6)
A0, t0 = [[1.2, 0.3], [-0.4, 0.8]], [0.5, -0.7]
X = [apply(A0, t0, y) for y in Y]
M = [[1.0 if j == k else 0.0 for k in range(6)] for j in range(6)]
A, t = pose_step(X, Y, M, 0.0)
for i in range(2):
self.assertAlmostEqual(t[i], t0[i], places=9)
for k in range(2):
self.assertAlmostEqual(A[i][k], A0[i][k], places=9)
def test_minimizes_the_penalized_cost(self):
rng = random.Random(4)
X, Y = cloud(rng, 5), cloud(rng, 4)
M = [[rng.random() for _ in range(4)] for _ in range(5)]
lam = 0.7
A, t = pose_step(X, Y, M, lam)
best = objective(X, Y, M, A, t, lam)
for _ in range(40):
B = [[A[i][k] + rng.uniform(-0.05, 0.05) for k in range(2)] for i in range(2)]
u = [t[i] + rng.uniform(-0.05, 0.05) for i in range(2)]
self.assertGreater(objective(X, Y, M, B, u, lam), best)
class TestAnnealing(unittest.TestCase):
def test_energy_never_rises_at_fixed_beta(self):
rng = random.Random(5)
Y = cloud(rng, 8)
X = [apply([[0.9, -0.3], [0.3, 0.9]], [0.2, 0.1], y) for y in Y] + cloud(rng, 2)
A, t = [[1.0, 0.0], [0.0, 1.0]], [0.0, 0.0]
beta, alpha, lam = 4.0, 0.05, 1.0
last = None
for _ in range(15):
M, sc, sr = softassign(X, Y, A, t, beta, alpha, 2000, 1e-13)
e1 = energy(X, Y, M, sc, sr, A, t, alpha, lam, beta)
if last is not None:
self.assertLessEqual(e1, last + 1e-9)
A, t = pose_step(X, Y, M, lam)
last = energy(X, Y, M, sc, sr, A, t, alpha, lam, beta)
self.assertLessEqual(last, e1 + 1e-9)
def test_recovers_affine_map_with_outliers(self):
for seed in (6, 7, 10):
rng = random.Random(seed)
Y = cloud(rng, 15)
A0, t0 = [[0.95, -0.35], [0.25, 1.1]], [0.3, -0.2]
# X: images of the first 13 points of Y with noise, plus 3 outliers, shuffled.
# Y[13] and Y[14] have no partner.
X = [[v + rng.gauss(0.0, 0.01) for v in apply(A0, t0, y)] for y in Y[:13]]
X += cloud(rng, 3)
order = list(range(16))
rng.shuffle(order)
X = [X[i] for i in order]
out = rpm(X, Y, alpha=0.04)
for i in range(2):
self.assertLess(abs(out["t"][i] - t0[i]), 0.03)
for k in range(2):
self.assertLess(abs(out["A"][i][k] - A0[i][k]), 0.03)
truth = {(order.index(k), k) for k in range(13)}
self.assertEqual(set(out["matches"]), truth)
def test_fixed_small_penalty_can_fail(self):
# A fixed small penalty from the start lets the affine part collapse:
# this is why the penalty is annealed.
rng = random.Random(7)
Y = cloud(rng, 15)
A0, t0 = [[0.95, -0.35], [0.25, 1.1]], [0.3, -0.2]
X = [[v + rng.gauss(0.0, 0.01) for v in apply(A0, t0, y)] for y in Y[:13]]
X += cloud(rng, 3)
out = rpm(X, Y, alpha=0.04, lam0=0.01, lam_final=0.01)
err = max(abs(out["A"][i][k] - A0[i][k]) for i in range(2) for k in range(2))
self.assertGreater(err, 0.1)
if __name__ == "__main__":
unittest.main()
History
Gold, Rangarajan, Lu, Pappu and Mjolsness published softassign point matching in Pattern Recognition in 1998, for rigid and affine maps in 2D and 3D. It combines the softassign of a match matrix with Sinkhorn normalization, slack variables for outliers, and deterministic annealing from statistical physics. Sinkhorn's 1964 result on the scaling of positive matrices to doubly stochastic form gave the normalization step. Chui and Rangarajan (2003) extended the method to non-rigid maps with thin-plate splines, and this form became a standard baseline for non-rigid point set registration. Coherent point drift later recast the problem as the fit of a Gaussian mixture.
References
- Steven Gold, Anand Rangarajan, Chien-Ping Lu, Suguna Pappu and Eric Mjolsness, New algorithms for 2D and 3D point matching: pose estimation and correspondence, Pattern Recognition 31(8), 1998, 1019-1031, The energy with a match matrix and a reward for matches, the slack row and column for outliers, softassign with Sinkhorn normalization, deterministic annealing, and the alternation with the pose update
- Haili Chui and Anand Rangarajan, A new point matching algorithm for non-rigid registration, Computer Vision and Image Understanding 89(2-3), 2003, 114-141, The non-rigid form of the method with a thin-plate spline map, and the annealing of the regularization weight
- Richard Sinkhorn, A relationship between arbitrary positive matrices and doubly stochastic matrices, The Annals of Mathematical Statistics 35(2), 1964, 876-879, The scaling of a positive square matrix to doubly stochastic form by alternating row and column normalization
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag P020QC Edit this page History Report an error Markdown