CS 791 E   Programming Assignment # 1

 

3.  Write a program  that applies an affine transformation on a given image.

3.1. Methodology

In order to get an affine-transformed image, we have to use the inverse affine transformation. Furthermore, to make things easy, all the transformations (rotation, translation) are represented in 3x3 homogeneous matrices, so the transformation process becomes of the manipluation of the matrices.

Suppose D (3x1) represents the destination image pixel location (coordinates) as [x, y, 1],   O (3x1) the original image coordinates as [x, y, 1], T (3x3) the translation matrix, R the rotation (around (0,0)) matrix,  C the matrix that represents the rotation center. Thus we have:
     1).   if translation first and rotation second:
                   forward:  D = C * R * inverse(C) * T  * O.
                    inverse:  O = inverse ( C * R * inverse(C) * T )  * D.

     2).  if rotation first and then translation:
                    forward:   D = T * C * R * inverse(C) * O.
                    inverse:    O = inverse( T * C * R * inverse(C)  )* D.

If the destination location calculated from above is beyond the location of the original image size, I just used the edge of the original image.
 

3.2. Usage:

3.3. Comments:

3.4. Results