RegisterFit computes affine transformations that minimize image registration mismatch. Given per-aperture mismatch data from RegisterMismatch, it finds the best-fit affine transform by fitting each aperture's mismatch to a quadratic form and solving a global least-squares problem. It is part of the HolyLab image registration pipeline.
RegisterFit is distributed through the HolyLabRegistry. Add the registry once, then install the package:
using Pkg
pkg"registry add https://github.com/HolyLab/HolyLabRegistry.git"
Pkg.add("RegisterFit")using RegisterFit, RegisterCore
# Synthetic mismatch: parabola centred at shift (1, -2)
num = [(i - 1)^2 + (j + 2)^2 for i in -5:5, j in -5:5]
mm = MismatchArray(num, ones(11, 11))
E0, u0, Q = qfit(mm, 0.5)
# E0 ≈ 0.0 — mismatch value at the minimum
# u0 ≈ [1, -2] — shift at the minimum
# Q ≈ I — curvature matrixusing RegisterFit
# Horizontal bar in fixed, vertical bar in moving (≈ 90° rotation)
fixed = zeros(5, 7); fixed[3, 2:6] .= 1.0
moving = zeros(7, 5); moving[2:6, 3] .= 1.0
tfms = pat_rotation(fixed, moving) # 2 candidate AffineMap transforms in 2D
# Evaluate each candidate against mismatch data and pick the bestThe typical workflow in the registration pipeline is:
- Compute mismatch — per-aperture
MismatchArrays fromRegisterMismatch mms2fit!— fit each aperture to a quadratic; returns per-aperture shifts and curvature matricesmismatch2affine— global least-squares solve over all apertures to produce a singleAffineMap- Refine — further optimisation in
RegisterDeformation
See the documentation for the full API reference.