1.7k likes | 1.87k Views
Iso-Contouring and Level-Sets. Roger Crawfis. Contributors: Roger Crawfis, Han-Wei Shen, Raghu Machiraju, Torsten Moeller, Huang Zhiyong, Fan Ding, and Charles Dyer. Iso-contour/surface Extractions. 3D Iso-surface. 2D Iso-contour. Contouring - The Problem.
E N D
Iso-Contouring and Level-Sets Roger Crawfis Contributors: Roger Crawfis, Han-Wei Shen, Raghu Machiraju, Torsten Moeller, Huang Zhiyong, Fan Ding, and Charles Dyer
Iso-contour/surface Extractions 3D Iso-surface 2D Iso-contour R. Crawfis, Ohio State Univ.
Contouring - The Problem • Extracting an iso- surface from an implicit function, that is, • Extracting a surface from volume data (discrete implicit function), f (x ,y ,z ) = T R. Crawfis, Ohio State Univ.
More Formally • A scalar visualization technique that creates curves (in 2D) or surfaces (in 3D) representing a constant scalar value across a scalar field. • Contour lines are called isovalue lines or isolines. • Contour surfaces are called isovalue surfaces or isosurfaces R. Crawfis, Ohio State Univ.
Contouring a 2D structured grid with contour line value = 5 1. Using interpolation to generate points along edges with the constant value 2. Connect these points into contours using a few different approaches. One of the approaches: . Detects edge intersection . Tracks this contour as it moves across cell boundary . Repeat for all contours 0 1 1 3 2 1 3 6 6 3 3 7 9 7 3 2 7 8 6 2 1 2 3 4 3 R. Crawfis, Ohio State Univ.
2D Contouring – Not so easy • Annotations • Smooth Curves Topographic Map of Jerusalem (Contour interval 10 meters) North is at the top of the map. The Mount of Olives is on the far right, Mount Zion on the left. Mount Moriah rises as a long ridge at the south end of the City of David and continues on past the present Temple Mount, and reaches its highest point outside the Northern walls of the Old City, at the top of the map. http://www.skullandcrossbones.org/articles/solomontemple/solomontemple2.htm R. Crawfis, Ohio State Univ.
Quantitative and Qualitative • In this figure, we can actually read off any value to about three significant digits. • Hard and tedious problem to determine where to place labels. • Usually done as vector graphics, rather than raster graphics for precision. http://omnimap.com/catalog/cats/fish/fish-contour.htm R. Crawfis, Ohio State Univ.
Divide and Conquer • Partition space into rectangular sub-regions. R. Crawfis, Ohio State Univ.
Dividing Cubes/Squares 0 1 1 3 2 • Generates Points and renders them • Rendering points is faster than polygons • Principle - Divide a square until contour passes thru the cell 1 3 6 6 3 3 7 9 7 3 2 7 8 6 2 1 2 3 4 3 Iso-value=5 R. Crawfis, Ohio State Univ.
Dividing Cubes 1. Create a cell 2. Determine if the cell is a surface cell 3. Subdivide surface cells to image resolution 4. Determine intensity or color of refined cell 5. Output a point for each remaining surface cell R. Crawfis, Ohio State Univ.
Step 3: Subdivide • Subdivide each cell such that the resolution is higher than the image resolution. For example, when a 1282 gridded field is rendered to a 5122 image, cells containing the contour will be divided to 4x4 smaller squares. classify subdivide output points R. Crawfis, Ohio State Univ.
Surface Tracking 0 1 1 3 2 • Given function S(t,x,y,z) that returns 1 if (x,y,z) is on the surface t and 0 otherwise • Needed: a seed cell p that is on the surface. 1 3 6 6 3 3 7 9 7 3 2 7 8 6 2 1 2 3 4 3 Seed cell Iso-value=5 R. Crawfis, Ohio State Univ.
Surface Tracking Let Q be a queue of cells. Push p onto Q Flag p as “visited” While Q is not empty do Pop q from Q and output it. For each cell v in the neighborhood of q do If S(t, v) = 1 then If v was not visited then Push v onto Q Flag it as “visited” end {while} R. Crawfis, Ohio State Univ.
Tracking and Smooth Curves • Recall that the gradient to a scalar field is normal to the isolines. • Therefore, the curve will be towards the direction perpendicular to the gradient. • Can also use the gradient to calculate tangents for each point on the curve to generate smooth curves. R. Crawfis, Ohio State Univ.
Restricted Topological Cases A closed curve can not be contained in the cell. The curve can only enter and exit the cell once per edge. Filled circle vertices indicate scalar value is above the contour value Unfilled ones which scalar values are below the contour values R. Crawfis, Ohio State Univ.
Not Allowed R. Crawfis, Ohio State Univ.
Linear Topology • The restricted set is topologically equivalent to linear segments. • Topologically equivalent if we restrict the edge intersections to lie at the mid-points of each edge. R. Crawfis, Ohio State Univ.
Using Symmetry to Reduce to 5 Contour ambiguity: either solid or dash lines look OK R. Crawfis, Ohio State Univ.
p5 p4 2D Iso-contour (0) Remember bi-linear interpolation p2 p3 To know the value of P, we can first compute p4 and P5 and then linearly interpolate P P =? p1 p0 R. Crawfis, Ohio State Univ.
p2 p3 p1 p0 2D Iso-contour (1) Consider a simple case: one cell data set The problem of extracting an iso-contour is an inverse of value interpolation. That is: Given f(p0)=v0, f(p1)=v1, f(p2)=v2, f(p3)=v3 Find the point(s) P within the cell that have values F(p) = C R. Crawfis, Ohio State Univ.
p2 p3 p1 p0 2D Iso-contour (2) We can solve the problem based on linear interpolation (1) Identify edges that contain points P that have value f(P) = C (2) Calculate the positions of P (3) Connect the points with lines R. Crawfis, Ohio State Univ.
If v1 < C < v2 then the edge contains such a point v1 v2 2D Iso-contouring – Step 1 (1) Identify edges that contain points P that have value f(P) = C R. Crawfis, Ohio State Univ.
Use linear interpolation: P = P1 + (C-v1)/(v2-v1) * (P2 – P1) p1 P p2 v1 v2 C 2D Iso-contouring – Step 2 (2) Calculate the position of P R. Crawfis, Ohio State Univ.
Connect the points with line(s) p2 p3 p1 p0 2D Iso-contouring – Step 3 Based on the principle of linear variation, all the points on the line have values equal C R. Crawfis, Ohio State Univ.
p2 p2 p3 p3 p1 p1 p0 p0 - - + inside cell outside cell Inside or Outside? Just a naming convention • If a value is smaller than the iso-value, we call it “Outside” • If a value is greater than the iso-value, we call it “Inside” R. Crawfis, Ohio State Univ.
Contouring in 3D • Treat volume as a set of 2D slices • Apply 2D Contouring algorithm on each slice. • Or given as a set of hand-drawn contours • Stitch the slices together. R. Crawfis, Ohio State Univ.
? ? Contour Stitching • Problem: Given: 2 two-dimensional closed curves Curve #1 has m points Curve #2 has n points Which point(s) does vertex i on curve one correspond to on curve two? i R. Crawfis, Ohio State Univ.
A Solution • Fuchs, et. al. • Optimization problem • 1 stitch consists of: • 2 spans between curves • 1 contour segment • Triangles of {Pi,Qj,Pi+1} or {Qj+1,Pi,Qj} • Consistent normal directions Qj Pi Pi+1 R. Crawfis, Ohio State Univ.
Fuchs, et. al. • Left span • PiQj => go up • Right span (either) • Pi+1Qj => go down • PiQj+1 => go down R. Crawfis, Ohio State Univ.
Fuchs, et. al. • Constraints • Each contour segment is used once and only once. • If a span appears as a left span, then it must also appear as a right span. • If a span appears as a right span, then it must also appear as a left span. R. Crawfis, Ohio State Univ.
Fuchs, et. al. • This produces an acceptable surface (from a topological point of view) • No holes • We would like an optimal one in some sense. R. Crawfis, Ohio State Univ.
Qj+1 Qj Pi Pi+1 Fuchs et. al. • Graph problem • Vertices Vij = span between Pi and Qj • Edges are constructed from a left span to a right span. • Only two valid right spans for a left span. R. Crawfis, Ohio State Univ.
Fuchs, et. al. • Organize these edges as a grid or matrix. Q j i P QjPiQj+1 PiQjPi+1 R. Crawfis, Ohio State Univ.
Fuchs, et. al. • Acceptable graphs • Exactly one vertical arc between Pi and Pi+1 • Exactly one horiz. arc between Qj and Qj+1 • Either • indegree(Vij) = outdegree(Vij) =0 • both > 0 • (if a right, also has to be a left) R. Crawfis, Ohio State Univ.
Fuchs, et. al. • Claim: • An acceptable graph, S, is weakly connected. • Lemma 2 • Only 0 or 1 vertex of S has an indegree = 2. • E.g., Two cones touching in the center. • All other vertices have indegree=1 • (recall indegree = outdegree) R. Crawfis, Ohio State Univ.
Fuchs, et. al. • Thereom 1: S is an acceptable surface if and only if: • S has one and only one horizontal arc between adjacent columns. • S has one and only one vertical arc between adjacent rows. • S is Eulerian (closed walk with every arc only once). R. Crawfis, Ohio State Univ.
Fuchs, et. al. • Number of arcs is thus m+n. • Many possible solutions still!!! • Associate costs with each edge • Area of resulting triangle • Aspect ratio of resulting triangle R. Crawfis, Ohio State Univ.
Fuchs, et. al. • Note that Vi0 is in S for some i. • Note that V0j is in S for some j. • With the weights (costs), we can compute the minimum path from a starting node Vi0. • Since we do not know which Vi0, we compute the paths for all of them and take the minimum. • Some cost saving are achievable. R. Crawfis, Ohio State Univ.
Marching Cubes • Predominant method used today. • Efficient and simple • It was independently reported by Wyvill and McPeeters in 1986, Lorenson and Cline in 1987 R. Crawfis, Ohio State Univ.
Marching Cubes • Treat each cube individual • No 2D contour curves • Allow intersections only on the edges or at vertices. • Pre-calculate all of the necessary information to construct a surface. R. Crawfis, Ohio State Univ.
+ + - + + + + + Marching Cubes • Consider a single cube • All vertices above the contour threshold • All vertices below • Mixed above and below R. Crawfis, Ohio State Univ.
+ + - + + + + + Marching Cubes • Binary label each node => (above/below) • Examine all possible cases of above or below for each vertex. • 8 vertices implies 256 possible cases. R. Crawfis, Ohio State Univ.
Now we have 8 vertices So it is: 2 = 256 8 How many unique topological cases? How many cases? R. Crawfis, Ohio State Univ.
_ _ + + _ + + _ _ _ + + _ + _ + Case Reduction Value Symmetry R. Crawfis, Ohio State Univ.
_ _ _ _ _ + _ + _ _ _ _ _ _ + + Case Reduction Rotation Symmetry R. Crawfis, Ohio State Univ.
_ + _ + _ + _ + _ _ _ _ + + + + Case Reduction Mirror Symmetry By inspection, we can reduce 256 15 R. Crawfis, Ohio State Univ.
Marching Cube - Summary • Create a cube • Classify each voxel • Build an index • Lookup edge list • Interpolate triangle vertices • Calculate and interpolate normals R. Crawfis, Ohio State Univ.
Step 1: Create a Cube • Consider a cube defined by eight data values: four from slice K, and four from slice K+ 1 R. Crawfis, Ohio State Univ.
Step 2: Classify Each Voxel • Binary classification of each vertex of the cube as to whether it lies • outside the surface (voxel value < isosurface value) • or inside the surface (voxel value <= isosurface value). R. Crawfis, Ohio State Univ.
Step 3: Build an Index • Use the binary labeling of each voxel to create an 8-bit index: • 8 vertices - 256 cases • Requires a canonical ordering of the cube. R. Crawfis, Ohio State Univ.