Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that...

47
Computer Graphics Recitation 5
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    220
  • download

    2

Transcript of Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that...

Page 1: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

Computer Graphics

Recitation 5

Page 2: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

2

Motivation – Shape Matching

What is the best transformation that aligns the dinosaur with the dog?

Page 3: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

3

Motivation – Shape Matching

The above is not a good matching….

Regard the shapes as sets of points and try to “match” these setsusing a linear transformation

Page 4: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

4

Motivation – Shape Matching

Regard the shapes as sets of points and try to “match” these setsusing a linear transformation

To find the best transformation we need to know SVD…

Page 5: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

5

Finding underlying dimensionality

x

y

Given a set of points, find the best line thatapproximates it – reduce the dimension of the data set…

Page 6: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

6

Finding underlying dimensionality

x

y

Given a set of points, find the best line thatapproximates it – reduce the dimension of the data set…

x’y’

Page 7: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

7

Finding underlying dimensionality

x

y

When we learn PCA (Principal Component Analysis),we’ll know how to find these axes that minimize

the sum of distances2

x’y’

Page 8: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

8

PCA and SVD

PCA and SVD are important tools not only in graphics but also in statistics, computer vision and more.

To learn about them, we first need to get familiar with eigenvalue decomposition.

So, today we’ll start with linear algebra basics reminder.

Page 9: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

9

The plan today

Basic linear algebra review. Eigenvalues and eigenvectors.

Page 10: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

10

Vector space

Informal definition: V (a non-empty set of vectors)

v, w V v + w V (closed under addition)

v V, is scalar v V (closed under multiplication by scalar)

Formal definition includes axioms about associativity and distributivity of the + and operators.

Page 11: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

11

Subspace - example

Let l be a 2D line though the origin L = {p – O | p l} is a linear subspace of R2

x

y

O

Page 12: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

12

Subspace - example

Let be a plane through the origin in 3D V = {p – O | p } is a linear subspace of R3

y

z

x

O

Page 13: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

13

Linear independence

The vectors {v1, v2, …, vk} are a linearly independent set if:

1v1 + 2v2 + … + kvk = 0 i = 0 i

It means that none of the vectors can be obtained as a linear combination of the others.

Page 14: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

14

Linear independence - example

Parallel vectors are always dependent:

Orthogonal vectors are always independent.

vw

v = 2.4 w v + (2.4)w = 0

Page 15: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

15

Basis

{v1, v2, …, vn} are linearly independent

{v1, v2, …, vn} span the whole vector space V:

V = {1v1 + 2v2 + … + nvn | i is scalar}

Any vector in V is a unique linear combination of the basis.

The number of basis vectors is called the dimension of V.

Page 16: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

16

Basis - example

The standard basis of R3 – three unit orthogonal vectors x, y, z: (sometimes called i, j, k or e1, e2, e3)

y

z

x

Page 17: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

17

Matrix representation

Let {v1, v2, …, vn} be a basis of V Every vV has a unique representation

v = 1v1 + 2v2 + … + nvn

Denote v by the column-vector:

The basis vectors are therefore denoted:

n

v

1

1

0

0

0

1

0

0

0

1

Page 18: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

18

Linear operators

A : V W is called linear operator if: A(v + w) = A(v) + A(w) A(v) = A(v)

In particular, A(0) = 0 Linear operators we know:

Scaling Rotation, reflection Translation is not linear – moves the origin

Page 19: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

19

Linear operators - illustration

Rotation is a linear operator:

v

w

v+w

R(v+w)

v

w

Page 20: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

20

Linear operators - illustration

Rotation is a linear operator:

v

w

v+w

R(v+w)

v

wR(w)

Page 21: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

21

Linear operators - illustration

Rotation is a linear operator:

v

w

v+w

R(v+w)

v

wR(w)R(v)

Page 22: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

22

Linear operators - illustration

Rotation is a linear operator:

v

w

v+w

R(v+w)

v

wR(w)R(v)

R(v)+R(w)

R(v+w) = R(v) + R(w)

Page 23: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

23

Matrix representation of linear operators

Look at A(v1),…, A(vn) where {v1, v2, …, vn} is a basis.

For all other vectors: v = 1v1 + 2v2 + … + nvn

A(v) = 1A(v1) + 2A(v2) + … + nA(vn) So, knowing what A does to the basis is enough The matrix representing A is:

|||

)()()(

|||

21 nA vAvAvAM

Page 24: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

24

Matrix representation of linear operators

|

)(

|

0

0

1

|||

)()()(

|||

121 vAvAvAvA n

|

)(

|

0

1

0

|||

)()()(

|||

221 vAvAvAvA n

Page 25: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

25

Matrix operations

Addition, subtraction, scalar multiplication – simple…

Matrix by column vector:

iimi

iii

nmnm

n

ba

ba

b

b

aa

aa

1

1

1

111

Page 26: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

26

Matrix operations

Transposition: make the rows columns

(AB)T = BTAT

mnn

m

T

mnm

n

aa

aa

aa

aa

1

111

1

111

Page 27: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

27

Matrix operations

Inner product can in matrix form:

vwwvwv TT ,

Page 28: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

28

Matrix properties

Matrix A (nn) is non-singular if B, AB = BA = I B = A-1 is called the inverse of A A is non-singular det A 0

If A is non-singular then the equation Ax=b has one unique solution for each b.

A is non-singular the rows of A are linearly independent set of vectors.

Page 29: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

29

Vector product

v w is a new vector: ||v w|| = ||v|| ||w|| |sin(v,w)| v w v, v w w v, w, v w is a right-hand system

In matrix form in 3D:

),,(

ˆˆˆ

det

),,(,),,(

122113312332

321

321

321321

wvwvvwvwwvwv

www

vvv

kji

wv

wwwwvvvv TT

v

w

vw

Page 30: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

30

Orthogonal matrices

Matrix A (nn) is orthogonal if A-1 = AT

Follows: AAT = ATA = I The rows of A are orthonormal vectors!

Proof:

I = ATA = v1

v2

vn

= viTvj = ij

v1 v2 vn

<vi, vi> = 1 ||vi|| = 1; <vi, vj> = 0

Page 31: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

31

Orthogonal operators

A is orthogonal matrix A represents a linear operator that preserves inner product (i.e., preserves lengths and angles):

Therefore, ||Av|| = ||v|| and (Av,Aw) = (v,w)

.,

)()(,

wvwvwIv

AwAvAwAvAwAvTT

TTT

Page 32: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

32

Orthogonal operators - example

Rotation by around the z-axis in R3 :

In fact, any orthogonal 33 matrix represents a rotation around some axis and/or a reflection detA = +1 rotation only detA = 1 with reflection

100

0cossin

0sincos

R

Page 33: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

33

Eigenvectors and eigenvalues

Let A be a square nn matrix v is eigenvector of A if:

Av = v ( is a scalar) v 0

The scalar is called eigenvalue

Av = v A(v) = (v) v is also eigenvector

Av = v, Aw = w A(v+w) = (v+w) Therefore, eigenvectors of the same form a linear

subspace.

Page 34: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

34

Eigenvectors and eigenvalues

An eigenvector spans an axis that is invariant to A – it remains the same under the transformation.

Example – the axis of rotation:

O

Eigenvector of therotation transformation

Page 35: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

35

Finding eigenvalues

For which is there a non-zero solution to Ax = x ? Ax = x Ax – x = 0 Ax – Ix = 0 (A- I)x = 0 So, non trivial solution exists det(A – I) = 0

A() = det(A – I) is a polynomial of degree n. It is called the characteristic polynomial of A. The roots of A are the eigenvalues of A. Therefore, there are always at least complex

eigenvalues. If n is odd, there is at least one real eigenvalue.

Page 36: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

36

Example of computing A

411

303

201

A

)32)(3(

)3(2)3()1()3(2)3)4()(1(

411

33

201

det)(

2

2

A

Cannot be factorized over ROver C: )21)(21( ii

Page 37: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

37

Computing eigenvectors

Solve the equation (A – I)x = 0 We’ll get a subspace of solutions.

Page 38: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

38

Spectra and diagonalization

The set of all the eigenvalues of A is called

the spectrum of A. A is diagonalizable if A has n independent

eigenvectors. Then:

nnn vAv

vAv

vAv

222

111

A v2v1 vn= v2v1 vn

1

2

n

AV = VD

Page 39: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

39

Spectra and diagonalization

Therefore, A = VDV1, where D is diagonal A represents a scaling along the eigenvector

axes!

nnn vAv

vAv

vAv

222

111

A = v2v1 vn

1

2

n

v2v1 vn

1

A = VDV1

Page 40: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

40

Spectra and diagonalization

A is called normal if AAT = ATA. Important example: symmetric matrices A = AT. It can be proved that normal nn matrices have

exactly n linearly independent eigenvectors (over C).

If A is symmetric, all eigenvalues of A are real, and it has n independent real orthonormal eigenvectors.

Page 41: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

41

Spectra and diagonalization

A Drotationreflection

orthonormalbasis

otherorthonormal

basis

Page 42: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

42

Spectra and diagonalization

A

Page 43: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

43

Spectra and diagonalization

A

Page 44: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

44

Spectra and diagonalization

A

Page 45: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

45

Spectra and diagonalization

A

Page 46: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

46

Why SVD…

Diagonalizable matrix is essentially a scaling Most matrices are not diagonalizable – they do

other things along with scaling (such as rotation)

So, to understand how general matrices behave, only eigenvalues are not enough

SVD tells us how general linear transformations behave, and other things…

Page 47: Computer Graphics Recitation 5. 2 Motivation – Shape Matching What is the best transformation that aligns the dinosaur with the dog?

See you next time