CSE 554 Lecture 6: Fairing and Simplification

46
CSE554 Fairing and simplification Slide 1 CSE 554 Lecture 6: Fairing and Simplification Fall 2012

description

CSE 554 Lecture 6: Fairing and Simplification. Fall 2012. Review. Iso-contours in grayscale images and volumes Piece-wise linear representations Polylines (2D) and meshes (3D) Primal and dual methods Marching Squares (2D) and Cubes (3D) Dual Contouring (2D,3D) - PowerPoint PPT Presentation

Transcript of CSE 554 Lecture 6: Fairing and Simplification

Page 1: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 1

CSE 554Lecture 6: Fairing and

Simplification

Fall 2012

Page 2: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 2

Review

• Iso-contours in grayscale images and volumes – Piece-wise linear representations

• Polylines (2D) and meshes (3D)

– Primal and dual methods

• Marching Squares (2D) and Cubes (3D)

• Dual Contouring (2D,3D)

– Acceleration using trees

• Quadtree (2D), Octree (3D)

• Interval trees

Page 3: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 3

Geometry Processing

• Fairing (smoothing)– Relocating vertices to achieve a

smoother appearance

• Simplification– Reducing vertex count

• Deformation– Relocating vertices guided by

user interaction or to fit onto a target

Page 4: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 4

• Same representation

• Different meaning:– Point: a fixed location (relative to {0,0} or {0,0,0})

– Vector: a direction and magnitude

• No location (any location is possible)

Points and Vectors

x

Y

1

2

2

x, y or x, y, z p 1, 2 p 2, 2

v 1, 2

v 1, 2

Page 5: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 5

• Subtraction– Result is a vector

• Addition with a vector– Result is a point

• Can points add?– Not yet…

Point Operations

p1

p2vp2 p1 v p2x p1x, p2y p1y

p1 v p2 p1x vx, p1y vy

Page 6: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 6

• Addition/Subtraction

– Result is a vector

• Scaling by a scalar

– Result is a vector

• Magnitude

– Result is a scalar

• A unit vector:

• To make a unit vector (normalization):

Vector Operations

v1

v2

v 1 v

2 v1

v2

v1 v2

vsv

v1 v2 v1x v2x, v1y v2ys v s vx, s vyv vx2 vy2

v 1vv

Page 7: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 7

Adding Points

• Affine combinations – Weighted addition of points where all

weights sum to 1

– Result is another point

• Same as adding scaled vectors to a point

ni1

wi pi p, where ni1

wi 1 p1

p2

p3 p4

pni1

wi pi ni1

wi pi p1 ni1

wi p1

ni1

wi vi p1

v2

v3 v4

Page 8: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 8

Adding Points

• Affine combinations: examples – Mid-point of two points

– Linear interpolation of two points

– Centroid of multiple points

p p1 p2

2

p 1 p1 p2

p ni1

pin

pp1

p2

pp1

p2

1

p1p2

p3 p4

p

Page 9: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 9

Geometry Processing

• Fairing (smoothing)– Relocating vertices to achieve a

smoother appearance

• Simplification– Reducing vertex count

Page 10: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 10

Fairing (2D)

• Reducing “bumpiness” by changing the vertex locations

Page 11: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 11

Fairing (2D)

• What is a bump?– A vertex far from the mid-point of its two neighbors

A big bump A small bump

Page 12: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 12

Fairing (2D)

• Fairing by mid-point averaging– Moving each vertex towards the mid-point of its two neighbors

• Using linear interpolation

• : some value between 0 and 1

– Controls how far p’ moves away from p

– Iterative fairing

• At each iteration, update all vertices using locations in the previous iteration

• A close to 1 will create oscillation

– Typically

p

p1 p2p1 p2

2

p'

p' 1 p p1 p2

2

1

0.5

Page 13: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 13

Fairing (2D)

• Drawback– The initial shape is shrunk!

100 iterations 200 iterations 400 iterations

Page 14: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 14

Fairing (2D)

• Non-shrinking mid-point averaging [Taubin 1995]

– Alternate between two kinds of iterations with different

• Odd iterations: (positive)

– Shrinking the shape

• Even iterations: (negative)

– : typically 0.1

– Expanding the shape

Odd 0.5

Even 1 1

Odd

Page 15: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 15

Fairing (2D)

• The initial shape is no longer shrunk– The result converges with increasing iterations

100 iterations 200 iterations 400 iterations

Page 16: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 16

Fairing (3D)

• Fairing by centroid averaging– Moving each vertex towards the centroid of its edge-adjacent neighbors

(called the 1-ring neighbors)

• Linear interpolation

– Iterative, non-shrinking fairing

• Alternate between shrinking and expanding

– Same choices of as in 2D

• Each iteration updates all vertices using locations in the previous iteration

p

p1

p2

p3

p4

p5

p' 1 p mi1

pim centroid

Page 17: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 17

Fairing (3D)

• Example: fairing iso-surface of a binary volume

Page 18: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 18

Fairing

• Implementation Tips– At each iteration, keep two copies of locations of all vertices

• Store the smoothed location of each vertex in another list separate from the current locations

– Building an adjacency table storing the neighbors of each vertex would be helpful, but not necessary

• Initialize the centroid as {0,0,0} at each vertex, and its neighbor count as 0.

• For each triangle, add the coordinates of each vertex to the centroids stored at the other two vertices and increment their neighbor count.

– The neighbor count is twice the actual # of edge neighbors

• For each vertex, divide the centroid by its neighbor count.

Page 19: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 19

• Dot product (in both 2D and 3D)– Result is a scalar

– In coordinates (simple!)

• 2D:

• 3D:

• Matrix product between a row and a column vector

More Vector Operations

v1

v2

v1 v2 v1x v2x v1y v2y v1z v2z

v1 v2 v1 v2 Cos v1 v2 v1x v2x v1y v2y

Page 20: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 20

• Uses of dot products– Angle between vectors:

• Orthogonal:

– Projected length of onto :

More Vector Operations

v1

v2

v1

v2h

v1 v2

ArcCos v1 v2v1 v2

v1 v2 0

h v1 v2v2

Page 21: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 21

• Cross product (only in 3D)– Result is another 3D vector

• Direction: Normal to the plane where both vectors lie (right-hand rule)

• Magnitude:

– In coordinates:

More Vector Operations

v1

v2

v1 v2 v1 v2 Sin v1 v2

v1y v2z v1z v2y, v1z v2x v1x v2z, v1x v2y v1y v2x v 1v 2

Page 22: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 22

More Vector Operations

• Uses of cross products– Getting the normal vector of the plane

• E.g., the normal of a triangle formed by

– Computing area of the triangle formed by

• Testing if vectors are parallel:

v1v2

v1v2

v1

v2Area v1 v22

v1 v2 0

v 1v 2

Page 23: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 23

More Vector Operations

Dot Product Cross Product

Distributive?

Commutative?

Associative?

(Sign change!)

v v1 v2 v v1 v v2

v v1 v2 v v1 v v2

v1 v2 v2 v1 v1 v2 v2 v1

v1 v2 v3 v1 v2 v3v1 v2 v3

Page 24: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 24

Geometry Processing

• Fairing (smoothing)– Relocating vertices to achieve a

smoother appearance

• Simplification– Reducing vertex count

Page 25: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 25

Simplification (2D)

• Representing the shape with fewer vertices (and edges)

200 vertices 50 vertices

Page 26: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 26

Simplification (2D)

• If I want to replace two vertices with one, where should it be?

Page 27: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 27

Simplification (2D)

• If I want to replace two vertices with one, where should it be?– Shortest distances to the supporting lines of involved edges

After replacement:

Page 28: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 28

Simplification (2D)

• Distance to a line– Line represented as a point q on the line, and a perpendicular unit vector

(the normal) n

• To get n: take a vector {x,y} along the line, n is {-y,x} followed by normalization

– Distance from any point p to the line:

• Projection of vector (p-q) onto n

– This distance has a sign

• “Above” or “under” of the line

• We will use the distance squared

p q n

q

n p

Line

Page 29: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 29

Simplification (2D)

• Closed point to multiple lines– Sum of squared distances from p to all lines (Quadratic Error Metric,

QEM)

• Input lines:

– We want to find the p with the minimum QEM

• Since QEM is a convex quadratic function of p, the minimizing p is where the derivative of QEM is zero, which is a linear equation

QEMp i1

m p qi ni 2 q1, n1, ..., qm, nm

QEMp p

0

Page 30: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 30

Simplification (2D)

• Minimizing QEM– Writing QEM in matrix form

2x2 matrix 1x2 column vector Scalar

a mi1

nix nix mi1

nix niy mi1

nix niy mi1

niy niyb

mi1

nix ni qi mi1

niy ni qi c mi1

ni qi2p px py QEMp p a pT 2 p b c [Eq. 1]

Matrix (dot) product

Row vectorMatrix transpose

QEMp i1

m p qi ni 2

Page 31: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 31

Simplification (2D)

• Minimizing QEM– Solving the zero-derivative equation:

– A linear system with 2 equations and 2 unknowns (px,py)

• Using Gaussian elimination, or matrix inversion:

QEMp p

2 a pT 2 b 0

a pT b mi1

nix nix mi1

nix niy mi1

nix niy mi1

niy niy pxpy

mi1

nix ni qi mi1

niy ni qi[Eq. 2]

pT a1 b

QEMp p a pT 2 p b c

Page 32: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 32

Simplification (2D)

• What vertices to merge first?– Pick the ones that lie on “flat” regions, or whose replacing vertex

introduces least QEM error.

Page 33: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 33

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.

Page 34: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 34

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 35: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 35

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 36: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 36

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 37: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 37

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 38: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 38

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 (Eq. 2)

• QEM (substitute p into Eq. 1)

– Used for edge selection in Step 2

• QEM coefficients (a, b, c)

– Used for fast update in Step 2Stored at the edge:

p

a, b, c, p, QEMp

Page 39: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 39

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, QEMp a1, b1, c1,

p1, QEMp1 a2, 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

Page 40: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 40

Simplification (3D)

• The algorithm is similar to 2D– Replace two edge-adjacent vertices by one vertex

• Placing new vertices closest to supporting planes of adjacent triangles

– Prioritize collapses based on QEM

Page 41: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 41

Simplification (3D)

• Distance to a plane (similar to the line case)– Plane represented as a point q on the plane, and a unit normal vector n

• For a triangle: n is the cross-product of two edge vectors

– Distance from any point p to the plane:

• Projection of vector (p-q) onto n

– This distance has a sign

• “above” or “below” the plane

• We use its square

p q n

q

n p

Page 42: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 42

Simplification (3D)

• Closest point to multiple planes– Input planes:

– QEM (same as in 2D)

• In matrix form:

– Find p that minimizes QEM:

• A linear system with 3 equations and 3 unknowns (px,py,pz)

QEMp p a pT 2 p b c

p px py pz q1, n1, ..., qm, nm

3x3 matrix

1x3 column vector

Scalar

a

mi1

nix nix mi1

nix niy mi1

nix niz mi1

niy nix mi1

niy niy mi1

niy niz mi1

niz nix mi1

niz niy mi1

niz niz

b

mi1

nix ni qi mi1

niy ni qi mi1

niz ni qic m

i1ni qi2

a pT b

QEMp i1

m p qi ni 2

Page 43: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 43

Simplification (3D)

• Step 1: Computing minimizer and QEM on an edge– Consider supporting planes of all triangles adjacent to the edge

– Compute and store at the edge:

• The minimizing location p

• QEM[p]

• QEM coefficients (a, b, c)

The supporting planes for all shaded triangles should be considered when computing the minimizer of the middle edge.

Page 44: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 44

Simplification (3D)

• Step 2: Collapsing an edge – Remove the edge with least QEM

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

• Remove “degenerate” triangles

• Remove “duplicate” edges

– For each re-connected edge:

• Increment its coefficients by that of the removed edge

• Re-compute its minimizer and QEM

Collapse

Degenerate triangles after collapse

Duplicate edges after collapse

Page 45: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 45

Simplification (3D)

• Example:

5600 vertices 500 vertices

Page 46: CSE 554 Lecture 6: Fairing and Simplification

CSE554 Fairing and simplification Slide 46

Further Readings

• Fairing:

– “A signal processing approach to fair surface design”, by G. Taubin (1995)

• No-shrinking centroid-averaging

• Google citations > 1000

• Simplification:

– “Surface simplification using quadric error metrics”, by M. Garland and P. Heckbert (1997)

• Edge-collapse simplification

• Google citations > 2000