In one text, the derivation for perspective projection goes like this: image1

If $x',y',z'$ represent any point along the projection line,and $x_{prp},y_{prp},z_{prp}$ are the projection reference point, then:

$$y'=y-(y-y_{prp})u$$ $$z'=z-(z-z_{prp})u$$ where $0\le u \le 1$

Now, finding the value of u from the third equation above and replacing in the first and second equations, we get at $z_vp$:

$$ x_p=x'= x.\frac{z_{vp}-z_{prp}}{z-z_{prp}}+x_{prp}.\frac{z-z_{vp}}{z-z_{prp}}$$ $$ y_p=y'= y.\frac{z_{vp}-z_{prp}}{z-z_{prp}}+y_{prp}.\frac{z-z_{vp}}{z-z_{prp}}$$

and there is no projection transformation matrix given.

In the second text, the derivation is using similar triangles:
comparing the similar triangles we get: $$x_p=\frac{-x_c}{\frac{z_c}{d}}$$ $$y_p=\frac{y_c}{\frac{z_c}{d}}$$

and the projection transformation for homogeneous coordinates x,y,z is given by: $$ \begin{bmatrix} -1&&0&&0&&0\\ 0&&1&&0&&0\\ 0&&0&&1&&0\\ 0&&0&&\frac{1}{d}&&0 \end{bmatrix} $$

so, my questions are:

  • How do I find the projection matrix of coordinates as found from derivation 1?
  • Both are given in the perspective projection area of these different texts, are both transformations the same? If not, how are they different?
  • 1
    $\begingroup$ Place the reference point at the origin in the first construction. $\endgroup$ – amd Nov 12 '18 at 5:09
  • $\begingroup$ @amd, wow, I didn't notice that simple fact, thanks a lot, but that answers only my second question, do you know about the first one? $\endgroup$ – mathmaniage Nov 12 '18 at 5:35
  • $\begingroup$ Compose the matrix with a translation. There’s also a straightforward formula for the matrix of a central projection onto an arbitrary plane that’s derived along the lines of your first construction, but you don’t need that here. $\endgroup$ – amd Nov 12 '18 at 5:50
  • $\begingroup$ @amd, but the translation part, i.e. the fourth column of the matrix has to be: $x_{prp}.\frac{z-z_{vp}}{z-z_{prp}}$ right? $\endgroup$ – mathmaniage Nov 12 '18 at 5:56
  • 1
    $\begingroup$ Also note that in the second derivation, there’s an additional reflection in the $y$-$z$ plane because we’re “looking” at the projected image from the wrong side. $\endgroup$ – amd Nov 12 '18 at 7:41

The two constructions are essentially the same. In the first, the reference point (more usually called the view point or camera center) is arbitrary and the image plane is $z=z_{\text{vp}}$, while in the second the camera is at the origin and the image plane is $z=d$. In solving for $u$ in the first construction you’re effectively using similar triangles, so if you place the reference point at the origin and set $d=z_{\text{vp}}-z_{\text{pvp}}$ you end up with the same equations... almost.

There’s an important difference between the two constructions: the second one also includes a reflection in the $y$-$z$ plane (the image $y$-axis). This is because we want a right-handed coordinate system for the image, but we’re “looking” at the image plane from the wrong side. Many authors place the image plane at $z=f$, $f\lt0$ instead (so that the camera is looking “down” at the scene) to avoid having to introduce this extraneous reflection.

Constructing a projection matrix from the first set of equations is fairly straightforward. The projected image of the point with homogeneous coordinates $(x,y,z,1)$ is $$\left({z_{\text{vp}}-z_{\text{prp}} \over z-z_{\text{prp}}}x+{z-z_{\text{vp}}\over z-z_{\text{prp}}}x_{\text{prp}},{z_{\text{vp}}-z_{\text{prp}} \over z-z_{\text{prp}}}y+{z-z_{\text{vp}}\over z-z_{\text{prp}}}y_{\text{prp}},z_{\text{vp}},1\right).$$ The projection matrix can’t depend on the point being projected, so just as is done to construct the matrix in the second derivation, multiply through by the denominator so that all of the coordinates appear in separate terms. Once you’ve done this, you can read off the projection matrix from the resulting coordinate vector: $$P = \begin{bmatrix} z_{\text{vp}}-z_{\text{prp}} & 0 & x_{\text{prp}} & -z_{\text{vp}}x_{\text{prp}} \\ 0 & z_{\text{vp}}-z_{\text{prp}} & y_{\text{prp}} & -z_{\text{vp}}y_{\text{prp}} \\ 0 & 0 & z_{\text{vp}} & -z_{\text{vp}}z_{\text{prp}} \\ 0&0&1&-z_{\text{pvp}}\end{bmatrix}.$$ You can obtain the same matrix by undoing the reflection in the second derivation (replace the $-1$ with a $1$) and concatenating it with two translations that correspond to translating the origin to the viewpoint and the translating back after projection. I’ll leave grinding through that computation to you.

Both this and the projection matrix in the second derivation produce a point in the three-dimensional scene space. To get a matrix that produces two-dimensional image coordinates instead, you would delete its third row.

We can also obtain $P$ directly by using a slightly different construction: the projected image of a point $\mathbf X$ is the intersection of the line through $\mathbf X$ and the camera center $\mathbf C$ with the image plane $\mathbf\pi$. This can be computed directly by using the Plücker matrix of the line: $$\mathbf X' = (\mathbf C\mathbf X^T-\mathbf X\mathbf C^T)\mathbf\pi.$$ Rearranging and factoring out $\mathbf X$, we get $$(\mathbf C\mathbf\pi^T-\mathbf C^T\mathbf\pi I_4)\mathbf X.$$ I’ll again leave it to you to verify that the parenthesized expression produces the matrix $P$ from above. This construction is completely general: it works for any image plane and viewpoint including points at infinity, which correspond to parallel projections (so-called affine cameras).

  • $\begingroup$ in the third row, the $z_vp$ is written as $s_x$ and $-z_{vp}z_{prp}$ as $t_x$ in my text and it's written that they are translation and scaling factors to preserve the z-value . What does preserving z-value mean and how does it preserve z value? ... :-) $\endgroup$ – mathmaniage Nov 12 '18 at 8:53
  • $\begingroup$ and why is it said in my book that this matrix transforms scene to homogeneous parallel projection coordinates? I get the homogeneous part, since the extraneous translation is also encoded into a single matrix, but What about the parallel projection coordinates? Isn't this perspective transformation? $\endgroup$ – mathmaniage Nov 12 '18 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.