5.5: Homogeneous Coordinates
In the previous section we were able to combine rotation and scaling into a single composite operation by matrix multiplication. Unfortunately, translation cannot yet be included in the composite operator since we do it by addition rather than by multiplication.
Suppose we wish to rotate the image \(G\) by \(\frac{\pi}{3}\) about the point (−10,10). Our rotation matrix R(\(\theta\)) always rotates about the origin, so we must combine three transformations to accomplish this:
- translate the point (−10,10) to the origin;
- rotate \(\frac{\pi}{3}\) radians about the origin; and
- translate the origin back to (−10,10).
For step (i), we have \(b_{0}=\left[\begin{array}{l}
10 \\
-10
\end{array}\right]\) and
\[\mathrm{G}_{1}=\mathrm{G}+\mathrm{b}_{0} 1^{T} \nonumber \]
For step (ii),
\[\begin{align}
\mathrm{G}_{2} &=\mathrm{R}\left(\frac{\pi}{3}\right) \mathrm{G}_{1} \nonumber \\
&=\mathrm{R}\left(\frac{\pi}{3}\right)\left[\mathrm{G}+\mathrm{b}_{0} 1^{T}\right] \nonumber \\
&=\mathrm{R}\left(\frac{\pi}{3}\right) \mathrm{G}+\mathrm{R}\left(\frac{\pi}{3}\right) \mathrm{b}_{0} 1^{T} .
\end{align} \nonumber \]
For step (iii), we can use −\(b_0\) from step (i):
\[\begin{align}
\mathrm{G}_{\text {new }} &=\mathrm{G}_{2}-\mathrm{b}_{0} 1^{T} \nonumber \\
&=\mathrm{R}\left(\frac{\pi}{3}\right) \mathrm{G}+\mathrm{R}\left(\frac{\pi}{3}\right) \mathrm{b}_{0} 1^{T}-\mathrm{b}_{0} 1^{T} \nonumber \\
&=\mathrm{R}\left(\frac{\pi}{3}\right) \mathrm{G}+\left[\left(\mathrm{R}\left(\frac{\pi}{3}\right)-\mathrm{I}\right) \mathrm{b}_{0}\right] 1^{T} .
\end{align} \nonumber \]
In this example we were unable to find a single matrix operator \(A\) to do the entire job. The total transformation took the form
\[\mathrm{G}_{\text {new }}=\mathrm{AG}+\mathrm{b} 1^{T} \nonumber \]
This is called an affine transformation because it involves both multiplication by \(A\) and addition of a constant matrix. This is in contrast to the more desirable linear transformation , which involves only multiplication by \(A\).
We will now move toward a modified representation of the image and the operators by rewriting the last equation as
\[\mathrm{G}_{\text {new }}=[\mathrm{Ab}]\left[\begin{array}{l}
\mathrm{G} \\
1^{T}
\end{array}\right] \nonumber \]
where in the example we had \(A = \mathrm{R}\left(\frac{\pi}{3}\right)\) and \(b=\left(\mathrm{R}\left(\frac{\pi}{3}\right)-\mathrm{I}\right) b_{0}\).
Show that, for any matrices A,B,C,D of compatible sizes,
\[\mathrm{AB}+\mathrm{CD}=\left[\begin{array}{ll}
A & \mathrm{C}
\end{array}\right]\left[\begin{array}{l}
\mathrm{B} \\
\mathrm{D}
\end{array}\right] \nonumber \]
The matrix \(\left[\begin{array}{l}
\mathrm{G} \\
1^{T}
\end{array}\right]\) looks like
\[\left[\begin{array}{lll}
x_{1} & x_{2} & x_{n} \\
y_{1} & y_{2} & y_{n} \\
1 & 1 & 1
\end{array}\right] \nonumber \]
and the points \((x_i,y_i,1)\) are called homogeneous coordinates . We can modify Equation 5 so that the new point matrix is also in homogeneous coordinates:
\[\left[\begin{array}{l}
\mathrm{G}_{\text {new }} \\
1^{T}
\end{array}\right]=\left[\begin{array}{ll}
\mathrm{A} & \mathrm{b} \\
\mathrm{O}^{T} & 1
\end{array}\right]\left[\begin{array}{l}
\mathrm{G} \\
1^{T}
\end{array}\right] \nonumber \]
In the new representation, each point in the image has a third coordinate, which is always a 1. The homogeneous transformation is a 3×3 matrix,
\[\mathrm{A}_{h}=\left[\begin{array}{ll}
\mathrm{A} & \mathrm{b} \\
0^{T} & 1
\end{array}\right] \text { , } \nonumber \]
which is capable of translation, rotation, and scaling all by matrix multiplication. Thus, using homogeneous coordinates, we can build composite transformations that include translation.
In homogeneous coordinates, we have
\[\mathrm{R}(\theta)=\left[\begin{array}{lll}
\cos \theta & -\sin \theta & 0 \\
\sin \theta & \cos \theta & 0 \\
0 & 0 & 1
\end{array}\right] \nonumber \]
\[\mathrm{S}\left(s_{x}, s_{y}\right)=\left[\begin{array}{lll}
s_{x} & 0 & 0 \\
0 & s_{y} & 0 \\
0 & 0 & 1
\end{array}\right] \nonumber \]
\[\mathrm{T}\left(t_{x}, t_{y}\right)=\left[\begin{array}{lll}
1 & 0 & t_{x} \\
0 & 1 & t_{y} \\
0 & 0 & 1
\end{array}\right] \nonumber \]
The composite transformation to triple the size of an image and then move it 2 units to the left is
\[\mathrm{A}=\left[\begin{array}{lll}
1 & 0 & -2 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{array}\right]\left[\begin{array}{lll}
3 & 0 & 0 \\
0 & 3 & 0 \\
0 & 0 & 1
\end{array}\right]=\left[\begin{array}{lll}
3 & 0 & -2 \\
0 & 3 & 0 \\
0 & 0 & 1
\end{array}\right] \nonumber \]
On the other hand, the composite transformation to move an image 2 units to the left and then triple its size is
\[\mathrm{B}=\left[\begin{array}{lll}
3 & 0 & 0 \\
0 & 3 & 0 \\
0 & 0 & 1
\end{array}\right]\left[\begin{array}{lll}
1 & 0 & -2 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{array}\right]=\left[\begin{array}{lll}
3 & 0 & -6 \\
0 & 3 & 0 \\
0 & 0 & 1
\end{array}\right] \nonumber \]
In the latter case, the distance of the translation is also tripled.
Find a single composite transformation in homogeneous coordinates that rotates an image by angle \(\theta\) about point \((x_i,y_i)\) as in Example 1 .