In duanxx's image processing learning: perspective transformation (I), this section briefly describes the Perspective change algorithm. Here we will further describe the perspective transformation.
Based on the preceding instructions, you can easily find that a transformation matrix has the following Partition features:
In general, I have a three-dimensional transformation matrix as follows:
Elements in the matrix (P, Q, R) Not all 0Can generatePivoting Effect
I. A little perspective
Let's look at the figure below:
The pivot projection of P (x, y, z, 1) points on the xoy plane is now centered on a point (0, 0, d, 1) on the Z axis.
Now it is easy to know:
That is:
Here:
Then the transformation matrix T is:
The Second coordinate of the result is:
Analyze the value of Z:
1. if z = 0, [x 'y' Z '1] = [x y 0 1]
2. If Z is infinite, [x 'y' Z '1] = [0 0 1/R 1]
It is easy to see from the analysis above,The Z value is infinitely large.All vertices are concentrated at 1/R of the Z axis after transformation. This point is calledPoint Elimination.
Such a point exists on the X and Y axes.
2. Two points of view
If there are two non-0 elements in P, Q, and R, two extinction points are generated. The obtained perspective is called a two-point perspective, or an angle perspective.
For example, if p is not equal to 0, R is not equal to 0, and Q is equal to 0, the effect of pivoting is displayed.
After the limit is obtained, it is easy to know that, here, one is at 1/P on the X axis, and the other is at 1/R on the Z axis.
3. Three-point perspective
From the above perspective and link perspective, and so on, when all the three elements P, Q, and R are not 0, the conversion result will form three pivoting points. The generated three extinction points are located at 1/P on the X axis, 1/Q on the Y axis, and 1/R on the Z axis.
At this time, the projection plane and the coordinate axis are not parallel
The formula is derived easily according to the previous formula.
Here I can simply Infer:
1. If the plane perpendicular to a coordinate axis is used as the projection plane, the projection on the plane must be a little projection.
2. If the plane that is located at the intersection of the two axes and does not conflict with the third axis is used as the projection plane, that is, the projection plane is parallel to one axis, and the projection on the plane must be a two-point projection.
3. If the plane that is intersecting with the three axes and does not contain any coordinate axes is used as the projection plane, the projection on the plane must be a three-point projection.
Iv. Transformation Matrix of Perspective Projection
The Y axis is used as an example. To generate a perspective projection, two steps are required.
Step 1: Use the preceding perspective transformation matrix to perform perspective transformation on the three-dimensional graph in the horizon
Step 2: Perform positive projection on XOZ coordinates
When generating a perspective view, to avoid a special perspective position, the three-dimensional view is better, usually, you need to first translate the stereo to a proper position (such as leaving the center of the coordinate system) before perspective transformation.
Therefore, the final perspective transformation matrix is:
V. Two-point perspective transformation matrix
Two steps are required to form a two-point perspective change:
Step 1: First rotate an angle Q around the Z axis, so that the surface of the stereo that is originally parallel to the coordinate plane XOZ and yoz has a certain tilt angle (angular perspective) with the XOZ of the projection plane ), for details about the calculation, see duanxx image processing learning: 3D image transformation and homogeneous coordinate representation.
Step 2: Perform perspective projection on the XOZ projection plane (the operation here is article 4 above)
This is a bit like a dimension reduction operation.
The preceding transform matrix has two non-zero parameters: (qsinq, qcosq). Therefore, the generated perspective is a two-point perspective.
In the two-point perspective, only the three-dimensional edges that were originally parallel to the Z axis remain parallel to the Z axis, and other edges (for example, the edges that were originally parallel to the X axis and Y axis) will be skewed (angular ).
Vi. Transformation Matrix of three-point perspective projection
From the two-point perspective transformation method, we can easily know that the three-point perspective transformation method is:
Step 1: First rotate the stereo around the Z axis at an angle Q
Step 2: rotate an angle F around the X axis (similar to the Axis Test transformation) so that the three-dimensional data is originally parallel to the three
The surface of Coordinate Planes and the projection plane XOZ have a certain inclination angle.
Step 3: Perform perspective projection on the XOZ projection plane.
Duanxx image processing learning: perspective transformation (2)