22
1 CSE554 Alignment Slide 1 CSE 554 Lecture 5: Alignment CSE 554 Lecture 5: Alignment Fall 2011 CSE554 Alignment Slide 2 Review Review Fairing (smoothing) Relocating vertices to achieve a smoother appearance Method: centroid averaging Simplification Reducing vertex count Method: edge collapsing

CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

1

CSE554 Alignment Slide 1

CSE 554

Lecture 5: Alignment

CSE 554

Lecture 5: Alignment

Fall 2011

CSE554 Alignment Slide 2

ReviewReview

• Fairing (smoothing)

– Relocating vertices to achieve a smoother appearance

– Method: centroid averaging

• Simplification

– Reducing vertex count

– Method: edge collapsing

Page 2: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

2

CSE554 Alignment Slide 3

Simplification (2D)Simplification (2D)

• The algorithm

– Step 1: For each edge, compute the best vertex location to replace that edge, and the QEM at that location.

• Store that location (called minimizer) and its QEM with the edge.

CSE554 Alignment Slide 4

Simplification (2D)Simplification (2D)

• The algorithm

– Step 1: For each edge, compute the best vertex location to replace that edge, and the QEM at that location.

• Store that location (called minimizer) and its QEM with the edge.

– Step 2: Pick the edge with the lowest QEM and collapse it to its minimizer.

• Update the minimizers and QEMs of the re-connected edges.

Page 3: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

3

CSE554 Alignment Slide 5

Simplification (2D)Simplification (2D)

• The algorithm

– Step 1: For each edge, compute the best vertex location to replace that edge, and the QEM at that location.

• Store that location (called minimizer) and its QEM with the edge.

– Step 2: Pick the edge with the lowest QEM and collapse it to its minimizer.

• Update the minimizers and QEMs of the re-connected edges.

CSE554 Alignment Slide 6

Simplification (2D)Simplification (2D)

• The algorithm

– Step 1: For each edge, compute the best vertex location to replace that edge, and the QEM at that location.

• Store that location (called minimizer) and its QEM with the edge.

– Step 2: Pick the edge with the lowest QEM and collapse it to its minimizer.

• Update the minimizers and QEMs of the re-connected edges.

– Step 3: Repeat step 2, until a desired number of vertices is left.

Page 4: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

4

CSE554 Alignment Slide 7

Simplification (2D)Simplification (2D)

• The algorithm

– Step 1: For each edge, compute the best vertex location to replace that edge, and the QEM at that location.

• Store that location (called minimizer) and its QEM with the edge.

– Step 2: Pick the edge with the lowest QEM and collapse it to its minimizer.

• Update the minimizers and QEMs of the re-connected edges.

– Step 3: Repeat step 2, until a desired number of vertices is left.

CSE554 Alignment Slide 8

Simplification (2D)Simplification (2D)

• Step 1: Computing minimizer and QEM on an edge

– Consider supporting lines of this edge and adjacent edges

– Compute and store at the edge:

• The minimizing location p

• QEM of p

• QEM coefficients (a, b, c)

Stored at the edge:

p

a, b, c, p, QEMp

Page 5: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

5

CSE554 Alignment Slide 9

Simplification (2D)Simplification (2D)

• Step 2: Collapsing an edge

– Remove the edge and its vertices

– Re-connect two neighbor edges to the minimizer of the removed edge

– For each re-connected edge:

• Increment its coefficients by that of the removed edge

– The coefficients are additive!

• Re-compute its minimizer and QEM

a, b, c,

p, QEMpa1, b1, c1,

p1, QEMp1a2, b2, c2,

p2, QEMp2

p

a a1,

b b1,

c c1,

p1, QEMp1

a a2,

b b2,

c c2,

p2, QEMp2

Collapse

: new minimizer locations computed from the updated coefficients

p1, p2

CSE554 Alignment Slide 10

ReviewReview

• Fairing (smoothing)

– Relocating vertices to achieve a smoother appearance

– Method: centroid averaging

• Simplification

– Reducing vertex count

– Method: edge collapsing

Page 6: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

6

CSE554 Alignment Slide 11

RegistrationRegistration

• Fitting one model to match the shape of another

– Automated annotation

– Tracking and motion analysis

– Shape and data comparison

Courtesy: Schneider and EisertCourtesy: Sowell et al.

CSE554 Alignment Slide 12

RegistrationRegistration

• Challenges: global and local shape differences

– Imaging causes global shifts and tilts

• Requires alignment

– The shape of the organ or tissue differs in subjects and evolve over time

• Requires deformation

Brain outlines of two mice After alignment After deformation

Page 7: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

7

CSE554 Alignment Slide 13

AlignmentAlignment

• Registration by translation or rotation

– The structure stays “rigid” under these two transformations

• Also called isometric transformations (distance-preserving)

– Accounts for shifts and tilts in imaging

Before alignment After alignment

CSE554 Alignment Slide 14

Transformation Math Transformation Math

• Translation

– Vector addition:

– 2D:

– 3D:

px'

py' vx

vy px

py

px'

py'

pz'

vxvy

vz

pxpy

pz

p' v p

p

p'

v

Page 8: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

8

CSE554 Alignment Slide 15

Transformation Math Transformation Math

• Rotation

– Matrix product:

– 2D:

• Rotate around the origin!

• To rotate around another point q:

px'

py' R px

py

R Cos SinSin Cos

p' Rp

p

p'

x

y

p' R p q q

CSE554 Alignment Slide 16

Transformation Math Transformation Math

• Rotation

– Matrix product:

– 3D:

px'

py'

pz'

Rpxpy

pz

Around X axis:

Around Y axis:

Around Z axis:

p' Rp

x

y

z

Rx 1 0 00 Cos Sin0 Sin Cos

Ry Cosa 0 Sina

0 1 0Sina 0 Cosa

Rz Cosa Sina 0Sina Cosa 0

0 0 1

Page 9: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

9

CSE554 Alignment Slide 17

Transformation Math Transformation Math

• Properties of a rotational matrix

– Orthonormal (orthogonal and normal):

• Examples:

• Easy to invert:

– Any orthonormal matrix represents a rotation

RRT I

Cos SinSin Cos Cos Sin

Sin Cos 1 00 1

1 0 00 Cos Sin0 Sin Cos

1 0 00 Cos Sin0 Sin Cos

1 0 00 1 00 0 1

R1 RT

CSE554 Alignment Slide 18

Transformation Math Transformation Math

• Properties of a rotational matrix

– The rotation angle can be obtained from the trace of the matrix

• Trace: sum of diagonal entries

• 2D:

• 3D:

– α is the angle of rotation around the rotation axes

– True for rotation around any axes (not just X,Y,Z)

– The larger the trace, the smaller the rotation angle

TrR 2 CosTrR 1 2 Cos

Cos SinSin Cos

Page 10: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

10

CSE554 Alignment Slide 19

Transformation Math Transformation Math

• Eigenvectors and eigenvalues

– Let M be a square matrix, v is an eigenvector and λ is an eigenvalue if:

• Intuitively, if M represents a transformation, an eigenvector is invariant (up to scale) under the transformation.

– There are at most m distinct eigenvalues for a m by m matrix

– Any scalar multiples of an eigenvector is also an eigenvector (with the same eigenvalue).

M v v

CSE554 Alignment Slide 20

AlignmentAlignment

• Input: two models represented as point sets

– Source and target

• Output: locations of the translated and rotated source points

Source

Target

Page 11: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

11

CSE554 Alignment Slide 21

AlignmentAlignment

• Method 1: Principal component analysis (PCA)

– Aligning principal directions

• Method 2: Singular value decomposition (SVD)

– Optimal alignment given prior knowledge of correspondence

• Method 3: Iterative closest point (ICP)

– An iterative SVD algorithm that computes correspondences as it goes

CSE554 Alignment Slide 22

Method 1: PCAMethod 1: PCA

• Compute a shape-aware coordinate system for each model

– Origin: Centroid of all points

– Axes: Directions in which the model varies most or least

• Transform the source to align its origin/axes with the target

Page 12: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

12

CSE554 Alignment Slide 23

Method 1: PCAMethod 1: PCA

• Computing axes: Principal Component Analysis (PCA)

– Consider a set of points p1,…,pn with centroid location c

• Let P be a matrix whose i-th column is vector pi – c

– 2D (2 by n):

– 3D (3 by n):

• Build the covariance matrix:

– 2D: a 2 by 2 matrix

– 3D: a 3 by 3 matrix

M PPT

pi

c

P p1x cx p2x cx ... pnx cx

p1y cy p2y cy ... pny cy

P

p1x cx p2x cx ... pnx cx

p1y cy p2y cy ... pny cy

p1z cz p2z cz ... pnz cz

CSE554 Alignment Slide 24

Method 1: PCAMethod 1: PCA

• Computing axes: Principal Component Analysis (PCA)

– Eigenvectors of M represent principal directions of shape variation

• The eigenvectors form orthogonal axes (2 vectors in 2D; 3 vectors in 3D)

– Note they are “un-signed”: lacking an orientation.

– Eigenvalues indicate amount of variation along each eigenvector

• Eigenvector with largest (smallest) eigenvalue is the direction where the model shape varies the most (least)

Eigenvector with the largest eigenvalue

Eigenvector with the smallest eigenvalue

Page 13: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

13

CSE554 Alignment Slide 25

Method 1: PCAMethod 1: PCA

• PCA-based alignment

– Let cS,cT be centroids of source and target.

– First, translate source to align cS with cT:

– Next, find rotation R that aligns two sets of PCA axes, and rotate source around cT:

– Combined:

pi pi cT cS

pi ' cT Rpi cT

pi ' cT Rpi cS

pi

pi

pi '

cT

cS

cT

cT

CSE554 Alignment Slide 26

Method 1: PCAMethod 1: PCA

• Rotational alignment of two sets of oriented axes

– Let A, B be two matrices whose columns are two sets of oriented axes

• The axes are orthogonal and normalized

– We wish to compute a rotation matrix R such that:

– Notice that A and B are orthonormal, so we have:

R A B

R B A1 B AT

Page 14: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

14

CSE554 Alignment Slide 27

Method 1: PCAMethod 1: PCA

• How to orient the PCA axes?

– Observing the right-hand rule

– There are 2 possible orientation assignments in 2D, and 4 in 3D

1st eigenvector 2nd eigenvector 3rd eigenvector

CSE554 Alignment Slide 28

Method 1: PCAMethod 1: PCA

• Computing rotation R

– Fix the orientation of the target axes.

– For each orientation assignment of the source axes, compute R

– Pick the R with smallest rotation angle (by checking the trace of R)

Smaller rotation Larger rotation

Page 15: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

15

CSE554 Alignment Slide 29

Method 1: PCAMethod 1: PCA

• Limitations

– Centroid and axes are affected by noise

Noise

Axes are affected PCA result

CSE554 Alignment Slide 30

Method 1: PCAMethod 1: PCA

• Limitations

– Axes can be unreliable for circular objects

• Eigenvalues become similar, and eigenvectors become unstable

Rotation by a small angle PCA result

Page 16: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

16

CSE554 Alignment Slide 31

Method 2: SVDMethod 2: SVD

• Optimal alignment between corresponding points

– Assuming that for each source point, we know where the correspondingtarget point is

CSE554 Alignment Slide 32

Method 2: SVDMethod 2: SVD

• Formulating the problem

– Source points p1,…,pn with centroid location cS

– Target points q1,…,qn with centroid location cT

• qi is the corresponding point of pi

– After centroid alignment and rotation by some R, a transformed source point is located at:

– We wish to find the R that minimizes sum of pair-wise distances:

pi ' cT Rpi cS

E i1

n

qi pi '2

Page 17: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

17

CSE554 Alignment Slide 33

Method 2: SVDMethod 2: SVD

• An equivalent formulation

– Let P be a matrix whose i-th column is vector pi – cS

– Let Q be a matrix whose i-th column is vector qi – cT

– Consider the cross-covariance matrix:

– Find the orthonormal matrix R that maximizes the trace:

M PQT

TrR M

CSE554 Alignment Slide 34

Method 2: SVDMethod 2: SVD

• Solving the minimization problem

– Singular value decomposition (SVD) of an m by m matrix M:

• U,V are m by m orthonormal matrices (i.e., rotations)

• W is a diagonal m by m matrix with non-negative entries

– The orthonormal matrix (rotation) is the R that maximizes the trace

– SVD is available in Mathematica and many Java/C++ libraries

TrR M

M U W VT

R V UT

Page 18: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

18

CSE554 Alignment Slide 35

Method 2: SVDMethod 2: SVD

• SVD-based alignment: summary

– Forming the cross-covariance matrix

– Computing SVD

– The rotation matrix is

– Translate and rotate the source:

M PQT

M U W VT

R V UT

pi ' cT Rpi cS

Translate

Rotate

CSE554 Alignment Slide 36

Method 2: SVDMethod 2: SVD

• Advantage over PCA: more stable

– As long as the correspondences are correct

Page 19: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

19

CSE554 Alignment Slide 37

Method 2: SVDMethod 2: SVD

• Advantage over PCA: more stable

– As long as the correspondences are correct

CSE554 Alignment Slide 38

Method 2: SVDMethod 2: SVD

• Limitation: requires accurate correspondences

– Which are usually not available

Page 20: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

20

CSE554 Alignment Slide 39

Method 3: ICPMethod 3: ICP

• The idea

– Use PCA alignment to obtain initial guess of correspondences

– Iteratively improve the correspondences after repeated SVD

• Iterative closest point (ICP)

– 1. Transform the source by PCA-based alignment

– 2. For each transformed source point, assign the closest target point as its corresponding point. Align source and target by SVD.

• Not all target points need to be used

– 3. Repeat step (2) until a termination criteria is met.

CSE554 Alignment Slide 40

ICP AlgorithmICP Algorithm

After PCA

After 10 iterAfter 1 iter

Page 21: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

21

CSE554 Alignment Slide 41

ICP AlgorithmICP Algorithm

After PCA

After 10 iterAfter 1 iter

CSE554 Alignment Slide 42

ICP AlgorithmICP Algorithm

• Termination criteria

– A user-given maximum iteration is reached

– The improvement of fitting is small

• Root Mean Squared Distance (RMSD):

– Captures average deviation in all corresponding pairs

• Stops the iteration if the difference in RMSD before and after each iteration falls beneath a user-given threshold

i1n qi pi '2

n

Page 22: CSE 554 Lecture 5: Alignmenttaoju/cse554/lectures/lect05_Alignment.pdf5 CSE554 Alignment Slide 9 Simplification (2D) • Step 2: Collapsing an edge – Remove the edge and its vertices

22

CSE554 Alignment Slide 43

More ExamplesMore Examples

After PCA

After ICP

CSE554 Alignment Slide 44

More ExamplesMore Examples

After PCA After ICP