Affine transformation and perspective transformation of image processing
Actually has not understood "affine" two words is what meaning, but everybody so called, in fact affine transformation and perspective transformation more intuitive name can be called "Plane transformation" and "spatial transformation" or "two-dimensional coordinate transformation" and "three-dimensional coordinate transformation." If this is the case, it is clear that these two are one thing, except that they are two-dimensional coordinates (x, y) and one is three-dimensional (x, Y, z). That is
Affine transformations:
Perspective Transformations:
From another angle can also explain the three-dimensional transformation and the meaning of two-dimensional transformation, affine transformation of the equation set has 6 unknowns, so to solve the need to find 3 sets of mapping points, three points just to determine a plane. The equations of the perspective transformation have 8 unknowns, so to solve it, we need to find 4 sets of mapping points, and four points just determine a three-dimensional space.
It is not difficult to write a program to solve a linear equation group.
After solving the equations, we can find the corresponding source pixels on the result image according to the above equation. Then do the interpolation.
Look at the effect AH:
Original:
After affine transformations:
After perspective transformations:
Can be seen from the difference, affine transformation after or parallelogram, after the perspective transformation is only the quadrilateral. The rotation of the image can theoretically be achieved by affine transformation (90-degree, 180-degree, 270-degree rotation with affine transformation to achieve a cost-effective). Perspective transformations can be used for a number of purposes, such as:
The QR code you sweep is like this:
So you can directly read the QR code information must not, so you need perspective transformation, into this:
You can read out the information.
Just now, to solve affine transformation requires 3 sets of corresponding points, to solve the perspective transformation requires 4 sets of corresponding points, if the number of mapping points found less than 3 groups or 4 groups will certainly not be solved, but if more than 3 groups or 4 group what to do? It is necessary to do the least squares fitting to find an optimal transformation equation. This is not a detail.
Affine transformation and perspective transformation of image processing