back

Linear Equations, Matrices and PseudoInverse

objective:
solve polynomial coefficients to fit chromatic aberration data
polynomial model:
`C0 + C1*x + C2*y + C3*x*x + C4*y*y + C5*x*x*x + C6*y*y*y + C7*x*y + C8*x*x*y + C9*x*y*y,
where x and y are pixel coordinates,
and the result approximates red or blue pixel misregistration relative to green at those coordinates.
This model may be too simple (underspecified) or overfit.
  however, gnuplots of model vs data seem reasonable...
4 solutions are wanted:  red and blue in x and y directions
in theory
solving for 10 unknown coefficients wants 10 equations
with 10 sets of independent variables and a set of 10 results
practically
data is noisy
in matrix algebra terms,
we have 10 unknowns C0-9,
an array of measured offsets and a matrix of linearly independent sample variables.
If there were 10 offset measurements and corresponding sample variables,
the matrix algebra expression is MC = O, where:
  • M is a 10x10 array of linearly independent sample variables,
  • C are the unknown coefficients,
  • O are measured offsets.
Chromatic aberration characterized by only 10 measurements is arguably suspect;
doing so would yield a solution for C = MiO, where Mi is the inverse of M.
in reality, a calibration slide has hundreds of sample targets
those measurements comprise an overdetermined system
a approximate solution is appropriate. My favorite approach is Moore-Penrose pseudoinverse.
Solving for 4x10 polynomial model coefficients by Gauss-Newton iteration
is one of the more computationally expensive steps in chromatic aberration reduction.
(Another expensive step is measuring red and blue misregistrations from test target images.)
I have, in the past, more than once coded Moore-Penrose pseudoinverse,
but more cleverness has since been applied,
and this implementation seems interesting.
maintained by blekenbleu