SynthEyes' lens-distortion algorithm is designed to model the bulk of the distortion created by the lens, but by design, it avoids having a large number of parameters, since having many parameters provides more opportunity for details in the scene to be interpreted as lens distortion.

## SynthEyes Image Coordinates

SynthEyes uses a resolution-independent representation of positions in the image plane: a U coordinate ranging from -1 on the left to +1 on the right, and a V coordinate ranging from -1 at the top to +1 at the bottom. The exact center of the image occurs at U=V=0, and this is assumed to be the location of the camera and lens' optic axis.

## Lens Distortion

The lens distortion algorithm is set up to rapidly distort image coordinates, since this is the calculation used very frequently during solving. The distortion algorithm is what you need to undistort images: to undistort, for each undistorted output pixel, you compute where it's distorted location would be.

If (u,v) are the coordinates of a feature in the undistorted perfect image plane, then (u', v') are the coordinates of the feature on the distorted image plate, ie the scanned or captured image from the camera. The distortion occurs radially away from the image center, with correction for the image aspect ratio (image_aspect = physical image width/height), as follows:

r2 = image_aspect*image_aspect*u*u + v*v f = 1 + r2*(k + kcube*sqrt(r2)) u' = f*u v' = f*v

The constant k is the distortion coefficient that appears on the lens panel and through Sizzle. It is generally a small positive or negative number under 1%. The constant kcube is the cubic distortion value found on the image preprocessor's lens panel: it can be used to undistort or redistort images, but it does not affect or get computed by the solver. When no cubic distortion is needed, neither is the square root, saving time.

## Lens Un-distortion

Though distorting the coordinates is quick and painless, un-distorting them (going from distorted coordinates to perfect ones) is a bit of trouble. This direction is the one you need to distort CGI images to match the distorted original plates, by computing for each (distorted) output pixel, where the original undistorted pixel lies.

Though a partial closed-form solution could probably be used for un-distorting equation plain quadratic distortion (requires a cubic solve), it is easiest to use an iterative technique. You can see sample Sizzle code in the distort.szl script.

But if you are doing an image's worth, you can build a look-up table on the radius. That's what the lens presets do, using spline interpolation. See the "Lens Information File" section of the manual for more information on them.