polygonization of implicit surfaces - cse, iit bombaycs749/spr2016/lecs/09_polygonize.pdf ·...
TRANSCRIPT
Polygonization of Implicit SurfacesSiddhartha Chaudhuri http://www.cse.iitb.ac.in/~cs749
Paul Bourke
Recall: Final step of Poisson reconstruction
Density Function Isosurface
Kazhdan, Bolitho and Hoppe
Medical Reconstruction
Density Function from CT Scans Reconstructed Skull Isosurface
Wikipedia, University of Utah
Level Set● c-Level set: The set of points where a function
takes a constant value c
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
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
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
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
Isocontours: Ambiguity
● Where is the contour?
Slides adapted from Toby Breckon
Join Split
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
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
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
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!
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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
In 3D: Marching Cubes
Koen Samyn, https://www.youtube.com/watch?v=LfttaAepYJ8
(Video)
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 )
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)
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
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
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
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