0% found this document useful (0 votes)
20 views4 pages

Homogeneous Coordinates & 2D Transformations

The document is an introduction to computer vision focusing on geometric primitives and exercises related to homogeneous coordinates and 2D transformations. It includes problems involving the intersection of lines, null spaces, isometric transformations, and matrix operations for rotations, translations, and reflections. The exercises aim to enhance understanding of projective space and the application of matrix mathematics in geometric transformations.

Uploaded by

walidlabied2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Homogeneous Coordinates & 2D Transformations

The document is an introduction to computer vision focusing on geometric primitives and exercises related to homogeneous coordinates and 2D transformations. It includes problems involving the intersection of lines, null spaces, isometric transformations, and matrix operations for rotations, translations, and reflections. The exercises aim to enhance understanding of projective space and the application of matrix mathematics in geometric transformations.

Uploaded by

walidlabied2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to Computer Vision

Geometric Primitives

Exercise 1: Homogeneous Coordinates in Projective Space


1. Given a line defined by its homogeneous coordinates l̃ = (a b c)T in the projective space, its
equation is: ax + by + c = 0. Show that this equation is equivalent to x̄ · l̃ = 0 for any given
x̄ = (x y 1) belonging to l̃.
2. Show that the intersection of two non-parallel lines l̃1 and l̃2 is a point x̄ whose homogeneous
coordinates are given by l̃1 × l̃2 , where l̃1 = (a1 b1 c1 )T , l̃2 = (a2 b2 c2 )T , and × is the cross
product.
3. Show that two points x̄1 and x̄2 belonging to the projective space define a line l̃ whose homogeneous
coordinates are given by x̄1 × x̄2 .
4. Show that for all α ∈ R, the point x̄0 = (1 − α)x̄1 + αx̄2 lies on the line defined by x̄1 and x̄2 .

Exercise 2: Homogeneous Coordinates: Application


Let’s consider the following 2-dimensional lines l̃1 = (1 1 1)T and l̃2 = (3 2 1)T represented by
their homogeneous coordinates in the projective space P2 .

1. Compute the homogeneous coordinates of the intersection of l̃1 and l̃2 .


2. What is the corresponding point in R2 ?

The null space of an m × n matrix A is the set of objects x for which the multiplication Ax gives the
zero vector:
N (A) = {x ∈ Rn ; Ax = 0}. (1)

3. Verify that the point given by the intersection of l̃1 and l̃2 is in the null space of the matrix
 
3 2 1
M= (2)
1 1 1

4. Are there any other points in N (M ) besides this intersection point?

Let’s consider the following lines l̃3 = (1 2 3)T and l̃4 = (1 2 1)T in P2 .

5. Compute the intersection of l̃3 and l̃4 in P2 .


6. What is the geometric interpretation of the obtained result in R2 ?

Let’s consider the points x1 = (1 1) and x2 = (3 2) in R2 .

7. Compute the line going through x1 and x2 in P2 .

1
Exercise 3: 2D Transformations
Let’s begin with a couple simple observations.

Let’s consider vectors v1 = (1 4)T , v2 = (7 2)T , v3 = (3 3)T , and the following matrix:
 
3 −1
A= (3)
2 5

1. Calculate Av1 , Av2 and Av3 .


2. Let B a matrix whose columns are v1 , v2 and v3 , calculate the matrix dot product AB.
3. What do you notice about the columns of AB?

The above results indicate that we can consolidate many computation operations into one, at least
conceptually.

Now let’s augment A and v1 such that to obtain the matrix C and the vector w below, as follows:
   
3 −1 0 1
C = 2 5 0 , w = 4 (4)
0 0 1 1

4. Calculate Cw.

We notice that by augmenting matrices and vectors in the way above, the result of multiplication is
also augmented. For the remainder of the exercise, we will be working with transformations in R2
that move points around in the plane. We will represent points by their coordinates organized as a
column vectors.

In the following, we will be performing isometric transformations on the triangle 4P QR illustrated


in Figure 1, with vertices at P (2, 1), Q(4, 1) and R(4, 2). Isometric means “same measure”, that is,
both triangle side lengths and triangle angles will remain the same after the transformation. There
are really only three kinds of isometric transformations: rotations, reflections and translations. The
point of this exercise is to see how these transformations can be performed with matrices.

7
6
5
4
3 R
2
1 P Q
0
1
2
3
4
5
6
7
7 6 5 4 3 2 1 0 1 2 3 4 5 6 7

Figure 1: We perform 2D transformations on this triangle.

2
A rotation story.
Suppose that we wish to create a new triangle 4P 0 Q0 R0 by multiplying each of P , Q and R by the
matrix A given below, to get the new points P 0 , Q0 and R0 . Note that we can represent the triangle
4P QR by the matrix [P QR] given below. Hence, we can use what we discovered in question 3. to
create the 4P 0 Q0 R0 by simply multiplying A by [P QR] to get the matrix [P 0 Q0 R0 ] whose columns
are the coordinates of the points P 0 , Q0 and R0 .

   
0 −1 2 4 4
A= , [P QR] = (5)
1 0 1 1 2

5. Find 4P 0 Q0 R0 and draw it.


6. You should be able to see that the matrix A rotated the triangle around the origin, so that it must
be a rotation matrix. Write the expression of this rotation matrix using the appropriate rotation
angle.
7. On the drawing, rotate 4P QR around the point (2, 3) with the same angle as above. Do it by
intuition without using a matrix multiplication.

A translation story.
Now, suppose we wish to translate the entire triangle left by 3 units and up by 1 unit.

8. Can we write this transformation as multiplication of matrices (using a 2 by 2 matrix)?

The workaround to perform translation using matrix multiplication is to augment it and use of
homogeneous coordinates. In fact, we can use the following matrix T , where tx and ty are the
translation units along the x and the y axes.

 
1 0 tx
T = 0 1 ty  . (6)
0 0 1

9. Multiply the homogeneous coordinates of the vertices of 4P QR by a translation matrix T that


moves a point by 3 units to the left and 1 unit above. Draw the obtained triangle 4P 0 Q0 R0 .
10. Without doing any calculation, give the matrix that should “undo” this translation.
11. Find T −1 , the inverse of T . What do you observe?

A rotation & translation story.


Now, we will see the real power of matrices and homogeneous coordinates. Suppose that we wish to
find a matrix that rotates all points 90 degrees counterclockwise, about the point (2, 3), like we did
in question 7.. The idea is to take advantage of the fact that we already know how to rotate about
the origin, and how we translate.

12. Give the matrix T that translates (2, 3) to the origin.


13. Of course, the matrix to translate back is just T −1 . Give it without calculation.
14. Give the matrix R90 rotating a point 90 degrees counterclockwise around the origin.

It is easy to see that rotating a shape around the point (2, 3), is equivalent to translating “everything”

3
to put the point (2, 3) at the origin, rotate around the origin, then translate back.

15. Suppose a homogeneous coordinates vector v = (x y 1)T for a point (x, y) in the plane, how to
perform the 90 degrees rotation around the point (2, 3) using 3 matrices.
16. How to do it using 1 matrix?
17. Rotate 4P QR using this matrix, draw the result, and visually verify that you obtained the correct
result.

A reflection story.
We want to create a new triangle 4P 0 Q0 R0 by multiplying [P QR] by the matrix M given below.
 
1 0
M= (7)
0 −1

18. Perform the transformation using homogeneous coordinates of 4P QR, and the augmented version
of M . What this matrix does to the triangle?

Suppose that we want to reflect 4P QR across the line passing through the origin and at an angle of
60 degrees to the positive x-axis, as shown in Figure 1. We already know how to reflect across the
x-axis, so let’s take advantage of that fact.

It is easy to see that reflecting across the green line is equivalent to rotating the line to x-axis,
reflecting, than rotating back by 60 degrees.

19. Give the matrix doing this transformation.

Exercise 4: 2D Transformations - Application


Suppose that we wish to transform the square ABCD to the square A0 B 0 C 0 D0 , both shown on the
coordinate grid in Figure .

1. Find a single matrix that perform the aforementioned transformation.


2. Check that the proposed matrix works.

You might also like