21.01.2015 Views

1. Homogeneous Coordinates and Tensor Notation - PRIMA

1. Homogeneous Coordinates and Tensor Notation - PRIMA

1. Homogeneous Coordinates and Tensor Notation - PRIMA

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Coordonnées Homogènes Séance 1<br />

Image Analysis <strong>and</strong> Formation<br />

(Formation et Analyse d'Images)<br />

James L. Crowley<br />

ENSIMAG 3 - MMIS Option MIRV First Semester 2010/2011<br />

Lesson 1 27 sept 2010<br />

Lesson Outline:<br />

<strong>Homogeneous</strong> <strong>Coordinates</strong><br />

<strong>1.</strong> <strong>Homogeneous</strong> <strong>Coordinates</strong> <strong>and</strong> <strong>Tensor</strong> <strong>Notation</strong>..........2<br />

<strong>Tensor</strong> <strong>Notation</strong>: ......................................................................... 3<br />

2. Cross Products ..............................................................5<br />

Two point make a line................................................................. 5<br />

Two lines make a point ............................................................... 6<br />

1-1


Coordonnées Homogènes Séance 1<br />

<strong>1.</strong> <strong>Homogeneous</strong> <strong>Coordinates</strong> <strong>and</strong> <strong>Tensor</strong> <strong>Notation</strong><br />

<strong>Homogeneous</strong> coordinates allow us to express translation, rotation, scaling, <strong>and</strong><br />

projection all as matrix operations. The principle is to add an extra dimension to each<br />

vector.<br />

For example, points on a plane are expressed as:<br />

r<br />

P =<br />

" x%<br />

$ '<br />

y<br />

$<br />

'<br />

# 1&<br />

Similarly, points in 3D space become<br />

!<br />

r<br />

Q =<br />

" x%<br />

$ '<br />

$<br />

y<br />

'<br />

$ z'<br />

$ '<br />

# 1&<br />

! The line equation, ax+by+c=0 can be expressed as a simple product:<br />

r<br />

L r T P = a b c<br />

( )<br />

" x%<br />

$ '<br />

y<br />

$ ' = 0<br />

# 1&<br />

where<br />

r<br />

L T = a b c ( )<br />

!<br />

Similarly, for a plane equation: ax+by+cz+d=1: !<br />

r<br />

S r T P = a b c d<br />

( )<br />

" x%<br />

$ '<br />

$<br />

y<br />

' = 0 where<br />

$ z'<br />

$ '<br />

# 1&<br />

r<br />

S = a b c d<br />

( )<br />

!<br />

!<br />

!<br />

Note that in <strong>Homogeneous</strong> coordinates, all scalar multiplications are equivalent.<br />

" x%<br />

" x%<br />

$ '<br />

a<br />

y<br />

$ ' = b $ '<br />

y<br />

$ '<br />

# 1&<br />

# 1&<br />

Any vector can be expressed in "canonical" form by normalizing the last coefficient<br />

to <strong>1.</strong><br />

1-2


Coordonnées Homogènes Séance 1<br />

" ax%<br />

" ax /a%<br />

" x%<br />

$ '<br />

ay<br />

$ ' = $ '<br />

ay /a<br />

$ ' = $ '<br />

y<br />

$ '<br />

# a & # a/a & # 1&<br />

! Our camera model will have the form of a 3 x 4 matrix<br />

M s<br />

i<br />

=<br />

" m 11<br />

m 12<br />

m 13<br />

m 14<br />

%<br />

$<br />

'<br />

m 21<br />

m 22<br />

m 23<br />

m 24<br />

$<br />

'<br />

# m 31<br />

m 32<br />

m 33<br />

m 34 &<br />

!<br />

such that<br />

"<br />

$<br />

$<br />

$<br />

$<br />

$<br />

#<br />

%<br />

' "<br />

' $<br />

' =<br />

1 ' $<br />

'<br />

#<br />

&<br />

q 1<br />

q3<br />

q 2<br />

q3<br />

q 1<br />

q 2<br />

q 3<br />

%<br />

'<br />

' = r i<br />

Q = M s<br />

P r<br />

=<br />

&<br />

" x<br />

" m 11<br />

m 12<br />

m 13<br />

m 14<br />

% s<br />

%<br />

$ '<br />

$<br />

'<br />

m 21<br />

m 22<br />

m 23<br />

m $<br />

y s '<br />

24<br />

$<br />

' $ z s<br />

'<br />

# m 31<br />

m 32<br />

m 33<br />

m 34 & $ '<br />

# 1 &<br />

! We can express this in "canonical form" by dividing out the last coefficient:<br />

M s<br />

i<br />

=<br />

" m 11<br />

m 12<br />

m 13<br />

m 14<br />

%<br />

$<br />

'<br />

m 21<br />

m 22<br />

m 23<br />

m 24<br />

$<br />

'<br />

# m 31<br />

m 32<br />

m 33<br />

1 &<br />

!<br />

!<br />

Notice that this gives 11 coefficients. This corresponds to our 11 parameters. The<br />

Rank of M is 1<strong>1.</strong><br />

<strong>Tensor</strong> <strong>Notation</strong>:<br />

In tensor notation, the sign " → " is remplaced by subscripts <strong>and</strong> superscripts.<br />

A super-script signifies a column vector.<br />

r<br />

For example the point P is P i<br />

The line<br />

"<br />

P i $<br />

=<br />

$<br />

#<br />

p 1<br />

p 2<br />

p 3<br />

%<br />

'<br />

!<br />

'<br />

&<br />

r<br />

L T is L i = (l 1 , l 2 , l 3 )<br />

!<br />

1-3


Coordonnées Homogènes Séance 1<br />

A matrix is a line matrix of column matrices (or a column of line matrices)<br />

"<br />

$<br />

M j i<br />

= $<br />

$<br />

#<br />

m<br />

1<br />

1<br />

m<br />

1<br />

2<br />

m<br />

1<br />

3<br />

m 2<br />

1<br />

m<br />

2<br />

2<br />

m<br />

2<br />

3<br />

m 3<br />

1<br />

m<br />

3<br />

2<br />

m<br />

3<br />

3<br />

%<br />

'<br />

'<br />

'<br />

&<br />

! When homogeneous coordinates are used to represent transforms, these indices can<br />

be used to indicate the reference frame.<br />

For example: A transformation from the scene "s" to the image "i"<br />

is a 3 x 4 matrix M<br />

"<br />

$<br />

M i s<br />

= $<br />

$<br />

#<br />

m 1<br />

1<br />

m 1<br />

2<br />

m 1<br />

3<br />

m 2<br />

1<br />

m 2<br />

2<br />

m 2<br />

3<br />

m 3<br />

1<br />

m 3<br />

2<br />

m 3<br />

3<br />

%<br />

'<br />

'<br />

1<br />

'<br />

&<br />

m 4<br />

1<br />

m 4<br />

2<br />

The sub/super scripts indicate the source <strong>and</strong> destination reference frames.<br />

i<br />

M s<br />

is ! a transformation from "S" (Scene) to "i" (image).<br />

!<br />

Einstein summation convention:<br />

The summation symbol is implicit when a superscript adn subscript have the same<br />

letter.<br />

L i P i = l 1 p 1 + l 2 p 2 + l 3 p 3<br />

for a matrix <strong>and</strong> vector, this gives a new vector:<br />

p j = T i j p i<br />

! This example transforms the point p in reference i to a point p in reference j.<br />

1-4


!<br />

Coordonnées Homogènes Séance 1<br />

2. Cross Products<br />

Two point make a line<br />

A line is a set of points that satisfies a constraint. The constraint is the line equation.<br />

r<br />

L r T P = ax + by + c = 0<br />

The constraint can be determined from any two points on the line P 1 = (x 1 ,y 1 ) <strong>and</strong><br />

P 2 = (x 2 ,y 2 ).<br />

Classically, we subsitute P 1 <strong>and</strong> P 2 in the line equation to obtain two equations<br />

ax 1 + by 1 + c = 0<br />

ax 2 + by 2 + c = 0<br />

We then solve the two equations for a, b <strong>and</strong> c. This should give :<br />

a = (y 1 –y 2 ) b = (x 2 – x 1 )<br />

c = –(a x 1 – b y 1 ) = – x 1 (y 1 –y 2 )– y 1 (x 2 – x 1 ) = x 1 y 2 +x 2 y 1<br />

if we normalize such that || (a, b) || = 1 then<br />

d = ax + by + c<br />

where d is a signed perpendicular distance from the line, positive to the left <strong>and</strong><br />

negative to the right.<br />

In fact the constraint imposed by the line can be discovered from the cross product of<br />

the two points:<br />

L T = ⎜ ⎜⎛ a<br />

b ⎝ c⎠ ⎟⎟⎞<br />

= P → 1 x P → 2 = ⎜ ⎜⎛ 0 –1 y 1 x 2<br />

1 0 –x 1<br />

⎝ –y ⎠ ⎟⎟⎞<br />

1 x 1 0 ⎝ ⎜⎜⎛ y 2<br />

⎠ ⎟⎟⎞ = ⎜ ⎜⎛ y 1 –y 2<br />

x 2 –x 1<br />

1 ⎝ x ⎠ ⎟⎟⎞<br />

1 y 2 –x 2 y 1<br />

This is equivalent to a setting the determinant to zero with free variables in one of the<br />

rows.<br />

x y 1<br />

x 1<br />

y 1<br />

1 = x(y 1<br />

– y 2<br />

)+ y(x 2<br />

– x 1<br />

)+ x 1<br />

y 2<br />

– x 2<br />

y 1<br />

= 0<br />

x 2<br />

y 2<br />

1<br />

!<br />

1-5


Coordonnées Homogènes Séance 1<br />

This is a simple example of a general principle that can be useful in higher<br />

dimensions.<br />

Two lines make a point<br />

There is a perfect duality between points <strong>and</strong> lines. So naturally, two lines make a<br />

point.<br />

Given non-parallel lines L <strong>and</strong> M.<br />

L: a 1<br />

x + b 1<br />

y + c 1<br />

= 0<br />

<strong>and</strong> M : a 2<br />

x + b 2<br />

y + c 2<br />

= 0.<br />

In classic notation L T = (a 1<br />

, b 1<br />

, c 1 ) et M T =(a 2<br />

, b 2<br />

, c 2 )<br />

The unique point is<br />

y = c 1a 2<br />

" c 2<br />

a 1<br />

c 1<br />

a 2<br />

" c 2<br />

a 1<br />

The cross product is<br />

!<br />

P → = L → x M → =<br />

x = b 1c 2<br />

" b 2<br />

c 1<br />

a 1<br />

b 2<br />

" a 2<br />

b 1<br />

!<br />

v<br />

P = L v<br />

" M v # 0 –c 1<br />

b 1<br />

&#<br />

%<br />

(%<br />

=<br />

c 1<br />

0 –a 1<br />

%<br />

(%<br />

$ –b 1<br />

a 1<br />

0 ' $<br />

a 2<br />

b 2<br />

c 2<br />

& #–c 1<br />

b 2<br />

+ b 1<br />

c 2<br />

& b 1 c 2 –c 1 b 2<br />

(<br />

( = % (<br />

c 1<br />

a 2<br />

– a 1<br />

c 2<br />

= % ( ⎝ ⎜⎜⎛ c 1 a 2 –a 1 c 2<br />

a ⎠ ⎟⎟⎞<br />

' $ –a 2<br />

b 1<br />

+ a 1<br />

b 1 b 2 –a 2 b 1<br />

2 '<br />

as before the cross ! product is equivalent to setting a determinant to zero. In this case:<br />

a b c<br />

a 1<br />

b 1<br />

c 1<br />

= a(b 1<br />

c 2<br />

– c 1<br />

b 2<br />

)+ b(c 1<br />

a 2<br />

– a 1<br />

c 2<br />

)+ c(a 1<br />

b 2<br />

– b 1<br />

a 2<br />

) = 0<br />

a 2<br />

b 2<br />

c 2<br />

!<br />

The unique point is<br />

x = b 1 c 2 " b 2 c 1<br />

a 1<br />

b 2<br />

" a 2<br />

b 1<br />

!<br />

y = c 1 a 2 " c 2 a 1<br />

c 1<br />

a 2<br />

" c 2<br />

a 1<br />

!<br />

1-6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!