polygonization of implicit surfaces - cse, iit bombaycs749/spr2016/lecs/09_polygonize.pdf ·...

41
Polygonization of Implicit Surfaces Siddhartha Chaudhuri http://www.cse.iitb.ac.in/~cs749 Paul Bourke

Upload: buidien

Post on 26-Aug-2019

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Polygonization of Implicit SurfacesSiddhartha Chaudhuri http://www.cse.iitb.ac.in/~cs749

Paul Bourke

Page 2: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Recall: Final step of Poisson reconstruction

Density Function Isosurface

Kazhdan, Bolitho and Hoppe

Page 3: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Medical Reconstruction

Density Function from CT Scans Reconstructed Skull Isosurface

Wikipedia, University of Utah

Page 4: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Level Set● c-Level set: The set of points where a function

takes a constant value c

Page 5: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Level Set● c-Level set: The set of points where a function

takes a constant value c● Isocontour: Level set of a 2D function● Isosurface: Level set of a 3D function

Toby Breckon

Page 6: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Isocontours

● Data: 2D structured grid of scalar values

Slides adapted from Toby Breckon

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

3

Page 7: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Isocontours

● The 5-level set:

Slides adapted from Toby Breckon

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

3

Bisects the edge,since 5 is equidistant

from 3 and 7

Splits edge asymetrically, since 5 is closer to 6 than to 2

Page 8: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Isocontours: Ambiguity

● Where is the contour?

Slides adapted from Toby Breckon

or

Triangular cell:No ambiguities

Square cell:2 ambiguous cases

“Split” green (inner) region

“Join” green (inner) region

Page 9: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Isocontours: Ambiguity

● Where is the contour?

Slides adapted from Toby Breckon

Join Split

Page 10: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Isocontours: Cell Configurations

Slides adapted from Toby Breckon

No intersections 1 vertex different 2 vertices different

Ambiguous case24 = 16 different possibilities, reducible to just 6 distinct cases after factoring out symmetries

Page 11: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Marching Squares Algorithm

● Select a starting cell● Calculate inside/outside state for each vertex● Classify cell configuration

● Determine which edges are intersected

● Find exact locations of edge intersections● Link up intersections to produce contour segment(s)● Move (or “march”) into next cell and repeat

● … until all cells have been visited

Slides adapted from Toby Breckon

Page 12: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Where is the intersection?

● Find location of contour intersection with edge by interpolating vertex values

2

43

8

5 – 4 = 1

8 – 5 = 3 The value 5 splits the edge in a 1:3 ratio

8 – 5 = 3 5 – 2 = 3

The value 5 splits the edge in a 1:1 ratio

Page 13: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Contour continuity

● Since we only look at the endpoints of the edge, the generated contour is continuous across cells

2

43

8

1 1

4

3

3

No discontinuity here!

Page 14: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Example: Marching Squares

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

Find 5-contour of function represented by its values at vertices of a

uniform grid

Slides adapted from Toby Breckon

Page 15: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 1: Classify vertices

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

Green: insideRed: outside

Slides adapted from Toby Breckon

Page 16: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 2: Classify cells

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 17: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 18: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 19: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 20: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 21: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 22: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 23: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 24: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 25: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 26: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 27: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 28: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 29: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Arbitrarily choose to split here, instead of join. We could also have gone the other way.

Page 30: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 31: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 32: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Step 3: Interpolate contour intersections

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

Page 33: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Resolving ambiguities

No intersections

Adjacent edges

Opposite edges

Ambiguous

Slides adapted from Toby Breckon

1

0 1

3

7

7

21

2

3 9

6

1

8

3 4

6

7

6

3 2

3

3

2

7

Choosing to join instead

Page 34: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

In 3D: Marching Cubes

Exactly the same algorithm, but cells are now cubes (15 distinct configurations) and output is triangles (or a polygon mix)

Wikipedia

Page 35: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

In 3D: Marching Cubes

Koen Samyn, https://www.youtube.com/watch?v=LfttaAepYJ8

(Video)

Page 36: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Marching Cubes: Estimating Normals

● We could estimate normals from the generated mesh, but the density function has more information

● Recall: The normal to the surface is the gradient of the density function

● We will estimate the gradient from the grid of values

∇ f=( ∂ f∂ x,∂ f∂ y,∂ f∂ z )

Page 37: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Normals at Cube Vertices

nx=f (i+1, j , k )−f (i−1, j , k )

2Δ x

nx=f (i , j+1,k )−f (i , j−1, k )

2Δ y

n y=f (i , j , k+1)−f (i , j , k−1)

2Δ z

Discrete approximation to the gradient at the blue cube vertex

(Better approximations are possible)

k – 1

i – 1i

i + 1

j – 1

j

j + 1

k

k + 1

(nx, n

y, n

z)

Page 38: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Normals at Mesh Vertices

Cube vertex normal(from gradient)

Cube vertex normal(from gradient)

Mesh vertex normal(interpolated from edge endpoints in ratio a:b)

a

b

Page 39: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Example: Different level sets of CT scan

Lorensen and Cline, “Marching Cubes: A High Resolution 3D Surface Reconstruction Algorithm”, SIGGRAPH '87

Bone surface Soft tissue surface

Page 40: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Example: Different level sets of CT scan

Lorensen and Cline, “Marching Cubes: A High Resolution 3D Surface Reconstruction Algorithm”, SIGGRAPH '87

Alignment with original volumetric data

Page 41: Polygonization of Implicit Surfaces - CSE, IIT Bombaycs749/spr2016/lecs/09_polygonize.pdf · Medical Reconstruction Density Function from CT Scans Reconstructed Skull Isosurface Wikipedia,

Marching Cubes: Pros and Cons● Pros:

● Local computations only, so needs very little working memory and has good cache coherence

● Works well with grid-structured input– E.g. medical scans

● Simple to implement● Cons:

● No adaptive resolution, produces lots of triangles● Telltale patterned artifacts, since cells are cubes and output

triangles are generated from a uniform grid.● No principled approach to resolve ambiguities