Set the original image to f (x, y), and the distorted image to f (x ', y ') to restore to f (x, y), you need to find the Conversion Relationship Between the (x', y') Coordinate and (x, y) Coordinate. This Conversion Relationship is called coordinate transformation, (x, y) = T (x', y ').
The distortion of a scene during imaging may cause the image to be out of proportion. The affine transform can be used to correct various distortion. First, calculate the coefficient of the coordinate transformation. The expression of the affine transformation is: R (x) = px + Q, x = (X, Y) is the plane position of the pixel, P is the rotation matrix of 2*2, q is the translation vector of 2*1, and p and q are the parameters of the affine transformation, that is:
X = AX '+ by' + c
Y = DX '+ ey' + F
Therefore, the correction of geometric distortion is ultimately the solution of the coordinate transformation coefficients A, B, C, D, E, F.
In order to prevent null pixels, reverse ing is generally adopted and obtained by the least square method:
Vec1 = inv ([x y I] '* [x y I]) * [x y I]' * U;
Vec2 = inv ([x y I] '* [x y I]) * [x y I]' * V;
Vec1 = [a B c] '; vec2 = [d e f]'; x y u v I are X, Y, x', y ', 1.
In addition, the cp2tform function or nlinfit function in MATLAB can implement similar functions.