Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented...

69
Linear Algebra Simplified

Transcript of Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented...

Page 1: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Linear Algebra Simplified

Page 2: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Readings

http://szeliski.org/Book/drafts/SzeliskiBook_20100903_draft.pdf -2.1.5 for camera geometry, -2.1.3, 2.1.4 for rotation representation

Page 3: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Inner (dot) Product

v w

α

332211

3

2

1

321 ..),,( yxyxyxyyy

xxxwvT ++=!!!

"

#

$$$

%

&

=

Page 4: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Inner (dot) Product

v w

α 332211

3

2

1

321 ..),,( yxyxyxyyy

xxxwvT ++=!!!

"

#

$$$

%

&

=

wvwvT ⊥⇔= 0

Page 5: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Cross product

X is normal to both v and w

Page 6: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Cross Product

Page 7: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Cross Product

+ -

Page 8: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Cross Product

+ -

Page 9: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Cross Product

+ -

Page 10: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set
Page 11: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example

Page 12: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Cross product as a matrix operator

v ⇥ u = v̂ · u

v̂ =

2

40 �x3 x2

x3 0 �x1

�x2 x1 0

3

5

Page 13: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Lines and Points

Page 14: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Line Representation

•  a line is

•  is the distance from the origin to the line •  is the norm direction of the line

•  It can also be written as

Page 15: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example of Line

Page 16: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example of Line (2)

0.42*pi

Page 17: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Line Homogeneous Representation

Page 18: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Homogeneous representation

Line in

Is represented by a point in :

But correspondence of line to point is not unique

We define set of equivalence class of vectors in R^3 - (0,0,0) As projective space

Page 19: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Point

Page 20: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Homogenous representation of point

A point lies on a line:

A point in P^2 is defined by the equivalence class of k(x,y,1)

Page 21: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Homogeneous Coordinates Homogeneous coordinates

•  represent coordinates in 2 dimensions with a 3-vector

!!!

"

#

$$$

%

&

''''' →'!"

#$%

&

1

coords shomogeneou yx

yx

A point:

Page 22: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Homogeneous -> Real Coordinates divide the third number out:

•  (x, y, w) represents a point at location (x/w, y/w) •  (x, y, 0) represents a point at infinity (in direction x,y)

•  (0, 0, 0) is not allowed

Convenient coordinate system to represent many useful transformations

1 2

1

2 (2,1,1) or (4,2,2) or (6,3,3)

x

y

Page 23: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example of Point

>> 0.6*42+0.8* 141 ans = 138

Page 24: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Line passing two points

Page 25: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Line passing through two points

l is the line passing two points

Two points:

Define a line

Proof:

x

Page 26: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Line passing through two points

•  More specifically,

Page 27: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Matlab codes

•  function l = get_line_by_two_points(x, y)

•  x1 = [x(1), y(1), 1]'; •  x2 = [x(2), y(2), 1]'; •  l = cross(x1, x2); •  l = l / sqrt(l(1)*l(1)+l(2)*l(2));

Page 28: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example of Line

>> 218*0.6+13*0.8 ans = 141.2000

Verify p2 lies on the line P2

P1 (close)

Page 29: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example of Line P2

P1

>> p1 = [42,142,1]; >> p2=[218,13,1]; >> l = cross(p1,p2) l = 129 176 -30410

Test line:

>> l = l/sqrt(l(1)^2+l(2)^2) l = 0.5912 0.8066 -139.3591

Page 30: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

>> x = [221;23]; >> y = [218;268]; >> l = get_line_by_two_points(x,y); >> l l = -0.2448 -0.9696 265.4744

Page 31: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Point passing two lines

Page 32: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Intersection of lines

Define a point

Given two lines: ,

X is the intersection of the two lines

l

Page 33: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Intersection of lines

•  More specifically,

Page 34: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Matlab codes

•  function x0 = get_point_by_two_line(l, l1)

•  x0 = cross(l, l1); •  x0 = [x0(1)/x0(3); x0(2)/x0(3)];

Page 35: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example of Lines Intersection

Page 36: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Point and Line at infinity

Page 37: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Point at infinity

Example: Consider two parallel horizontal lines:

Intersection =

Point at infinity in the direction of y

Page 38: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Point at infinity, Ideal points

Intersection:

Any point (x1,x2,0) is intersection of lines at infinity

Page 39: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Points at infinity

•  Under projective transformation, •  All parallel lines intersects at the point at infinity

•  One point at infinity ó one parallel line direction

•  Where are the points at infinity in the image plane?

Page 40: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Line at infinity

•  A line passing all points at infinity:

•  Because :

Page 41: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Projective Transformation

Page 42: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

From Plane to Plane

Page 43: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Projective transformation Goal: study geometry of image projection from one plane to another plane(the image plane).

Facts: 1) parallel lines intersect, 2) circle becomes ellipses, 3) straight line is still straight

Page 44: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Projective transformation

Definition: Line remains a line! Projective transform is an invertible mapping from to itself, such that three points lies on a same line iff do.

0 0.5 1

0

0.2

0.4

0.6

0.8

1

0.6 0.8 1 1.2

2

2.2

2.4

2.6

2.8

3

3.2

3.4

x1

x2

x3

h(x1)

h(x2)

h(x3)

Page 45: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

•  Theorem:

Projective transformation

Check what happened to lies on line l?

Line Mapping:

Page 46: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

=

x’ y’

x y

How many independent para? Can we always set h33 = 1?

Page 47: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Classes of 2D projective transformations

Page 48: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Special case: Similarity Transformation

Similarity

0 0.2 0.4 0.6 0.8 1

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 0.5 1 1.5 2

2

2.5

3

3.5

4

4.5

Page 49: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Special Case: Affine Transformation

0 0.1 0.2 0.3 0.4 0.5

0

0.05

0.1

0.15

0.2

0.25

0.3

0 0.2 0.4 0.6 0.8 1

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 0.5 1 1.5

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

Page 50: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Special case: Projective transformation

0 0.2 0.4 0.6 0.8 1

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 0.1 0.2 0.3 0.4 0.5

0

0.05

0.1

0.15

0.2

0.25

0.3

Page 51: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set
Page 52: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example

0.6 0.8 1 1.2

2

2.2

2.4

2.6

2.8

3

3.2

3.40 0.2 0.4 0.6 0.8 1

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

10 0.1 0.2 0.3

0

0.1

0.2

0.3

0.4

0.5

0.6

0 0.1 0.2 0.3 0.4 0.5

0

0.05

0.1

0.15

0.2

0.25

0.3

Page 53: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example

•  Projective

0 0.2 0.4 0.6 0.8 1

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 0.1 0.2 0.3 0.4 0.5

0

0.05

0.1

0.15

0.2

0.25

0.3

Page 54: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example

Affine

0 0.1 0.2 0.3

0

0.1

0.2

0.3

0.4

0.5

0.6

0 0.1 0.2 0.3 0.4 0.5

0

0.05

0.1

0.15

0.2

0.25

0.3

Page 55: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example

0 0.1 0.2 0.3

0

0.1

0.2

0.3

0.4

0.5

0.6

Similarity

0.6 0.8 1 1.2

2

2.2

2.4

2.6

2.8

3

3.2

3.4

Page 56: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Matlab codes

•  function img_now = projective_transform(img, H);

•  px = [0 1]; •  py = [0 1]; •  tform = maketform('projective', H'); •  [img_now, xdata, ydata]= imtransform(img, tform,

'udata', ... •  px, 'vdata', py, 'size', size(img));

Page 57: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

•  Extra slides

Page 58: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Points, Lines & Projective Transformation

Page 59: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Lines under Projective Transformation • With homogenous coordinates:

• Point:

• Line:

Page 60: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Before transformation

Page 61: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

After transformation

Page 62: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Just checking…

•  Verify:

Page 63: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Vanishing point, revisited

Page 64: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Points at infinity: Revisited

•  Where are the points at infinity in the image plane? •  The point at infinity can be in the FINITE region of the image !

Page 65: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Example

Page 66: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Seeing vanishing point

•  vanishing point of horizontal direction:

Page 67: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

•  In the image plane:

Line at infinity: Revisited

•  A line passing all points at infinity:

Page 68: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

Line of infinity

•  line of infinity is:

Notice: this is the last column of

Page 69: Linear Algebra Simplifiedcis580/Spring2015/... · Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set

The line of infinity