Skip to content

Polynomial distortion

The 'Polynomial' distortion also maps pairs of control points, but uses a standard polynomial equation. This means one extra argument is needed before the control points are given:

ts
const args = [order, u1, v1, x1, y1, /* ..., */ uN, vN, xN, yN];

The order argument is usually an integer from 1 onward, though a special value of 1.5 can also be used. This defines the 'order' or complexity of the 2-dimensional mathematical equation (using both x and y), that will be applied.

For example an order 1 polynomial will fit an equation of the form:

Xd=C2xXs+C1xYs+C0x,Yd=C2yXs+C1yYs+C0y

Which if you compare with the equation used for Affine Projection you will see that it is the equivalent. As 3 constants is needed for each X and Y formula, you also need to provide at least 3 X,Y coordinate pairs. Any more will cause the equation to be least-squares fitted to the coordinates given.

The next order or 1.5 is equivalent to a 'BilinearReverse' (remember the equation is used to map destination coordinates to the source image).

Xd=C3xXsYs+C2xXs+C1xYs+C0x,Yd=C3xXsYs+C2yXs+C1yYs+C0y

WARNING

'BilinearReverse' distortion is not implemented in Lens at the moment.

It needs a minimum of 4 coordinates. Basically this is exactly the same as the order 1 equations but with 1 extra term added to the polynomial equations. That is, as each equation now has 4 terms per axis, with 4 constants, so you now need at least 4 coordinate pairs, to allow Lens to determine those constants.

With an order 2 the polynomial equations is expanded further to become a full quadratic-fit, requiring a minimum of 6 coordinate pairs.

Xd=C5xXs2+C4xXsYs+C3xYs2+C2xXs+C1xYs+C0x,Yd=C5yXs2+C4yXsYs+C3yYs2+C2yXs+C1yYs+C0y

Basically this is exactly the same as the order 1 equations but with 3 extra terms (order 2 + 1) prepended to the polynomial equations. that is as each equation now has 6 terms with 6 constants you now need at least 6 coordinates to allow Lens to determine those constants.

Each successive order polynomial after this adds another order + 1 terms to each of the pair of equations. As such an order 3 cubic-fit polynomial requires a minimum of 10 coordinate pairs to fully define, and an order 4quintic-fit polynomial needs 15 coordinate pairs.