Module: tfg.rendering.camera.quadratic_radial_distortion

Quadratic radial lens distortion and un-distortion functions.

Given a vector in homogeneous coordinates, (x/z, y/z, 1), we define r^2 = (x/z)^2 + (y/z)^2. We use the simplest form of distortion function, f(r) = 1 + k * r^2. The distorted vector is given by (f(r) * x/z, f(r) * y/z, 1).

To apply the undistortion, we need the inverse of f(r), g = f^{-1}. In this library we use the approximate formula for the undistortion function given here https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4934233/, and refine the solution using Newton-Raphson iterations (https://en.wikipedia.org/wiki/Newtons_method).

Restricting the distortion function to quadratic form allows to easily detect the cases where r goes beyond the monotonically-increasing range of f (which we refer to as overflow).

Functions

distortion_factor(...): Calculates a quadratic distortion factor given squared radii.

undistortion_factor(...): Calculates the inverse quadratic distortion function given squared radii.