up to Schedule & Notes

Geometric Transforms

Goals:

Definitions

$I(x,y)$ = original image

$I'(x,y)$ = new image

The transformation is $T: (x,y) \longrightarrow (x',y')$.

This moves pixel $(x,y)$ in $I$ to pixel $(x',y')$ in $I'$.

Forward Projection

for (x=0; x<width; x++)
  for (y=0; y<height; y++)
    (x',y') = T(x,y)
    I'(x',y') = I(x,y)   // must check that (x',y') is in bounds of NEW image

Basic Transformations

pixel $p = \left[ \begin{array}{c} x \\ y \end{array} \right]$

Rotation by angle $\theta$: $p' = T \; p$

$T = \left[ \begin{array}{cc} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{array} \right]$

$\begin{eqnarray} \left[ \begin{array}{c} x' \\ y' \end{array} \right] & = & \left[ \begin{array}{cc} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{array} \right] \left[ \begin{array}{c} x \\ y \end{array} \right] \\ \\ & = & \left[ \begin{array}{cc} x \cos\theta - y \sin\theta \\ x \sin\theta + y \cos\theta \end{array} \right] \end{eqnarray}$

Scaling by $(s_x,s_y)$:

$T = \left[ \begin{array}{cc} s_x & 0 \\ 0 & s_y \end{array} \right]$

Translation by $(t_x,t_y)$:

$\begin{eqnarray} \left[ \begin{array}{c} x' \\ y' \end{array} \right] & = & \left[ \begin{array}{c} x \\ y \end{array} \right] + \left[ \begin{array}{c} t_x \\ t_y \end{array} \right] \end{eqnarray}$

There's no $2 \times 2$ matrix to do this!

Sequences of Transformations

We want to be able to compute $p' = T_3 \; T_2 \; T_1 \; p$.

e.g.

$\begin{eqnarray} p' & = & T_3 \; (T_2 \; (T_1 \; p)) \\ & = & (T_3 \; T_2 \; T_1) \; p \\ & = & T \; p \end{eqnarray}$

It's more efficient to use $T$ instead of $(T_3 \; T_2 \; T_1)$, especially since this is done for all pixels in the image.

But translations cannot be written as $2 \times 2$ matrix operations

Forward Projection Problems

With transformations that dilate the pixel positions, there are gaps (having no values) between pixels in the new image.

[ DEMO of forward projection ]

Instead, for each pixel in the new image, find where it comes from in the original image.

$\begin{array}{ll} \textrm{if } & (x',y') = T \; (x,y) \\ \textrm{then } & (x,y) = T^{-1} (x',y') \end{array}$

for (x'=0; x'<width; x'++)
  for (y'=0; y'<height; y'++)
    (x,y) = T-1 (x',y')
    I'(x',y') = I(x,y)           // must check that (x,y) is in bounds of ORIGINAL image

[ DEMO of back projection ]

up to Schedule & Notes