Diploma thesis

Framework for Levelset Methods

Christian Sigg

Advisors: Prof Dr.-Ing. Markus Gross, ETH Zurich Dr.-Ing. Matthias Teschner, ETH Zurich Steven Assa, Schlumberger Cambridge Research

Christian Sigg Diploma thesis

Framework for Levelset Methods

Introduction

The goal of this thesis is to investigate the feasibility of implicit technology within geo- metrical earth modeling research. Implicit surfaces are utilized in many problem domains, such as fluid mechanics, material sciences and image processing. Motivated by research carried out in these areas, this thesis is intended to survey the potential application of implicit surfaces in geoscience.

Goals

The project is aimed at the development, implementation, and testing of computational algo- rithms for levelset representations of surfaces. It is planned to apply these methods for approxi- mating implicit surfaces to 3D point clouds. The Diploma thesis is defined by the following tasks:

1. State-of-the-art publications in Levelset Methods are reviewed and analyzed with special emphasis on surface modeling and editing. 2. A computational framework for 3D levelsets is designed and developed. Due to the appli- cation it is intended to restrict the framework to narrow bands on Cartesian grids. 3. The implemented framework is tested. Therefore, the implementation is utilized for surface data interpolation of 3D point sets. 4. Performance aspects and the robustness of levelset approaches with respect to surface data interpolation are studied. 5. Documentation for implemented software is provided.

Remarks

Results of this thesis will be summarized in a written report and presented in a talk. The Diplo- ma thesis is co-supervised by Prof Dr.-Ing. Markus Gross, ETH Zurich, Dr.-Ing. Matthias Te- schner, ETH Zurich, and Steven Assa, Schlumberger Cambridge Research.

Start: April 30th, 2002 End: August 30th, 2002

Contents

1 Introduction ...... 7 1.1 Levelset Methods ...... 7 1.2 History ...... 7 1.3 Aims ...... 8 1.4 Contributions ...... 8 1.5 Outline ...... 9 2 Levelset Methods ...... 11 2.1 Moving Interfaces ...... 11 2.2 Theory of Surface Evolution ...... 14 2.2.1 Hyperbolic Conservations Laws ...... 14 2.2.2 Riemann Problem ...... 15 2.2.3 Levelset Formulation ...... 17 2.2.4 Finite Volume Schemes ...... 18 2.3 Signed Field ...... 21 2.3.1 Eikonal Equation ...... 21 2.3.2 Sweeping Method ...... 21 2.3.3 Fast Marching Method ...... 22 2.3.4 Closest Point Transform ...... 23 2.3.5 Preservation of Distance Field ...... 24 2.4 Narrow Band ...... 26 3 Applications ...... 29 3.1 Geometry ...... 29 3.2 Grid Generation ...... 30 3.3 Noise Removal in Images ...... 31 3.4 Shape Detection ...... 34 3.5 Computational Geometry and CAD ...... 34 3.6 Path Planning ...... 36 3.7 Multiphase Flows ...... 37 4 Framework ...... 39 4.1 Overview ...... 39 4.2 Templates in C++ ...... 40 4.3 Data Structure ...... 42 4.4 Numerical Schemes ...... 43 4.5 Closest Point Transform ...... 45 4.6 Marching Cubes ...... 46 4.7 Equation Parser ...... 46 4.8 Configuration File ...... 47 4.9 Visualization ...... 47 5 Results ...... 51 5.1 Applications ...... 51 5.1.1 Offset Surfaces ...... 51 5.1.2 Fairing ...... 51 5.1.3 Surface Reconstruction ...... 52 5.1.4 Logical Operators ...... 53

5 Contents 6

5.2 Performance Test ...... 54 5.3 Open Issues ...... 55 5.4 Future Work ...... 56 A Code Usage ...... 61 A.1 Development Environment ...... 61 A.2 Libraries ...... 61 A.3 Configuration File ...... 62 A.4 Triangular Mesh Files ...... 62 A.5 Classes ...... 63 B References ...... 65 1

1Introduction

This chapter begins with a brief introduction to Levelset Methods by explaining the problem setup and the basic idea of how to address the problem. In section 1.2, a presentation of the his- tory of the Levelset Method and its extensions resulting in computational affordable algorithms is given. Then, the aims and contributions of this diploma thesis are summarized. This chapter concludes with a short outline of this report.

1.1 Levelset Methods Levelset Methods describe the evolution of hyper surfaces in time. Instead of looking at boundary motion from a natural geometric Lagrangian perspective, the theory of Levelset Methods utilizes the Eulerian partial differential equation (PDE) viewpoint. This results in a powerful numerical technique for analyzing and computing interfaces that can develop sharp corners and undergo topological changes as they evolve. By using an implicit representation of a surface, its evolution can be written as a PDE in the used to define the surface. The stability of the numerical solution to this PDE is guar- anteed by the theory of hyperbolic conservation laws.

1.2 History J.A. Sethian used the Levelset Methods in his Ph.D. thesis [29] to analyze the propagation of flames. Although the simplicity of Levelset Methods is very appealing, the computer power for solving PDEs in three dimensions within an acceptable period of time was not available at the beginning. But exponential growing computer power and important optimizations have made the Levelset Method a very popular technique to simulate evolving surfaces in a wide range of scientific applications. If one is only interested in a specific front, the full matrix approach is not efficient because all contours in the computational space are being evolved by the PDE. Because the evolution of a whole family of contours is simulated, extra computational cost is incurred if only one surface is of interest. In 1993, the narrow band method was introduced by Chopp [1]. The idea is to restrict the computations to the vicinity encompassing the front of interest to improve effi- ciency. For N samples in the whole computational domain, the number of samples within a cer- tain maximum distance to the zero levelset is O(N2/3), but the samples are sufficient to uniquely describe the front. The computational cost of one time step is reduced because a significantly

7 8 1. INTRODUCTION smaller amount of points have to be updated. In fact, the computational complexity for one time step is linear in the resolution of the explicit surface because the narrow band has a constant width of samples on each side of the interface. Also the Courant-Friedrichs-Levy (CFL) condi- tion, which limits the time step to guarantee convergence, has to be enforced for points only within the narrow band. In general, this results in larger time steps. The samples that belong to the narrow band are not exchanged until the zero level moves near the edge of the narrow band. Then, the calculation is stopped and a new band is built with the zero level at its center. The Levelset Method uses iteration for surface evolution. However, if the front only moves in one direction, the numerical scheme used can efficiently build the solution outward from the boundary data thereby avoiding iteration. By taking algorithmic approaches from initial value problems and applying them to the boundary value problem, the Fast Marching Method is pro- duced [31]. The Fast Marching Method is particularly useful for solving the Eikonal equation. By solving the Eikonal equation, an implicit representation of the initial condition, given as an explicit surface, is built. To solve the Eikonal equation with the Fast Marching Method, a front is moved outward from the initial surface at unit speed. The time of first arrival of the moving front at the sampling point is equal to the distance between the sampling point and the front at time zero. Each sample is only processed when the front moves through the point in contrast to an iterative algorithm in which samples are processed repeatedly until the value converges.

1.3 Aims

The goal of this master thesis is to implement a general framework for Levelset Methods. To achieve this goal, state-of-the-art publications in Levelset Methods are investigated, different approaches for this technique are analyzed with special emphasis on surface modeling and edit- ing, and finally an implementation of the levelset approach is written to study performance aspects and robustness of implicit surface technology for surface data interpolation.

1.4 Contributions

A framework of the Levelset Method was implemented to test the feasibility of different approaches, applications and optimizations. The problem was restricted to three-dimensional uniform grids. To speed up the computations, the Narrow Band Method was chosen. To save memory, only grid points that lay in the narrow band are stored. To allow fast access to this sparse matrix of sample values, an octree was implemented. Because surfaces in the field of computer graphics are most often described as triangulated meshes, an import and export routine was written. For the transfer between the explicit descrip- tion of surfaces by triangular meshes and the implicit description by a scalar function, two dif- ferent algorithms are used, the Marching Cubes algorithm and the Closest Point Transform. The latter is taken from an external library. To solve the PDE that describes the evolution of the surface, a stable first order finite volume scheme was implemented. Because the framework should serve as test environment for a wide range of formulas defining the velocity of a point on the surface, an equation parser is used to give the user full freedom in the design of these speed functions. To further reduce frequent recompilation of the code, a configuration file class was written and many options of the pro- gram can be stored in a simple text file that is loaded on program execution. For the verification of the solutions calculated, the distance field and extracted isosurfaces are visualized using OpenGL. All parameters of the surface evolution and the visualization are controllable with a graphical user interface. 1.5 OUTLINE 9

To test the possibilities of the Levelset Method and the implemented framework, some exam- ples of evolving interfaces with different speed functions were simulated. This includes offset- ting, fairing, surface reconstruction and logical operators of volumes.

1.5 Outline After the introduction given in this chapter, the theory of the Levelset Methods is derived. To give an overview of alternatives, chapter 2 starts by presenting some techniques to handle moving interfaces from different fields of computational science. Then, the theory of hyperbolic conservation laws is reviewed and transferred to Hamilton-Jacobi equations. This theory builds the foundation for numeric schemes used in Levelset Methods. The chapter continues with opti- mization methods for the levelset approach. The two most important specialized versions of Levelset Methods are presented: the solution of the Eikonal equation to calculate a distance field and the narrow band approach to reduce the cost of the overall computation. In chapter 3, applications from a wide range of fields are presented. First, the influence of curvature flow on topology and volume preservation is studied. The well-defined behavior of surfaces evolving under curvature flow is then used for generating computational grids. Next, the Levelset Method is extended to move an entire family of contours. This is shown in the example of image enhancement. Another application from the field of Computer Vision that can be done with levelsets is shape detection as shown in section 3.4. The chapter then progresses to a description of an algorithm for constructive solid geometry (CSG) operations from com- puter aided design. Section 3.6 discusses usage of Levelset Methods for path planning. Finally, the chapter concludes with simulations of multiphase fluid dynamics where the phase bound- aries are tracked with a hybrid combination of Levelset Methods and particles. Chapter 4 presents the different parts of the framework implementation. After an Overview of the different components of the code, a short introduction to the concept of templates in C++ and the standard template library is given. In section 4.3, the data structure used to store the sparse sampled function is expounded. The next section describes the numerical implementa- tion to achieve a stable discretization of the PDE that defines the surface evolution. A library is used to initially set the implicit surface representation to a distance field. The algorithm employed by the library is outlined in section 4.5 along with suggestions for an improved ver- sion, which uses graphics hardware. The well-known Marching Cubes algorithm is reviewed in the following section and adapted to the environment of the framework. The chapter ends with a description of other tools used in the framework, including an equation parser, a configuration file reader and libraries for implementing the graphical user interface. Chapter five starts with examples showing the possibilities of the Levelset Method and the framework implemented. Pictures from offset surfaces, surface fairing, surface reconstruction and from logical operations between two regions are presented. In section 5.2, some perfor- mance examples indicate the numerical expensive parts of the computation. In the next section, unresolved problems in the implemented framework as well as open issues in the theory of Lev- elset Methods are discussed. The chapter ends with possible future work in the field of Levelset Methods. 10 1. INTRODUCTION 2

2Levelset Methods

In this chapter, the theory for Levelset Methods is derived. In the first section, the description of surfaces changing their position in time is given. After reviewing the Lagrangian technique for performing this movement, the levelset approach is introduced. Also a hybrid approach is briefly described. In section 2.2, the mathematical theory behind the Levelset Methods is expounded. The evolution of the surface in levelset methodology is described by a partial dif- ferential equation (PDE). To explain the numerical schemes for solving this PDE, hyperbolic conservation laws, weak solutions and viscosity solutions as well as entropy conditions are introduced. Levelset Methods use an implicit representation of the front. Distance fields holding the Eikonal equation are well suited for this representation. In section 2.3, three common tech- niques for computing a distance field are presented: the sweeping method, the Fast Marching Method and the Closest Point Transform. To preserve the distance field during the surface evo- lution, constraints have to be imposed on the speed function. In the last section of this chapter the narrow band method is introduced, which speeds up the computations by an order of magni- tude.

2.1 Moving Interfaces

Consider a boundary separating one region from another. This interface of co dimension one, a curve in two dimensions and a surface in three dimensions, is moving in a direction normal to itself with a speed function ββ . The function changes its scalar value on the surface depending on local or global measurements. One wants to track the motion of this interface in time. The motion of the interface in its tangential direction is not changing the shape of the interface, only its parameterization. Because the surface evolution should be independent of the parameteriza- tion, tangential motions can be ignored. When the interface is given as a triangular mesh, one can move it by changing the position of the vertices. In many applications, the speed function depends on some measurement of the curvature of the surface, which is a function of the derivative of the surface normal. However, the normal is not continuous across edges and therefore the derivative is undefined. A remedy to this problem is to instead choose the curvature of a spline surface interpolating the vertices of the mesh. Unfortunately, triangular meshes are not suitable for surfaces that undergo large topological changes during evolution. The preservation of a consistent triangulation during evo- lution would involve complicated CSG tasks in every timeframe.

11 12 2. LEVELSET METHODS

Figure 2.1: An interface separating two regions. The task is to move the interface with a variable speed in normal direction n.

Consider two regions merging during one time step. The boundary triangles intersect with each other and are laying inside the merged region. Therefore, they no longer form a valid boundary description. The CSG task must then be applied to delete all pieces of the mesh inside the merged region. This involves the calculation of many triangle intersections, which is time consuming.

Particle methods avoid a triangulation of the interface and became popular to handle moving interfaces, for example in fluid dynamics. Particles represent samples of the surface but in com- parison to triangulated meshes, there is no fixed neighborhood defined between particles. They can move independently hence surface mergers or splits become relatively simple operations because no triangles have to be checked for intersection. Unfortunately, the interface defined by the particles often has to be resampled because the particle density can change dramatically during evolution. If the interface is not resampled often, the resolution of the particles becomes significantly unbalanced. In comparison to the triangulated method, the particle method makes it even harder to find a natural definition of curvature and perform CSG operations. Particles are therefore seldom used in geometric applications.

Figure 2.2: An interface described by a set of particles. No neighborhood is de- fined between the particles and the normal has to be calculated with some heuristic. Each particle independently moves in its normal di- rection as the interface evolves.

Another common technique in computational fluid dynamics is the volume-of-fluid tech- nique. The initial interface geometry is used to compute volume fractions in each computational cell. The volume fraction is the relative amount of volume that is truncated by the interface in 2.1 MOVING INTERFACES 13 each cell. The exact interface information is then discarded, thereby loosing a unique interface topology. During the evolution, the position of the interface is reconstructed from local volume fraction data. Piecewise linear surfaces calculated with operator splits lead to much better results than piecewise constant reconstructions, but at a significant higher computational cost. Overall, this technique is preferred when conservation of mass is a central criterion of the simu- lation but the resolution and topology of the surface is less crucial.

Figure 2.3: Volume-of-fluid method. Volume fractions are stored for each cell. The position and the topology of the interface are discarded after the fractions are computed, thereby loosing a unique interface topology.

The Levelset Method uses an implicit description of the interface. Instead of storing infor- mation about the position of the interface, a scalar function in full space dimension defines the interface: the interface is located at the set of points where the function vanishes. This set is called the kernel or zero level of the function. In order to evolve the interface, the kernel is moved in space by changing the function values. This change is formulated as a PDE in time. To generate a numerical scheme in order to solve the PDE, an interpolation method is chosen and the function is sampled on a uniform grid. Although there are many choices for the function defining the interface, often the signed distance function to the surface is preferred. Hence the distance to the closest point on the interface is stored at every grid point in the computational domain. The sign of the distance is set to negative on one side of the interface and positive on the other. The zero level of the function interpolating these distance values represents the inter- face. During the evolution, the position of the interface does not have to be known because the distance field contains enough information to describe the evolution. Because no surface is involved in the calculation, no intersections have to be computed and topological changes are unimpeded. After the calculation has converged, the interface can be extracted to get an explicit solution to the problem. In summary, the main benefit of Levelset Methods is that calculation is not disrupted by surface splits and mergers because explicit tracking of the interface is avo- ided. A hybrid technique was introduced in [6], combining particle methods and the levelset approach. This hybrid method addresses the common problem of mass conservation in Levelset Methods. The region bounded by the interface shrinks when it is passively advected in a flow field. To avoid this shrinkage, particles are randomly placed, before each time step, close to each side of the interface represented by the levelset function. The interface and the particles are independently advanced according to the underlaying flow. At some regions, marker particles initially seeded on one side of the interface are detected on the opposite side of the interface after one time step. This indicates that the local resolution of the levelset resulted in lack of precision and the interface is corrected with information from these escaped particles. The feasibility of this method for real world multiphase flows is shown in [7]. 14 2. LEVELSET METHODS

Figure 2.4: The Levelset Method uses an implicit description of the interface. The interface is located at the set of points where the levelset function vanishes. The levelset function is defined in full space di- mension and its values are sampled on a regular grid.

2.2 Theory of Surface Evolution

In this section, the theory of moving interfaces and the levelset approach will be developed. An introduction to hyperbolic conservation laws is given first because they have similar charac- teristics to the PDE for evolving levelsets. A few common schemes for the numerical solution of hyperbolic conservation laws are presented, which have proven to succeed in Levelset Methods.

2.2.1 Hyperbolic Conservations Laws The evolution of an interface is formulated as PDE. In contrast to the Eulerian approach where the position of the interface is explicitly tracked, the Lagrangian approach used in Level- set Methods describes the interface as an isosurface of a function in full-dimensional space. The evolution of the interface is then incorporated into a PDE of this function. Because the solution is not smooth, a stable numerical scheme can only be found if special care is taken when discre- tizing the problem. Three important types of PDEs exist: parabolic, hyperbolic and elliptic. For each class, dif- ferent approaches are used to derive a stable numerical solution scheme. The equation descri- bing the surface evolution in Levelset Methods is closely related to the class of nonlinear hyperbolic conservation laws. To derive a stable numerical scheme for the levelset equation, the theory of hyperbolic conservation laws is a good starting point. Hyperbolic conservation laws are PDEs of the form

∂uxt(), d ------+0∇β⋅ ()uxt(), = in R ×R+ (2.1) ∂t

Together with initial condition

ux(), 0 = u0()x (2.2)

they describe the change of a function in time. Here, t denotes the time variable, while x des- cribes the spatial variation in d space dimensions. The unknown function u can be a vector but in Levelset Methods, we only have to deal with scalar problems. Assuming that u is defined in 2.2 THEORY OF SURFACE EVOLUTION 15 one space dimension and sufficiently regular to allow the exchange of derivative and integral, the formal integration of (2.1) between two points x1 and x2 gives

x2 d ----- uxt(), dx = β()βux(), t – ()ux(), t . (2.3) dt∫ 1 2 x1 This equation expresses conservation of the quantity measured by u in the sense that the rate of change in the amount of u between x1 and x2 is given by the difference in β()u evaluated at these points. Therefore, β()u is often referred to as flux density or flux function. Hyperbolic conservation laws are for example used to describe compressible flows and are usually strongly nonlinear. In comparison to linear problems, nonlinear conservation laws have the following characteristics:

• Even if the initial function u0(x) is smooth, the solution u(x, t) of (2.1) develops shocks after a finite time and looses its regularity. • Because derivatives are undefined at discontinuities, classical solutions of nonlinear con- servation laws do not exist and one has to consider generalized or weak solutions. • Weak solutions are not unique when shocks appear in the solution. Uniqueness can only be guaranteed with a selection principle. Additional information must be introduced for selecting exactly one weak solution. The entropy condition is such a selection principle. Instead of (2.1), one often has to deal with a viscous variant of the conservation law

ε ∂u ε ε ------+ ∇β⋅ ()u = ε∆u (2.4) ∂t

where the viscosity ε is small. Numeric methods that keep their accuracy when ε → 0 are called robust and are often derived from discretized versions of (2.1). However small the visco- sity term in (2.4) is, the viscous variant of the hyperbolic conservation law always produces smooth solutions. It is therefore not necessary to use a weak formulation of the problem and the solution is unique.

2.2.2 Riemann Problem Because the solutions of hyperbolic conservation laws contain discontinuities, the equation (2.1) has to be reformulated so that the spatial derivative in u does not need to be defined every- where. To describe this reformulation, a simple example of a non-linear hyperbolic conserva- tion law is introduced: the scalar Burger Equation defined as

∂u ∂u ----- +0u----- = in R×R+. (2.5) ∂t ∂x The simplicity of this equation lays in the fact that it can be split into two trivial ordinary differential equations: Characteristics x(t) are solutions of · x()t == β'()uxt()(), t uxt()(), t (2.6) The solution u of (2.5) is constant along these rays because

d · uxt()(), t ===ut + uxx()t ut +0βx (2.7) dt 16 2. LEVELSET METHODS

· and therefore also x()t is constant and all characteristics are lines. Because we are interested in shocks, an initial condition that contains one discontinuity and is constant everywhere else is used. This is the Riemann Problem

uL x < 0 u0()x =  (2.8) uR x > 0

There are two cases:

• uL > uR . The derivative of u is undefined at the discontinuity in zero and there is no unique solution to the problem. For the viscous variant of the conservation law (2.4), the solution is unique and smooth for all ε > 0, t > 0 . The viscosity method now chooses

ε uxt(), = lim u ()xt, (2.9) ε → 0

as solution of (2.1). The limit is called viscosity solution and is unique but discontinuous, i.e. contains shocks. Therefore, it is not a solution to the initial problem. One is forced to consider weak solutions instead, satisfying

∫u0()ϕx ()x, 0 + ∫ uxt()ϕ, t()βxt, + ()ϕuxt(), x()xt, dtdx = 0 . (2.10)

R R+ The idea of a weak solution of a PDE is to integrate the equation against a smooth test function and then integrate by parts to make the derivatives fall on the test function. In contrast to the initial formulation, solutions that hold this new, generalized equation do not need to be differentiable and are called weak solutions.

Figure 2.5: The solution to the Riemann problem where uL > uR and uL > 0 forms a moving shock.

• uL < uR . In this case the characteristics are diverging and the weak solution is not unique. There is the continuous solution called the rarefaction fan and also the simple discontinuous solution (see Fig. 2.6). The solution is no longer unique because the pro- blem was relaxed for allowing waek solutions. From the two solutions, the continuous one is preferred because information may vanish into a shock but may not be created at a shock. The discontinuous solution is not prefer- red because it can transform into a rarefaction fan at any time. The exact time of such a transition is additional information stored in a solution. On the other hand, a rarefaction fan never transforms into a discontinuous solution and a unique solution is defined by the initial condition. The discontinuous solution does not satisfy the entropy condition 2.2 THEORY OF SURFACE EVOLUTION 17

Figure 2.6: Two solutions to the Riemann problem where uL < uR: The rarefac- tion fan (left) and the discontinuous solution (right). The latter solu- tion violates the entropy condition because it could transform to a rarefaction fan at any time.

∫ η()ϕu0()x ()x, 0 + ∫ η()ϕuxt(), t()Φβxt, + ()ϕ()uxt(), x()xt, dtdx = 0 (2.11)

R R+ for all Φ, convex η with Φ' = η'β'

and by adding this condition to the problem description, the solution contains only rarefac- tion fans and is unique. Therefore, the additional information is now stored in the problem des- cription and not in the solution. In the above section, the theory of solutions to hyperbolic PDEs containing shocks was given. In summary, the PDE has to be transformed to its integral form in order to allow weak solutions because the original PDE contains derivatives, which are not defined for solutions containing shocks. Although there is always a solution to the weak formulation of the PDE, its uniqueness is not guaranteed. The entropy condition is added to the problem to select exactly one of all possible weak solutions.

2.2.3 Levelset Formulation The same principle is applied when a numerical scheme for the Levelset Method is construc- ted. The surface evolution in levelset methodology is formulated as a PDE and the solution can contain shocks. A discretization is needed to numerically simulate the continuous problem. For a numerically stable scheme, the concepts of weak solutions and entropy conditions have to be incorporated into the discretization.

Levelset Methods address the problem of moving an initial closed surface S0 in the normal direction with a speed function ββ . The function changes its scalar value on the surface depen- ding on local or global measurements. One wants to track the motion of this interface in time. The motion of the interface in its tangential direction is not changing the shape of the interface, only its parameterization. Because the surface evolution should be independent of the parame- terization, tangential motions can be ignored. Let S(p, t) be this family of closed surfaces, where p parameterizes the surface and t is the time variable. The problem of the evolution can be formulated as a PDE ∂S ------= βn (2.12) ∂t 18 2. LEVELSET METHODS

with the initial condition

S(t=0)=S0, (2.13) where n is the unit normal vector of S and β is the velocity of a point on the surface in normal direction. Instead of choosing a parameterization of S, the main concept behind the levelset formulation is to define the interface implicitly as the zero level of u.

St()= {}xuxt(), = 0 (2.14)

To derive an equation of motion, one looks at a particle on the front with path x(t). The level- set function u is vanishing at the position of the particle because the particle is part of the surface S(t).

uxt()(), t = 0 (2.15) The derivative in time of u calculated by the chain rule from (2.12) is

ut +0∇uxt()(), t ⋅ x'()t = , (2.16)

where x'()t is the velocity of the particle. Therefore, the following relation holds

∇u x'()t == βn β------(2.17) ∇u and the evolution of the surface now becomes

ut +0β∇u = , (2.18)

which is the level set equation given by Osher and Sethian in [25]. Equation (2.18) is a PDE and does not explicitly evolve a parameterized surface but descri- bes the change of a function in time. The function is defined in full space dimensions by the initial condition (2.13). The surface S moves because the set of points where the function u vanishes is changed by the PDE in time. The levelset equation not only evolves the interface S in time, which is the zero level of u, but simultaneously evolves all isosurfaces defined by u. Hence the speed function β has to be extended from the embedded surface to full dimensions. A point on an isosurface away from the zero level then moves with the value of the extended speed function. The construction of the extension is further discussed in section 2.3.5.

2.2.4 Finite Volume Schemes In order to numerically solve the equation (2.18), a discretization has to be chosen. Because the PDE is closely related to hyperbolic conservation laws, numerical schemes from this field can be applied to (2.18). Like solutions to nonlinear conservation laws, the solution of the level- set equation can form shocks even if the initial condition is smooth. The finite volume scheme incorporates weak solutions and the entropy condition. Therefore, it allows shocks in a solution. In this section, a few examples of finite volume schemes are introduced. The levelset equation (2.18) is a Hamilton-Jacobi equation,

ut +0Hu()∇ = with Hamiltonian Hx()= βx , (2.19) 2.2 THEORY OF SURFACE EVOLUTION 19

which is closely related to hyperbolic conservation laws. More precisely, ∇u satisfies a weakly hyperbolic system of conservation laws [4]. In view of these arguments, one can think of viscosity solutions of the Hamilton-Jacobi equations as primitives of the entropy solutions for the conservation law [17]. Based on this idea, the wide range of numerically robust discre- tization schemes for conservation laws can be applied to multi-dimensional Hamilton-Jacobi equations. The most obvious choice for the numerical treatment of the equation (2.1) is the finite volume method because this scheme incorporates the notion of weak solutions. Weak solutions do not need to be differentiable and can contain discontinuities. Therefore, a finite volume method uses volume averages and fluxes across cell boundaries. In contrast, finite difference methods use a point-wise discretization of the differential operators. For discontinuous functions, no stability predicate can be made with this method because derivatives are not defi- ned everywhere. Hence, the starting point for the discretization is the weak formulation of the equation. Integration of the scalar, non-viscous equation (2.1) over a spatial domain ()xi – 12⁄ , xi – 12⁄

xi + 12⁄ d ∫ uxt(), dx +0β()βux()i + 12⁄ , t – ()ux()i–12⁄ , t = (2.20) dt xi – 12⁄

and over time (tm, tm+1) results in

xi + 12⁄ xi + 12⁄

∫ uxt(), m + 1 dxuxt– ∫ (), m dx + (2.21)

xi – 12⁄ xi – 12⁄ tm + 1 tm + 1

∫ β()ux()i + 12⁄ , t dt – ∫ β()ux()i–12⁄ , t dt = 0. t t

Figure 2.7: Finite Volume Method: From the cell averaged solution um at time m tm, the average β on each cell boundary has to be approximated. From the flux through the cell boundaries during one time step, the new call averaged solutions at time tm+1 can be computed 20 2. LEVELSET METHODS

Discretizing the spatial and temporal integrals

xi + 12⁄ tm + 1 m 1 m 1 ui ==---- ∫ uxt(), m dx , βi ± 12⁄ --- ∫ β()ux()i ± 12⁄ , t dt (2.22) hi k xi – 12⁄ tm leads to the finite volume scheme

hi m + 1 m m m ----()βu – u +0– β = (2.23) k i i i + 12⁄ i – 12⁄ m To get a numerical scheme from (2.23), the fluxes βi ± 12⁄ have to be calculated from m {}ui iZ∈ . In general, one writes

m m m βi + 12⁄ = gu()ip–1+ ,,… uip+ (2.24) where the function g is called the numerical flux. Some useful examples for numerical flux functions with p=1 are • Local Lax-Friedrichs Flux: 1 gab(), =2---()β()a + β()b + Da()– b with Dmax≥ {}β'()s (2.25) 2 sab∈ [], This scheme produces considerably high dissipation and therefore undesired shock smearing. • Enquist-Osher Flux for convex β :

b a gab(), = ∫min()β'()s , 0 dsmax+ ∫ ()β'()s , 0 ds + β()0 (2.26) 0 0 The discretization of this formula results in an upwind differencing scheme of first or higher order. • Godunov Scheme: The idea behind Godunov method [10] consists in analytically sol- ving the Riemann problem described in section 2.2.2 at each shock of the piecewise con- stant finite volume function starting at time tm. This exact solution is evaluated at time tm+1 and averaged in each cell to obtain a piecewise constant solution again. A CFL con- dition arises from the fact that neighboring Riemann problems are not allowed to interact. The CFL condition ensures that the maximum signal velocities do not cover more than half a spatial cell dimension during a time interval. • Approximate Riemann Solvers: The Godunov scheme requires the analytical solution of the Riemann problem at each grid point for every time step. Because the finite volume scheme is not error-free due to the temporal discretization, it is not necessary to precisely solve the Riemann problem. One example of an approximate Riemann solver is the Roe [27] scheme, which computes a linear approximation to the exact solution of the Rie- mann problem. Since all these schemes are originally designed for hyperbolic conservation laws they don’t automatically apply for the Hamilton-Jacobi equation, none-the-less they perform reasonably well in those situations too. But it can be shown [34] that the Enquist-Osher flux used by Sethian [32] does not satisfy the entropy condition and can replace shocks by fans and vice versa. For further readings refer to [8]. 2.3 SIGNED DISTANCE FIELD 21

2.3 Signed Distance Field

An implicit surface is described by a scalar function in full dimensions. The surface is present at all points were the function vanishes. The values at all other points are arbitrary in the sense that they have no influence on the position of the surface. But for numerical stability it is pre- ferred to choose the distance function, which is characterized by a of unit length. The calculation of the distance field and its preservation during the surface evolution is discussed in the following section.

2.3.1 Eikonal Equation

For a given explicit surface, a function u0 has to be computed for the implicit representation at the beginning of the evolution. This function is most often chosen to be the signed distance function to the initial interface S0 and can be characterized by the Eikonal equation

{}xu0()x = 0 ==S0 and ∇u0 1 . (2.27)

At every point in space, the value of the signed distance function is the distance to the closest point on the surface. In fact, the gradient of the solution is defined almost everywhere only, in the mathematical sense. More precisely, the gradient is not defined at points where more than one closest point on the surface exists. The set of points where the gradient contains a singularity is called the skeleton of the interface.

The sign is set to negative on one side of the surface and positive on the other side. To allow such a partition, the surface has to be closed and orientable. Three methods for quickly compu- ting this distance field are presented: the simple sweeping method, which was introduced in [28], the Fast Marching Method, which is thoroughly discussed in [32] and finally the Closest Point Transform from [21].

2.3.2 Sweeping Method

The idea behind the sweeping method is to start with boundary data for u0 at neighboring grid points to S0. The full distance field is then computed with Gauss-Seidel iterations of the Eikonal equation ∇u0 = 1 in alternating directions using upwind schemes. The inner loop updates the distance value at the current point only depending on neighbors with smaller values. The for- mula for updating a value ui is

2 ∑ max() ui –0uj, = h (2.28) ij–1=

where ij–1= denotes that the point with index j is a direct neighbor of the point with index i. The algorithm for solving (2.28) is described in section 4.4 and is just denoted “upwind update” for now.

The outer loop sweeps through the whole grid several times, each time using a different lexi- cographic ordering. The following pseudo code for the sweeping method gives a rough structure of the algorithm. 22 2. LEVELSET METHODS

Set I = all indices; for(i ∈ I) ui = unknown;

Set N = {i ∈ I: i close to S0}; for(i ∈ N) ui = distance(i, S0); until convergence: for(Basis b ∈ {x, y, z}) for(Compare c ∈ {less, greater}3); lexicographic sort(I, b, c);

for(i ∈ I) ui = upwind update; Usually, convergence takes no more than one cycle of all possible lexicographic orderings and the operator count is linear in the number of grid points. The computation of the initial data is linear in the complexity of the surface S0. Although the sweeping method is a linear algo- rithm, it is rather slow for real world applications.

2.3.3 Fast Marching Method The solution to the Eikonal equation is equal to the time of first arrival of the initial front traveling with unit speed. This PDE point of view results in the observation of a very specific causality relationship: Information is only propagated outward from points closer to the surface to points further away from the surface [31]. Unlike the sweeping method, which performs costly iterations over the whole grid, the Fast Marching Method conserves whole grid sweeps. Instead, the Fast Marching Method performs the calculation in one loop, ordering the grid points in a non-lexicographic, strategically determined fashion. The order in which the distance values of the grid points are calculated is specific so that updates only depend on smaller values that have already converged. To achieve this upwind propagation, the exact of the grid points in close proximity to the front S0 are computed first. A thin intermediate-band with approximated distance values is then computed at grid points next to the known, exact distance values that were computed first. After an iterative update of the values within the thin band by an upwind differencing scheme, the smallest value is removed from the band and neighboring grid points of unknown distances are added to the band. The distances of these new points are calculated from points that already belong to the band. To ensure the outward propagation of the solution, all points that have distance values larger than the new points are updated. As this cycle progresses, more and more grid points with the smallest value are removed. After several exchanges, one of the points that were added first, stores the smallest distance of all grid points in the band and is therefore removed next. With this iteration, the thin band is grown outward away from the initial front until all grid points in the computational domain were processed through the band and store their final distance value. The efficiency of the Fast Marching Method is dependent on quickly finding the point with the smallest distance value in the intermediate-band. For this task, back pointers to the values in the band are kept in a min-heap data structure. This is a complete binary tree with the property that node values are not larger than the values of their children. Therefore, the pointer to the grid point in the band that is closest to the interface is always stored at the root of the tree. The heap property has to be ensured when deleting the root, updating distance values and inserting new grid points. All these operations are performed in logarithmic time compared to the size of the heap. Thus, the total work of the Fast Marching Method in d dimensions for N points is bounded by ON() log()Ndd⁄ ()– 1 because the band contains ON()dd⁄ ()– 1 points and each point is pro- cessed through the band once. Although the complexity of the algorithm is not optimal, it still performs very well for reasonably sized problems. 2.3 SIGNED DISTANCE FIELD 23

Figure 2.8: The Fast Marching Method computes distance values simultaneous- ly only within a thin band (yellow). The front moves away from the surface (upper left) by iteratively removing the point with the smal- lest value from the band and adding it to the points with frozen values (blue). A point with unknown value (red) replaces the removed point in the band.

The pseudo code of the Fast Marching Method looks as follows. Set I = all indices; for(i ∈ I) ui = unknown;

MinHeap N = {i ∈ I: i close to S0}; for(i ∈ N) ui = distance(i, S0); do

Index s = arg miniN∈ ( (ui); N.remove(s); Set M = {i: |i-s| == 1, ui == unknown}

Value v = miniN∈ (ui = upwind update); N.add(M);

for(i ∈ N: ui > v) ui = upwind update; until N.empty();

2.3.4 Closest Point Transform The sweeping method and the Fast Marching Method both solve a discretized approximation of the Eikonal equation. For exact distance fields, this is not sufficient and for each grid point, the position of the closest point on the surface has to be found. The distance to this point is the exact solution to the Eikonal equation. From any position in space, the Closest Point Transform finds the nearest point on the surface S0. The distance field can easily be computed from this information. For triangulated meshes, the closest point on one of the primitives building the mesh can be computed. The brute force approach of testing each grid point against each surface primitive is slow but embarrassingly parallel. An improvement is presented in [21] by reducing the number of points that have to be tested against one primitive. For a set of primitives in space, the Voronoi diagram separates space into regions where all points are closest to the same primitives. A cell of a Voronoi dia- gram contains exactly all the points laying closest to the primitive based upon which the cell 24 2. LEVELSET METHODS was built. To compute a distance transform when the Voronoi diagram is given, only one distance for each point has to be computed because the closest primitive is known. Instead of computing the exact Voronoi cell for each primitive, which is a time-consuming process, one computes a volume that at least contains all closest grid points. These volumes can then be scan- converted to find all grid points laying inside the volume. Only for those points, the distance to the primitive has to be calculated because all points laying outside of the volume have a diffe- rent closest primitive on the surface. Because the approximated cells contain more than just the closest points, the cells are overlapping. If a point lies in several cells, one calculates several distances and accepts the smallest distance as the solution. For triangulated meshes, the surface primitives are faces, edges and vertices. The correspon- ding volumes containing at least all closest points up to a certain maximum distance are the polyhedrons shown in Fig. 2.9.

Figure 2.9: Polyhedrons containing at least all closest points to a triangle (left), an edge (right) and a vertex (bottom). All points outside these poly- hedrons are closer to different primitives of the surface.

2.3.5 Preservation of Distance Field As shown in [11], the distance function initially computed for an implicit representation of the surface is not preserved during the evolution with equation (2.18). This lack of preservation presents a problem because the properties of functions holding the Eikonal equation are essen- tial to the Levelset Method. 2.3 SIGNED DISTANCE FIELD 25

• The implicit definition of S as a subset of R3 and the signed distance function u are equi- valent descriptions. In other words, given any oriented surface S, the signed distance function is uniquely defined and vice versa. Therefore a stationary levelset problem has converged if and only if the underlaying surface evolution problem has converged. • One can deduce interesting intrinsic properties of S by a local knowledge of u. For example the curvature of the levelset can be calculated from the distance function and skeletons are defined by singularities in the distance function. • For the numerical approximation of the derivatives of u by finite differences, a normali- zed gradient assures minimal rounding errors for fixed spatial step sizes. • For the narrow band method, which is described in section 2.4, reinitialization is needed when the front moves out of the region of defined function values. The set of grid points that belong to the narrow band is reset so that the zero level lays in the center of the band. Usually, the distance field is recalculated for the whole band to satisfy the Eikonal equa- tion. If the distance field is preserved during the evolution, only distance values for points that did not belong to the old band have to be calculated.

In order to keep the property of a distance function during the solution of the PDE, one has to properly extend the speed function to the whole computational domain. The constraints for this extension, which is denoted B, are

β B u = 0 = (2.29) ∂u ------= B ∂t ∇u = 1

Differentiating leads to

∂u ∇ ------= ∇B and (2.30) ∂t ∇u ∂∇u ∇u ∂u ∇u 0 ==------⋅ ------⋅ ∇ ------=------⋅ ∇B ∇u ∂t ∇u ∂t ∇u ⇒ ∇u ⋅ ∇B = 0

which defines the function B. Because of u and B are orthogonal, the speed function is constant along the characteristics of u. Characteristics of distance functions are straight lines normal to all isosurfaces. Therefore the speed function off the surface is equivalent to the speed function at the closest point on the surface. As a result, the levelset equation (2.18) can be refor- mulated to preserve the distance field as follows

ut = β()xu– ∇u . (2.31)

Equation (2.31) is neither a Hamilton-Jacobi equation nor a PDE. But it can be shown [11] that for the imported mean curvature flow, the equation can be reformulated as a PDE. 26 2. LEVELSET METHODS

2.4 Narrow Band

Thus far, the function describing the implicit surface was defined in the whole space. Alt- hough, it is sufficient for a unique description to define the function only where its value is close to the isovalue of the surface. This idea is used for the narrow band technique, which is essential for a fast implementation of the Levelset Method. The levelset function is only sampled within a thin region around the moving interface. Outside this band of samples, the value of the func- tion is unknown. Although the value is unknown, the sign is defined and determines on which side of the interface the region is laying. The sign does not change within a connected region of undefined samples.

Figure 2.10: Narrow Band. The computational region is reduced to a vicinity of the interface. Only a fraction of the levelset function is sampled and updated in every time step. When the interface moves out of the nar- row band, the calculation is stopped and a new band is built with the interface at the center of the band

Rather than updating all grid points of the computational domain, the narrow band approach stores values of u only at grid points up to a certain distance off the interface of interest. The computational complexity is greatly reduced because a significant smaller amount of values have to be updated at every time step. Table 2.1 shows a comparison of the number of samples Table 2.1: Number of samples in the narrow band of width 6 around a sphere and in the whole domain for different grid resolutions. Grid Resolution 32 64 128 256 Full Domain 32 K 256 K 2 M 16 M Narrow Band 12.7 K 62.1 K 0.268 M 1.12 M in a narrow band around a sphere for different grid sizes. The set of grid points belonging to the narrow band is unchanged for the duration of several time steps until the zero level reaches the edge of the narrow band at one point. To catch this event, land mines are placed at the border of the band. As soon as one of the signs of the land mines changes during one time step, the cal- culation is stopped and a new band is built with the zero level at the center of the band. To reduce the amount of grid values updated at every time step, it is important to keep the narrow band as thin as possible. However, some components of the Levelset simulation need a minimum width of the narrow band. The Marching Cubes algorithm is used to extract an expli- cit representation of an isosurface of a scalar field. To successfully restore the interface, the 2.4 NARROW BAND 27

Marching Cubes Algorithm requires at least a 26-connected region containing the isosurface. But a minimum width of 2 is not feasible to approximate curvature by finite differences. Also, the thinner the chosen narrow band is, the more often the distance field has to be reinitialized because the zero level moves out of the band. 28 2. LEVELSET METHODS 3

3Applications

After the theory of Levelset Methods was derived in the last chapter, this chapter presents some examples of evolving interfaces from a wide range of applications. For each application, a specific speed function is designed so that the desired movement of the surface is achieved. The interfaces are evolved using the Levelset Method. In the first section, some examples of sur- face smoothing operators are described. In 3.2, levelsets are applied to grid generation for nume- rical computations. Section 3.3, presents an example where not only one interface but a whole family of interfaces is evolved in time. In order to remove noise from a gray scale image, the image intensity is evolved with the levelset equation. In the next section, the speed function is designed so that a point placed into a grayscale image grows until it covers a region of uniform image intensities. This process is used for image segmentation, a problem found in the disci- pline of computer vision. Levelsets can also solve the tasks of CSG and solid modeling used in computer-aided design, which is presented in 3.5. The next section presents an algorithm for path planning using moving interfaces. The chapter concludes with a section on tracking inter- faces in multiphase flows with a hybrid levelset approach.

3.1 Geometry In many applications, the speed of a surface depends on the local curvature. The motion of a surface under curvature is called curvature flow and corresponds to a geometric version of the heat equation. High frequency oscillations in the interface are damped. Information contained in the initial surface is dissipated and the surface is smoothed. Curvature flow is also used when finding optimal configurations with minimal energy. In this case, the curvature acts as surface tension together with other terms in the speed function. For the one-dimensional case, the levelset equation with negative curvature speed βκ= – is

∇u ∇u u = ∇ ⋅ ------∇u because κ∇= ⋅ ------. (3.1) t ∇u ∇u Grayson proofed in [12] that any curve bounding a connected component of a plane shrinks to one point and disappears under curvature flow. This property cannot easily be extended to higher dimensions because several different mea- surements for curvature of hyper surfaces in three and higher dimensional space exist. All cur- vature measurements can be calculated from the principle curvatures, which are derived as

29 30 3. APPLICATIONS follows: Given a parameterization p of the hyper surface in d dimensional space, a gradient of the normal vector n can be calculated.

∂ni ∇n = ------(3.2) ∂ pj id≤ , j ≤ d – 1 If the surface is smooth, the normal itself is in the kernel of the gradient. Therefore, the normal spans an eigenspace with a vanishing eigenvalue. The information about local curvature is stored in the normal gradient restricted to the tangent space, which is a d-1 square matrix. Its eigenvalues are the principle curvatures κi in parameter space and the eigenvectors are called the principle directions of curvature. Two important curvature measurements are

1 Mean curvature H=------∑ κi (3.3) d – 1 id< κ Gaussian curvature G=d – 1 ∏ i id< The boundary of any convex shape collapses to one point and disappears under both mean curvature and square root of Gaussian curvature flow [14, 26]. For non-convex shapes like a dumbbell, the initially connected surface splits during the evolution for mean curvature flow and leads to instabilities for the square root of Gaussian curvature flow. In [23], the properties of both flows are combined to get the Mean-Gaussian flow

β = –sign() H max() G, 0 (3.4) which shrinks the dumbbell to a single point, see figure 3.1. To avoid shrinking the volume bounded by the initial surface during the evolution, the aver- age curvature has to be kept constant. This is achieved by the speed function

βκκ= –()– Ave (3.5)

where κAve is the average curvature of the interface. The motion under the second derivative of curvature is known as surface diffusion. This evo- lution is needed in physical applications, but is numerically difficult to compute. The lack of a maximum principle can result in surface mergers and it is therefore necessary to introduce more than one levelset function. Additionally, the calculation of fourth order derivatives is numeri- cally difficult [2].

3.2 Grid Generation In computational fluid dynamics the problem of grid generation is an important part of the whole task. A good computational grid leads to smaller numerical errors and faster conver- gence. Numerical schemes like finite volumes require logically rectangular, body fitted grids. Hyperbolic techniques allow a balance between the two desired properties - mesh orthogonality and cell uniformity. A front is advanced away from the body, defining a stack of thin regions by partitioning time. Each thin region is cut into cells by space partitioning the front. The speed function of the front is chosen to be 3.3 NOISE REMOVAL IN IMAGES 31

Figure 3.1: Dumbbell under different curvature flows. The initial interface bounds a connected, non-convex region (upper left). The evolution under Gaussian flow encounters instabilities (yellow). Under mean curvature flow, the handle disappears and hence the topology of the region changes (red). The Mean-Gaussian flow shrinks the boundary to one single point (blue).

β = 1 – εκ (3.6) with a parameter ε . This parameter regulates the surface tension of the front and therefore regulates how fast the front will converge to a sphere as it moves away from the body. For small ε , the front forms a sharp corner off concave regions and the transverse lines come close together. This is not preferred because the cells become non-uniform in size. To achieve more uniform cell sizes, a diffusion operator can be applied to the partition of the front thereby sepa- rating the transverse lines [30]. If a grid is needed inside a body, the speed functions discussed in the last section are used to guarantee a constant topology while the front of each connected region shrinks to one point.

3.3 Noise Removal in Images While geometrical motion of a front was the subject of the last two sections, the levelset approach also allows processing of sampled functions in full dimension such as gray scale images and computer tomography (CT) scans. In this case, all isocontours or levelsets defined by the sampled function are processed by the levelset equation (2.18) at the same time. If cur- 32 3. APPLICATIONS

Figure 3.2: Solutions of an interface moving away from a surface with surface tension. The interface is moved away from the yellow duck with speed function (3.6). The interface position at three different times is visualized. vature flow is applied to an image, noise is reduced and boundary oscillations are smoothed while large gradients are preserved.

A common way to reduce noise in images is the application of a Gaussian filter. The Gaus- sian filter can be described as the convolution of the image, represented as a density function u, with a Gaussian kernel. In the levelset methodology, this is achieved by the speed function

∇∇⋅ u β = –------. (3.7) ∇u

Unfortunately, this results in isotropic smoothing, which blurs the signal in all directions and dimensions and therefore the boundaries and edges are smeared. Because those boundaries and edges often represent important features of the image, one wishes to avoid this uniform blurring. To avoid this, one chooses the speed function of the curvature flow

∇u βκ==– –∇ ⋅ ------. (3.8) ∇u

As seen in section 3.1, curvature flow smoothens boundaries but also shrinks the enclosed region to a point. Although it is desired that noise is removed completely from the image, shrin- kage should be avoided for edges representing features in the picture. Hence a stopping criterion is required to avoid shrinkage of edges that represent features. The distinction between noise and features is a subjective decision and should usually not be encoded into an algorithm used to process a wide range of images. 3.3 NOISE REMOVAL IN IMAGES 33

Malladi describes an extension to the curvature flow in [19] which allows the user to control this distinction and brings the PDE to a steady state without shrinking all regions to a single point. To derive the speed function for smoothing boundaries up to a variable scale, consider two variations of the basic curvature flow:

β = –min()κ, 0 (3.9) β = –max()κ, 0 The effect of flow under the former speed function is to allow inward concave fingers to grow outwards, while suppressing motion of outward convex regions. Thus, the motion halts as soon as the convex hull is obtained. Conversely, the flow under the latter speed function allows the outward regions to grow inwards while suppressing the motion of the inwards concave regions. However, the motion will not halt but becomes a regular curvature flow once the shape is fully convex. Therefore, the region shrinks to zero and disappears. The goal is now to construct a switch between the two speed functions in order to smooth out small oscillations but maintain essential properties of the shape. In [18] that switch is chosen to compare two different averages of sample values to get the min/max flow

 ()κ, < β =  –max 0 Avg G . (3.10)  –min()κ, 0 Avg≥ G

Avg is the averaged image intensity in a neighborhood of a user-defined radius and G is the averaged intensity perpendicular to the intensity gradient. The radius of the average controls the maximal scale of oscillations that is smoothed. Because the min/max flow should only be applied to features while the rest of the image is smoothed under curvature flow, the final speed function is set to

 κ ∇ < β =  – uK (3.11)  min/max flow ∇uK≥

where K is a threshold, which defines the minimum gradient length for edges that should not shrink while they are smoothed.

Figure 3.3: Noise removal with Levelset Methods. 30% noise is added to the in- itial picture (left and middle). The noise is then removed with the min/max flow while preserving edges (right). Reprints from [15] in courtesy of Seongjai Kim. 34 3. APPLICATIONS

3.4 Shape Detection Given a raw image from a CT scan, a connected shape of similar grayness intensity should be extracted. The shape is bounded by a jump in the image intensity. The approach uses active contours or snakes to grow an initial, user-defined region until it covers the whole isolated object [20]. The speed function

β = 1 – εκ (3.12) consists of the unit speed to grow the interface outward and a surface tension term to achieve a smooth boundary. The surface tension term consists of the curvature κ multiplied by a con- stant ε . To lock the interface on to the boundary of the region to extract, the speed function is multiplied by

–1 ()1 + ∇()Gσ*I (3.13)

where Gσ*I is the underlaying image filtered with a Gaussian kernel of variation σ . This term is close to unity at smooth regions and gets very small along edges because of the steep intensity gradient. Therefore, the initial region bounded by the interface is growing with unit speed at regions of uniform density. The interface slows down and stops when it reaches an edge in the image. The interface therefore converges to the shape boundary defined by large gradients in the image. Noise produced by the scanning device is smoothed by the Gaussian filter.

Figure 3.4: Shape detection. An initial region is expanded until the boundary locks at a steep gradient of the underlaying image. Reprints from [20] in courtesy of Ravi Malladi.

3.5 Computational Geometry and CAD This section describes applications of the Levelset Method and the Fast Marching Method in the field of computational geometry and computer-aided design. The Fast Marching Method builds the distance field of a surface as time of first arrivals of a front propagating away from the surface with unit speed. Besides the pure distance field, this approach can produce additional information about the shape of the surface. For a segmented surface, an identifier of the segment can be incorporated into the initial front. When two parts of the front with different identifiers collide, the corresponding segments lay in the same distance to the position where the collision occurred. The set of these collision points corresponds to the Voronoi diagram of the segmented surface because the Voronoi diagram separates space into regions where all points are closest to the same segment. Therefore, the part of the front with one identifier travels through the whole Voronoi cell of the corresponding segment and hits another part of the front with a dif- ferent identifier on the cell boundary. The Fast Marching Method propagates the front in discrete steps on a spatial grid. To com- pute the Voronoi diagram, the distance function is calculated simultaneously from all segments until parts of the front with different identifiers overlap by one sample. The Voronoi cell bound- 3.5 COMPUTATIONAL GEOMETRY AND CAD 35 aries can now be extracted from grid cubes storing multiple distance values by finding the sur- face where the trilinear interpolated distance functions all have the same value. Also constructive solid geometry (CSG) operators can be incorporated into the levelset approach [22]. Table 3.1 describes the operations between two distance functions, each defining a closed surface, that match Boolean operations between the volumes enclosed by the surface. Tabelle 3.1: CSG operations of objects A (torus) and B (sphere) repre- sented by distance functions uA and uB . Action CSG operation Distance operator Picture

Copy AB∩ max() uA, uB

Paste AB∪ min() uA, uB

Cut AB– max() uA, –uB

The result of each operation is a new distance field that defines the boundary of the new Boo- lean object. To show the concept, the cut operations shall be discussed in detail. The distance fields uA and uB are negative inside and positive outside the shapes A and B, respectively. When the shape B is cut out of shape A, all points that are inside A but outside B belong to the new shape. In terms of distance functions, this means that at all points where uA is negative but uB is positive, a negative value should be assigned. This is clearly the case for max() uA, –uB . For a point where either uA is positive or uB is negative, the result is positive and the point lays outside of the new shape. CSG operators result in sharp edges where the two object boundaries intersect. A modeler therefore often wants to smooth this intersection. To achieve this, the surface is low pass filtered with curvature flow or other fairing operators like the min/max flow from section 3.3. To avoid a global or extensive filtering that would also remove desired features, the flow is modulated with another function. Two factors allow the user to control the surface evolution: • “region-of-influence” - a smoothed box function of user-definable radius is computed around the boundary intersections to spatially restrict the fairing. • “geometric measure” - a barrier function is chosen to keep geometric measures like the curvature within a user-definable interval. Besides smoothing the intersection of two interfaces, fairing of surfaces in general is a common task in modeling. Although the curvature flow is reducing undesired boundary oscil- 36 3. APPLICATIONS lations, it lacks a stopping criteria and the region shrinks to a point if the evolution is not halted. The min/max flow introduced in section 3.3 does not have this disadvantage. Instead, the user can choose a maximum scale for which boundary oscillations are smoothed. The min/max flow converges to a steady state where repeated application of the flow does not change the boundary anymore.

3.6 Path Planning

The last applications presented all use the Eikonal equation to compute first arrivals. From all possible weak solutions to a boundary value problem, the viscosity solution is the one that corresponds to fastest propagation of the initial information. From the viscosity solution, the initial information can be traced back to the initial data via the shortest path. This idea leads to solutions in a set of optimization problems including path planning and calculation of shortest distances on manifolds [3].

The task is to find a path γ()t with γ()0 = x0 and γ()1 = x1 which minimizes

1 φγ()γ ux()0, x1 = ∫ t dt (3.14) 0

where φ is a given cost function. The problem can be split to an Eikonal equation and an ordinary differential equation as follows. The function ux()= ux()0, x is the solution of

∇φux() = ()x and ux()0 = 0 (3.15)

and the problem is solved by setting γ to the solution of

γt = –ux()1 ∇u and γ()1 = x1 . (3.16)

The values of the function u(x) are the arrival times of the front propagating with speed φ starting at point x0. The optimal path can be constructed by tracing the front backward from x1 to x0.

With this approach, a shortest path for moving an object from point x0 to point x1 can be plan- ned. Obstacles in space that need not to be intersected by γ()t are realized by setting the cost function to infinity inside the obstacle. If the object is not just a point but a shape S, the problem has to be transformed in two steps in order to reduce it to the case of a point. First, the dimension of the space is enlarged to parameterize the orientation of the object. Second, the cost function is convolved with the delta function of the shape of the object in the corresponding orientation

 1 xS∈ δS()x =  . (3.17)  0 xS∉

This enlarges the size of obstacles and in return the extent of the object can be shrunk to a point. The problem is now reduced to the case described first. For calculation of first arrivals on manifolds, the Eikonal equation solvers can be extended to triangulated domains [16]. The shortest path on a manifold is called geodesic. 3.7 MULTIPHASE FLOWS 37

3.7 Multiphase Flows Multiphase flow is the simultaneous flow of gas, liquid and solid phases in different combi- nations. They are important in most industrial applications, such as combustion engines and tur- bines. There are many ways to model a multiphase flow problem using PDEs, depending on the nature of the problem. For dilute dispersed flows, Lagrangian particle tracking is often employed. Using this approach, the motion of the continuous fluid is described by the Navier- Stokes equations in an Eulerian frame, while the bubbles, drops or particles are tracked by the equations of motion for each particle. For larger flow problems, Eulerian multi-fluid models are often used instead of the Lagrangian approach. In multi-fluid models, the dispersed phase is also treated as a continuous medium and the phase density is regarded as a continuous property. Unfortunately, this approach does not allow an accurate definition of the phase boundary, which is important for reacting flows like flames. To overcome this difficulty, the interface between phases is tracked during the calculation. It is very natural to use the Levelset Methods for this task because they fit well into the Eulerian frame of the Navier-Stokes equation. Due to the diffusive numerical schemes used to evolve the interface, the interface is unphy- sical smoothed during the calculation. This can be avoided by placing particles on either side of the interface before every time step. The particles are then moved independent of the levelset by the underlaying flow field. After the time step, some marker particles initially seeded on one side of the interface are detected on the opposite side of interface. They indicate an incorrect diffusion of the interface and are used to correct the levelset description [6]. The Lagrangian particles are not used for the flow calculation but only to detect errors in the interface evolution. The feasibility of this method was shown in [7] with the simulation of water splashes and in [24] with a realistic flame model.

Figure 3.5: Animation of fire and water based on simulations with hybrid Level- set Methods. Reprints from [6, 24] in courtesy of Ronald Fedkiw. 38 3. APPLICATIONS 4

4Framework

This chapter presents the different parts of the framework implemented. An overview of the framework and its different components implemented is given first. Section 4.2 introduces the concept of templates in C++ and the standard template library. Templates are used for the data structure that stores the sparse sampled field of variables used during the computation. The details of the data structure are expounded in section 4.3. In order to evolve the interface, a par- tial differential equation (PDE) has to be solved. The discretization of the continuous problem has to be done carefully to achieve a stable numerical implementation. This is described in sec- tion 4.4. The initial surface is usually given in an explicit triangulation. For the transformation to the implicit definition used in the levelset framework, a library is used which calculates a distance field. The algorithm implemented in the library is outlined together with some thoughts for an improved version using graphics hardware. The well-known Marching Cubes algorithm is reviewed in 4.6 and adapted to the environment. The next section describes the equation parser allowing the user to choose arbitrary speed functions. A configuration file is used to store options of the framework and is described in section 4.8. The chapter ends with a guide to the graphical user interface.

4.1 Overview

In this section an overview of the implemented classes is presented. The code forms a test environment for the Levelset Methods. The problem was restricted to three-dimensional uni- form grids. To speed up the computations, the Narrow Band Method was chosen. In contrast to the full matrix approach, the Narrow Band Method solves the levelset function only in regions that are essential to the description of the interface evolved. Namely, the function defined in a close vicinity to the interface is sufficient for a unique description of the interface. To save memory, only grid points that lay in this region are stored. To allow fast access to this sparse matrix of sample values, an octree was implemented. Because surfaces in the field of computer graphics are most often described as triangulated meshes, a simple ASCII file format import and export filter was written. For the transfer bet- ween the explicit description of surfaces by triangular meshes and the implicit description by a scalar function, two different algorithms are used, the Marching Cubes algorithm and the Clo- sest Point Transform. The former extracts a triangular description of an isosurface from a scalar field. Due to simple bit code comparison and table lookups, the process is very efficient. The Closest Point Transform computes a signed distance field from a triangulated mesh. For every

39 40 4. FRAMEWORK grid point in the three-dimensional domain, the distance to the closest point on the surface is calculated. By choosing a negative sign for distance values on one side of the surface, the ori- ginal surface corresponds to the zero isosurface of the signed distance field. A library is used for the computation of the distance field. Although high order numerical schemes for the levelset equation exist, they are harder to implement and have worse performance than the simple first order schemes. Also the additional accuracy gained with these methods is not necessary for this framework because it is not inten- ded to simulate physical processes. Instead, the time variable in the levelset equation is used as an artificial unit to calculate a steady state solution. Therefore, priority was given to numerical stability instead of accuracy and a simple first order scheme was implemented. Because the framework should serve as test environment for a wide range of speed functions used to evolve surfaces, an equation parser is used to give the user full freedom in the design of the speed function. The formula is translated from infix to postfix notation at runtime. Because the same function has to be evaluated many times with different variable values during each time step, a machine code function that takes the variable values as parameter is generated at runtime. To further reduce frequent recompilation of the code, a configuration file class was written and many options of the program can be stored in a simple text file that is loaded on program execution. For the verification of the solutions calculated, the distance field and extracted isosurfaces are visualized using OpenGL. All parameters of the surface evolution and the visualization are controllable with a graphical user interface.

4.2 Templates in C++

This section introduces the concept of templates in C++. Templates allow the parameterization of source code for different data types. One may implement a minimum function or a container class without specifying the type of parameter or elements respectively. It is important though that a template is not code for any type of object, but complete type checking is performed when the data type of the parameters or elements is known. Therefore, function templates are not blind text replacement rules like macros, but functions that undergo a semantic check dur- ing compilation.

Function Templates The definition of a function template is similar to an ordinary function for an assumed type that is indicated before the declaration. A maximum template for example is defined as template const T& max(const T& a, const T& b) { return (a > b ? a : b); } The keyword typename is used to indicate that the following symbol T is a type. The declara- tion uses this type T as a parameter. The instructions inside the function are the same as for an ordinary function. In this case, the maximum of two values of an assumed type T is returned using the compare operator. A function template is used like any other function. int a,b; std::cout << max(a,b) << std::endl; As soon as the function max() is called for two objects of the same type, the compiler uses the 4.2 TEMPLATES IN C++ 41 template definition and produces code by replacing the parameter with the type used. This means that if a template is used for several types, several functions are being compiled. Of course, the code can only be compiled if all operations performed in the template function are defined for the type used. To be able to call the max() function for integers, the compare oper- ator < has to be defined for int. Templates are extending the classical model of compiler and linker with distinct translation units. It is unknown for which types a template has to be compiled until the actual usage. Therefore, the complete template code should be placed into the header file.

Class Templates

In addition to the parameterization of function types, also classes can be parameterized. This is very helpful for container classes, which are used to store objects. Class templates make it pos- sible to implement container classes although the type of the objects to store is not known yet.

Standard Template Library

In modern data processing, programmers often have to deal not only with data, variables and objects but also with sets of those elements. In C++, the programmer has to implement data structures like fields, linked lists, trees and hash tables to deal with sets.

Figure 4.1: Components of the Standard Template Library

The C++ standard library offers an own framework to handle sets, the so-called Standard Tem- plate Library [33], or STL with container classes, algorithms, and iterators. It provides many of the basic algorithms and data structures of computer science. Iterators provide a common inter- face to access containers and algorithms do not need additional information about the container they are applied to. Operations on types stored in a container can be written as function objects that can be passed to algorithms. For example, a function object can define a less operator used to sort a list or a tree. The basic structure of the library is shown in figure 4.1. To make STL a generic library, almost every component is a template. Because templates provide static poly- morphism, meaning that function calls are resolved during compilation and data types are independent from each other, STL containers are very close to the efficiency of hand-coded, type-specific containers. 42 4. FRAMEWORK

4.3 Data Structure The framework is restricted to uniform sampling of the distance function in combination with the narrow band technique. To store the distance values, an octree was implemented. To explain the implementation details, the properties necessary for the framework are presented first. • New samples have to be inserted into and removed from the data structure during the cal- culation to keep the narrow band with constant width centered around the evolving zero level. • Stencil queries should be resolved in constant time because they are a considerable part of the computation of finite differences. • Sweeping the volume for all possible lexicographic orderings has to be fast when the sweeping method is used to compute the distance function. • For the evaluation of the speed function, the distance function and its first and second derivative have to be known for all sample points in the narrow band but the position of the samples is not of any interest. • For the extraction of an isosurface with .the Marching Cubes algorithm, a distance value range query would reduce the amount of cubes that have to be tested for isosurface intersection. • To build the structures needed for high performance of the tasks above, a quick random access of samples is necessary. An octree is a three-dimensional space-partitioning tree. They are used to store static geome- tric objects. The cube containing the computational domain is called the root and is subdivided into eight smaller cubes of equal size. Each smaller cube is a node and is recursively subdivided. Each node stores a link to its eight children. Nodes that are not further subdivided are called leaves and store a link to data objects intersecting the cube. The maximum number of subdivi- sions of a node is its level and the level of the root is called the depth of the tree. Octrees are very well suited to particular tasks such as finding objects in a given area. To query all data objects intersecting a subvolume, only objects that intersect the same leaves as the subvolume must be processed. The storage of functions with equal sampling width allows some optimizations of the octree. If the number of samples in each direction is N = 2n , the leaves with full subdivision of a tree with depth n will each contain one sample point. Only nodes that contain samples are further subdivided to keep the memory consumption linear to the number of samples stored. The random access of a sample by its position is completed by following the links from the root down to the leaf, which takes O(log(N)) time. The position of a sample does not have to be stored because it is implicitly defined by the series of children chosen between the root and the leaf. The octree is a templated class to allow storage of any type of samples. A sample type has to provide a member function that returns its value for range queries. Each node stores the mini- mum and maximum value of all samples contained in the node. A compare operator has to be provided for a strict weak ordering of sample values. To return all samples with values in a cer- tain interval, nodes do not have to be processed where the min/max interval of values does not intersect the query range. There is a quick way to search for direct neighbors of a leaf. The idea is to search for the first common parent of the current leaf and the neighbor leaf. While traveling up the tree to the common parent, the indices of the children visited are stored. To walk from the common parent 4.4 NUMERICAL SCHEMES 43 to the neighbor leaf, a mirror copy of the first journey is traveled. Thus, the neighbor can be found by traveling down choosing the children opposite to the ones stored in the series. Although this algorithm is fast, it is still O(log(N)) in average. The same computational complexity applies for finding the next sample in a given basis direction. Also this algorithm is logarithmic in time but one can do this search once for every sample inserted and store the results. The leafs of the tree then form an eight fold linked list which can provide both stencil search and sweeping in constant time. To allow fast access of all samples when the position is not of importance, the samples are stored in a STL vector and accessed with an index from the octree leaves.

4.4 Numerical Schemes

Eikonal Equation Discretization As described in section 2.3, the Eikonal equation

{}xu0()x = 0 ==S0 and ∇u0 1 (4.1)

needs to be solved to calculate a distance field off the zero levelset. In a first step, a thin band of distance values around the front is calculated. All other values are set to a large number. By solving the equation (2.28), one updates distance values only depending on smaller values. The implementation to update a point di can be written in pseudo code as:

N = sort({dj|j neighbor of i}); d2 = 0; k = 0; while(++k < size(N) && d2 < h2) 2 2 d += (Nk - N0) ; 2 2 di = solution of sumj=0..k (di-Nj) = h ; This algorithm only solves one second order polynomial per distance update. Special care has to be paid to the fact that one is dealing with a function that has both positive and negative values, but values are compared by their absolute value. This is because the new value should depend on values that are closer to the front. Although the sweeping method is an iterative pro- cess and needs several updates per point, it is very competitive to the Fast Marching Method which, needs to sort the front of intermediate distance point as it grows outward. This sorting process makes the Fast Marching Method a O(N log(Nd/(d-1))) algorithm while the sweeping method is linear in the number of samples N.

Gradient Discretization In spatial dimension, the levelset equation

ut +0β∇u = (4.2)

has to be discretized with special care because the gradient of the distance function under- goes jumps at the skeleton and at shocks. A very simple scheme that guarantees stability is to use upwind differences to approximate the gradient. This means that the derivative is approxi- mated by a one-sided derivative in the direction of the closest point on the zero levelset. The easiest implementation for this is to choose one-sided derivatives in the directions that result in the largest gradient. 44 4. FRAMEWORK

Curvature Discretization The curvature is a common parameter of the speed function as seen in chapter 3. To extend the speed function to the whole computational domain, one also has to extend the curvature. To achieve this, the curvature at a point away from the front is defined to be the curvature of the isosurface through that point. The two principle curvatures κ12, are the nonzero eigenvalues of the Hesse matrix H projected to the tangent plane of the isosurface. H is computed by central differences of the gradient field and then projected by

()Inn– ⋅ T THI()– n⋅ nT (4.3)

This results in a 33× matrix whose eigenvalues 0, κ1 and κ2 have to be extracted by sol- ving a third order polynomial. To reduce the effort to the solution of a second order polynomial, an orthogonal basis B of the tangent space has to be found.

BTn = 0 (4.4) Now, the projection

BTHB (4.5)

results in a 22×κ matrix with the eigenvalues 1 and κ2 . Although this is much faster, the calculation of the principal curvatures still takes up the most workload in each time step.

Time Discretization An explicit Euler scheme is used for the time discretization. Once the speed function is eva- luated at each sample point, the distance value is updated by

m + 1 m 1 m u = u – ----- β . (4.6) ∆t Because am approximative Riemann problem is solved for each sample independent from its neighbors, it has to be guaranteed that information propagated from one sample does not enter the computational domain of another sample within one time step. A CFL condition on the time step is necessary to avoid the interference of Riemann solutions in a cell. This condition is necessary for convergence of explicit numerical schemes. To still apply the biggest time steps possible, we record the maximum β -value and set the time step according to

h β ∆t < --- (4.7) max 2 where h is the spatial resolution. It is also important to keep the zero level within the narrow band in order to always have a complete description of the closed surface. Therefore, the time step is bound so that no sample at most three edges away from the narrow band border changes its sign. Thus, cubes containing parts of the zero level are always fully sampled at all eight corners and the Marching Cubes algorithm can extract a closed surface. If it is necessary to shorten the time step to assure this, a reinitialization process is triggered afterwards. The zero levelset is extracted with Marching Cubes and a new distance field around the surface is computed with the Closest Point Trans- form. 4.5 CLOSEST POINT TRANSFORM 45

4.5 Closest Point Transform

To compute the distance field in the narrow band from a triangulated input surface, the library presented in [21] is used. For each triangle, edge and point of the surface, a volume con- taining at least all closest points to that primitive is built. By construction, each volume is enclo- sing the Voronoi cell of the corresponding primitive. For the narrow band method, the extent of the primitive can be restricted to the width of the narrow band. To find the grid points inside a volume, one uses the scan conversion algorithm. At each scan-converted point, the distance to the primitive that defines the volume is calculated and the minimum distance of all volumes containing that point is stored in the distance field. di = ∞ ∀i for all faces p = polyhedron containing all closest points to face for all i∈ scan convert(p)

if |di| > |d = min(distance(i, face)| di = d; for all edges ... for all vertices: ... Because scan conversion is a dominant part of rasterization, modern graphic cards are desi- gned to perform well in that task and are much faster than CPUs. Therefore, one can speed up the algorithm by slicing the volume into sample planes and drawing slices of the polyhedrons with OpenGL into each plane. Because pixel buffer read back is rather slow on current consu- mer graphic cards, all polygons of one slice should be drawn concurrently and then read back. The depth buffer is used to perform the minimum test and store the distance values and the sten- cil buffer keeps track of the sign of the distances. In standard OpenGL, depth values are bilinear interpolated between vertices within a polygon. Unfortunately, the distance function within one Voronoi cell is not trilinear. Therefore, the distance function within a slice of the polyhedron enclosing the Voronoi cell is not bilinear. In [13], the polygons are geometrically refined to

Figure 4.2: The distance fields within the Voronoi cells of edges and points are not trilinear. Hence the distance field is not bilinear within a slice of a cell. 46 4. FRAMEWORK compute Voronoi diagrams using hardware acceleration. But there is also a different approach, which saves a lot of AGP bandwidth. A single radial depth texture used for all polygons and linear texture coordinate interpolation along the edges of the polyhedron is enough to achieve correct values in the depth buffer. The implementation of this algorithm is still in progress. A demo and a separate report will be released as soon as possible.

4.6 Marching Cubes

Marching Cubes is an algorithm for extracting isosurfaces from volumetric uniform sampled scalar data [18]. The basic idea is to independently extract an isosurface for each cube defined by eight neighboring sample values. An 8-bit mask defines which of the corner values are smaller than the isovalue and is used to lookup which of the twelve edges of the cube intersect the isosurface. Linear interpolation between the samples is used to compute the exact position of the intersection vertices. A second lookup returns a list of vertex triples defining a triangle patch that divides the cube between regions inside the isosurface and regions outside. By con- necting the patches from all cubes on the isosurface boundary, a surface representation is pro- duced. For fast surface extraction from a static scalar field, the minimum and maximum values of each cube are stored in a range tree. This drastically reduces the amount of cubes processed by avoiding all cubes with no isosurface intersection, i.e. cubes with all or no bits set in the mask. Also the octree used in this framework is well suited to store minimum and maximum values of all cubes represented by a node. Unfortunately, the extreme values of eight cubes must be updated when changing a single sample value. Therefore it is computationally expensive to keep an updated min/max octree. When the scalar field is known to hold the Eikonal equation, i.e. is a distance field, the dif- ference between corner values within a cube is guaranteed to be smaller than 3 ⋅ h where h is the sampling width. Thus, it is enough to keep minimum and maximum information of the sample values instead of the cube ranges. But at the current implementation state, the distance field is not preserved during the evolution as described in section 2.3 and all cubes in the narrow band have to be checked for isosurface intersection. Although this is not optimal, the number of cubes in the narrow band is linear in the number of cubes intersected by the zero level. There- fore, also the Marching Cubes algorithm is linear.

4.7 Equation Parser

Because of the wide range of speed functions used in Levelset Methods, it would be impos- sible to include all possible functions into the source code and let the user choose from a fixed list. Instead, the user can type an expression into a text field and the formula is being parsed at runtime. After conversion from infix to postfix notation, the program produces machine code of the expression and wraps it with a function to allow variable substitution. In each time step, the function is called once per sample. The samples distance, normal and principal curvatures are passed as arguments to the function returning the speed value. Operators that can be used in the formula include addition [+], subtraction [-], multiplication [*], division [/], absolute value [abs()], sign [sign()] and square roots [sqrt()]. To extend the pos- sibilities of expressions, also additional supplied functions can be called from within the expres- sion. 4.8 CONFIGURATION FILE 47

4.8 Configuration File To avoid recompilation, a configuration file defines parameters of the program. This includes sampling resolution, available object files and initial speed function. All options are subdivided in sections for a better overview. The configuration file for example contains a section where the renderer is configured. // renderer options renderer { // width and hight of the renderer window windowsize = 512 // initial rotation matrix of the object rotateobj = (0.9 , 0.14, -0.44, 0, 0.03, 0.93, 0.37, 0, 0.46, -0.35, 0.82, 0, 0 , 0 , 0 , 1) rotatelight = (1 , 0 , 0 , 0, 0 , 1 , 0 , 0, 0 , 0 , 1 , 0, 0 , 0 , 0 , 1) // shading level of the object shadeobj = 3 }

4.9 Visualization OpenGL is used to display the isosurface and allows free rotation and movement of the camera to examine the properties of the surface. The levelset function is visualized by vectors in the normal direction with length equal to the distance value. Curvature is represented by points sized relative to the mean curvature. To allow a better examination of these values in cer- tain regions, the samples visualized can be reduced to a user-definable range off the surface. GLUT is used to handle window management. The user interface is programmed with the GLUI library, a GLUT-based C++ user interface library that provides controls such as buttons, check- boxes, radio buttons, and spinners to OpenGL applications. 48 4. FRAMEWORK

Figure 4.3: Isosurface with distance field visualization. Each line visualizes the vector from a point in space to its closest point on the surface. The blue points represent the curvature.

Figure 4.4: Graphical user interface with GLUI. All options are explained in Ta- ble 4.1. 4.9 VISUALIZATION 49

Tabelle 4.1: Caption to Figure 4.4. The graphical user interface of the framework provides extensive configuration possibilities. Control Description Options A Mesh Shading None Do not display the surface. Point Display vertices only. Wireframe Display edges only. Flat Display triangles using flat shading. Smooth Display triangles using Gouraud shading . B Compute Compute the distance field from the mesh displayed by the Closest Distance Point Transform. The width of the narrow band can be chosen. The Field larger the value, the more expensive a time step. On the other hand, the value has to be big enough so that the Marching Cubes algorithm can still extract a closed surface. The ROI option stores the distance field into a static array that can be used as a variable in the speed function. C Load and Loads or saves the mesh displayed. For loading, an entry from the Save Mesh configuration file should be chosen. For saving, the filename has to be entered into the field. D Distance None Do not display the distance field. Field Point Display points of the selected distance range Shading Distance Display vector to the closest point. Curve Display distance and visualize curvature. Point(ROI) Display points of the static array of values. Boundary Display points that belong to a boundary cube. E Show Range The range of distance values that is displayed can be chosen here. F Isosurface Extract the isosurface of the entered value and display it. The Mar- Extraction ching Cube algorithm is used for this task. G Surface Evolve the implicit surface with the Levelset Method. Evolution In the first field, the function for the velocity of the surface is en- tered. The second field H Correct Use the sweeping method to correct the distance field without rein- Distance itialization. Field I Shading None Do not display the point cloud. Point Cloud Point Display the vertices of the point cloud. J Load Load a point cloud from a file. An entry from the configuration file Point Cloud should be chosen. K Screenshot Save a screen shot of the render viewport as a TGA file. L Quit Exit the Program 50 4. FRAMEWORK 5

5Results

This chapter starts with examples showing the possibilities of the Levelset Method and the framework implemented. Pictures from offset surfaces, surface fairing and surface reconstruc- tion as well as from logical operations between two regions are presented. Then, some timing examples indicate the expensive parts of the computation. In 5.3, unresolved problems in the implemented framework as well as open issues in the theory of Levelset Methods are discussed. The chapter ends with possible future work in the field of Levelset Methods.

5.1 Applications

To test the framework for Levelset Methods, surfaces are evolved with a set of different speed functions that are used in applications described in chapter 3.

5.1.1 Offset Surfaces

To test the basic functionality of the framework, a triangulated mesh of a knot is loaded into the program. To achieve an implicit description of the surface, a distance field is built from the mesh. The zero level is then moved outwards with unit speed

β = 1 (5.1)

until the surface undergoes a topological change. During this change, the genus of the surface is reduced from one to zero. When the surface is moved backwards for the same amount, the genus does not change anymore. Figure 5.1 shows the result of this simple test.

5.1.2 Fairing

The next example uses the Mean-Gaussian curvature flow described in section 3.1 to smooth a distorted sphere. Figure 5.2 shows that high frequency oscillations are damped and the object surface becomes smooth. The speed function

β = –sign()κ1 + κ2 max()κ1 ⋅ κ2, 0 (5.2)

51 52 5. RESULTS

Figure 5.1: Topological change during forth-and-back evolution with unit speed. The initial surface (top) is evolved with unit speed until it bounds a connected region (left). When the interface is moved backwards the same distance, the initial state is not attained anymore.

Figure 5.2: Smoothing of a distorted sphere with Mean-Gaussian curvature flow.

5.1.3 Surface Reconstruction

Surface reconstruction from unorganized data, i.e. a point cloud, is a challenging problem because the connectivity and the topology of the surface are not unique. Therefore it is natural to use an implicit representation of the surface to be reconstructed. In levelset methodology, which offers the evolution of implicit surfaces, the problem consists in finding a speed function that moves an initial surface close to the points of the data set. The target surface minimizes the energy

ES()= ∫ds()x d (5.3) S

where d is the distance to the point cloud and ds is the surface area. As derived in [35], the gradient flow of the energy functional (5.3) is

∇dn⋅ + dκ (5.4) 5.1 APPLICATIONS 53

with κ being the mean curvature and n the normal of the surface. At the steady state solution, there is a balance between the attraction of the surface to the points ∇dn⋅ and the surface ten- sion dκ . The latter is dependent on the local data density, resulting in smooth surfaces at regions of poor sampling and a flexible surface at regions where more detail is contained in the data. The speed function of the levelset approach is set to

κ1 + κ2 β = ∇dud⋅ ∇ + ------. (5.5) 2 The distance field d to the point cloud is static and only has to be computed once. The recon- struction of a knot from a point cloud is shown in figure 5.3.

Figure 5.3: Surface reconstruction from point cloud. A cube is shrunken to a knot of higher topological genus.

5.1.4 Logical Operators Boolean operations between volumes can be described as operations between the signed distance functions of the boundaries of the volumes. Section 3.5 explains how intersection, sub- traction and union are mapped to operators of the distance fields. To test this idea, two shapes are loaded into the framework. Table 3.1 describes the operations between two distance functions, each defining a closed surface, that match Boolean operations between the volumes enclosed by the surface. The result of each operation is a new distance field, which defines the boundary of the new Boolean object. To show the concept, the cut operations shall be discussed in detail. The distance fields uA and uB are negative inside and positive outside the shapes A and B, respectively. When the shape B is cut out of shape A, all points that are inside A but outside B belong to the new shape. In terms of distance functions, this means that at all points where uA is negative but uB is positive, a nega- tive value should be assigned. This is clearly the case for max() uA, –uB . For a point where either uA is positive or uB is negative, the result is positive and the point lays outside of the new shape. 54 5. RESULTS

Figure 5.4: Logical Operators. The distance fields from a sphere and a cube with holes are combined to produce the intersection and subtraction volu- mes.

5.2 Performance Test To investigate the computational complexity of the algorithms and to find numerical expen- sive components of the framework, a few performance test were carried out. A small test pro- blem was solved for different resolutions and for different widths of the narrow band. During each computation, six time steps and a reinitialization process was performed. The Mean-Gaus- sian curvature function was evaluated for every sample and time step but the distance values were left unchanged to ensure consistent results. In table 5.1, the results of the computations car- ried out for different resolutions of the computational grid are listed. The narrow band was set to a width of 12 samples for all resolutions. The performance measurements indicate that the computational complexity grows less than quadratic in the number of points of the full grid in each direction for the narrow band method. The theory predicts a quadratic growth. It also shows that the calculation of the curvature is very expensive and uses more than half of the over- all time spent for each simulation. 3 The second set of measurements were performed with a fix full grid resolution of 64 but different widths of the narrow band. Table 5.2 shows that computational complexity grows more than linear in the width of the narrow band. Although the theory predict linear growth, the time spent for evaluating the speed function grows almost quadratic in the bandwidth. 5.3 OPEN ISSUES 55

Table 5.1: Performance measurements of an artificial problem for different grid resolutions. With constant narrow band width of 12 samples, six time steps and one reinitialization process is performed. Grid Compute Compute Marching Closest Point Function Total Resolution Gradient Curvature Cubes Transform Evaluation 3 16 0.05 s 0.34 s 0.02 s 0.13 s 0 s 0.54 s 3 32 0.15 s 0.8 s 0.05 s 0.38 s 0 s 1.38 s 3 64 0.41 s 2.38 s 0.15 s 1.23 s 0.01 s 4.18 s 3 128 1.48 s 8.69 s 0.54 s 4.46 s 0.06 s 15.23 s 3 256 5.92 s 34.72 s 2.24 s 18.87 s 0.29 s 62.04 s Avg Growth 3.3 3.2 3.3 3.5 5.4 3.3 Avg Fraction 9.6% 56.3% 3.6% 30.1% 0.4% 100%

Table 5.2: Performance measurements of an artificial problem for different nar- 3 row band widths. The resolution of the full grid is 64 , six time steps and one reinitialization process is performed Narrow Band Compute Compute Marching Closest Point Function Total Width Gradient Curvature Cubes Transform Evaluation 6 0.18 s 1.04 s 0.07 s 0.59 s 0.01 1.89 s 12 0.41 s 2.38 s 0.15 s 1.23 s 0.01 4.18 s 24 1.13 s 6.65 s 0.39 s 3.8 s 0.05 12.02 s 48 3.78 s 22.92 s 1.29 s 14.18 s 0.19 42.36 s Avg Growth 2.8 2.8 2.7 3.0 3.8 2.9 Avg Fraction 9.1% 54.6% 3.1% 32.8% 0.4% 100%

5.3 Open Issues This section describes some open issues in Levelset Methods that have not been addressed by this diploma thesis. This includes the somehow unappealing reinitialization process that breaks the contiuous flow of the surface evolution and the restriction to closed surfaces.

Reinitialization During the evolution of the interface, the levelset function looses the properties of a distance function if special care is not taken. This has several disadvantages for numerical stability and accuracy in surface reconstruction. Therefore it is preferred to keep the gradient length of the levelset function at least close to unity. To achieve this, the zero level is extracted after a small amount of time steps and a new distance field is built from the reconstructed surface. But repea- ted reconstruction of an explicit surface is offending the idea of implicit interface evolution. Therefore, it would be nice to find a method to rebuild a distance field without reconstructing any explicit surface. The method would have to guarantee that the updated sampled field repre- sents the same isosurface for a specific reconstruction method like Marching Cubes, i.e. the sur- face extracted by a given method would be the same before and after the update. 56 5. RESULTS

Another reason for reinitialization comes up with the narrow band method. When the zero level reaches the edge of the narrow band, the time iteration is stopped and a new narrow band centered around the interface is build. Also this reinitialization process should be avoided because the values of samples that are in the old and the new narrow band are unnecessarily recalculated. And these samples can contribute a considerable part of the overall number of grid points when the surface speed is high at one point in comparison to the average. Thus, it should be tried to come up with a scheme that keeps the narrow band centered around the zero level. Grid points that were further away than the width of the band before a time step but are closer afterwards should be added to the narrow band and grid points that are not within the maximum distance to the surface anymore should be deleted. Together with the preservation of the distance field presented in 2.3.5, this would avoid any reinitialization and keep the Levelset Method at a purely implicit point of view.

Restriction to Closed Surfaces The Levelset Method presented heavily depends on the implicit description of the interface as the zero level of a signed distance function. However, signed distance functions can only be built for orientable surfaces with edges only on the border of the computational domain. This restriction makes the Levelset Method infeasible for a set of important applications. A general method to expand an arbitrary orientable surface to the border of the computational domain or a simple way to restrict the computational domain would be very helpful to apply the Levelset Method to a wider range of applications.

5.4 Future Work

Some Ideas for improvements of the framework were not implemented due to time restric- tions of the diploma thesis. These ideas are presented in this section. and should provide infor- mation on how the framework could be improved.

Closest Point Transform Because scan conversion is a dominant part of rasterization, modern graphic cards are desi- gned to perform well in that task and are much faster than CPUs. Therefore, one can speed up the algorithm by slicing the volume into sample planes and drawing slices of the polyhedrons with OpenGL into each plane. Because pixel buffer read back is rather slow on current consu- mer graphic cards, all polygons of one slice should be drawn concurrently and then read back. The depth buffer is used to perform the minimum test and store the distance values and the sten- cil buffer keeps track of the sign of the distances. In standard OpenGL, depth values are bilinear interpolated between vertices within a polygon. This is not sufficient for this purpose because the distance to vertices and edges are not trilinear functions within the polyhedron. One way to address this problem is to split the polygon up into small triangles [13]. An error estimate for the distances computed can be calculated from the number of subdivisions of a polygon. A different approach to this problem is presented here. SGI introduced OpenGL extensions called depth_texture and shadow, which were approved by the Architecture Review Board for OpenGL 1.3 and are implemented in many current graphic card drivers. The former extension defines a new texture format storing a fragment’s depth value. So far, these textures are only used in conjunction with the latter extension, which compares the texture R coordinate to the depth texture value in order to produce a Boolean texture value. This can be used to implement shadow mapping. Unfortunately, there is currently no extension for writing the depth values stored in a depth texture to the z-buffer. 5.4 FUTURE WORK 57

nVidia’s GeForce3 introduced high-level texture shaders, providing a superset of conventio- nal OpenGL texture addressing. nVidia’s current OpenGL drivers for both Linux and Windows implement third generation texture shaders. This version includes a texture shader operation called GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV. Like the name says, this feature makes it possible to replace the z-buffer’s values with a fragment’s depth value computed from a texture. A single radial depth texture used for all polygons and linear texture coordinate inter- polation along the edges of the polyhedron is enough to achieve correct values in the depth buffer with 32bit precision. Such an implementation would substantially speed up the computations of the Closest Point Transform because graphic cards work in parallel to the main CPU. Also, they are designed to quickly perform the tasks needed for this algorithm, i.e. polygon rasterization, table lookup and interpolation, finding minimums over a set of values.

Dual Marching Cubes So far, Marching Cubes is used in the framework for extracting isosurfaces from the distance field. To extract the zero level surface, a vertex is placed on edges where one end’s value has a different sign than the other end’s value. An isosurface is build independently for each cube defined by eight neighboring samples. To do so, vertices on the edge of a cube are connected with triangles separating corner values of different signs. Instead of placing the vertices on the edges and the triangles into the cubes, the dual algorithm called SurfaceNets [9] places the ver- tices into the cube and connects them with triangles intersecting one edge. This results in more uniformly sized triangles and therefore more details can be represented by the same amount of triangles. The algorithm performs in four steps. • Identify the cubes containing a node. These are all cubes where corner values are either all smaller or all greater than the isovalue. • Create links between nodes of adjacent cells. • Relax node positions to achieve better smoothness. Information from the distance field can be used to enhance the accuracy of the extracted surface [5]. • Triangulate the vertices. Of all twelve possible triangles intersecting an edge of the cube, only six are considered to avoid redundancy.

Preserve Distance Function The implicit function describing the isosurface is initialized to hold the Eikonal equation (2.27). A mathematical theory was presented in 2.3.5 to preserve this property as the levelset function evolves under the partial differential equation (PDE). It should be investigated how far this theory is feasible for a numerical implementation. Even if the distance field can only be pre- served within a numerical accuracy, the number of expensive reinitializations could be reduced.

Higher Order Schemes The theory of hyperbolic conservation laws leads to mathematical toolkit to come up with a number of numerical schemes of different order of accuracy for this problem. So far, only low order schemes were implemented in the framework. Higher order schemes like ENO and WENO should also be tested. Although Levelset Methods in the field of geometric modeling are used to calculate a steady state and not to simulate a physical system, higher accuracy would help to reduce the numerical error when preserving a distance field. 58 5. RESULTS

Volume Rendering

Today’s consumer graphics cards support three-dimensional textures and make volume ren- dering possible on modern personal computers. Christian Sigg implemented a volume renderer with real time transfer function editing and phong shading model that could be incorporated into the framework. Visualization of translucent distance ranges and shaded isosurfaces that can interactively be changed are useful to examine scalar fields and understand their evolution. At the current state, the volume renderer is available for Windows only and the distance field has to be exported from the framework and visualized in a separate program.

The density values are stored in a OpenGL volume texture together with the gradient length and the orientation of the gradient spherical coordinates. The transfer function is incorporated into a separate texture hence the volume data, which uses 64MB of texture memory, does not have to be transferred over the AGP bus again when the transfer function is changed. The trans- fer function defines the opacity of a sample dependent on the density and the gradient length.

opacity= f() u ⋅ gu()∇ (5.6)

The colors and opacities of several materials are combined into one transfer texture. During texture fetch, the RGBA value of a sample is determined with a dependent texture lookup from the volume texture into the transfer texture. A second dependent texture is used to lookup the gradient in three-dimensional coordinates from the spherical coordinates stored in the volume texture. A phong shading is then performed with register combiners of the graphic card.

Figure 5.5: Phong shaded volume rendering of the distance field of the knot, sampled on a grid with resolution 2563. The transfer function defined on the right and the viewpoint can be altered in real-time. 5.4 FUTURE WORK 59

Windows Port For the next version of the levelset framework, it is planned to write portable code that can be compiled under both Linux and Windows. Because Microsoft’s Visual C++ compiler still does not support full ANSI standards, not all libraries currently used in the framework could be used for a portable version. The limitations of the GLUI library will restrict possible extensions of the user interface. It is therefore planned to switch to the Qt library. 60 5. RESULTS A

ACode Usage

A.1 Development Environment The framework for the Levelset Method is implemented under Linux with GNU C++ version 3. Because template features are extensively used, older versions of GNU C++ and Visual C++ cannot compile the code. The KDevelop integrated development environment provides a set of applications and wraps the functionality of third party tools used when developing an application. • Text Editor - with syntax highliting and auto completion. • File Management - add and remove files from the project, choose files from a tree view. • Debugger - integrated debugger, displaying the source • Compiler and Linker - wraps GNU C++ 3. • Configuration and Makefile Generation - wraps Autoconf and Automake. • Documentation - wraps Doxygen. KDevelop is not necessary to compile the code because script files are automatically gene- rated.

A.2 Libraries The libraries used in the framework include the following. • OpenGL [www.opengl.org] - a cross-platform standard for 3D rendering and 3D hard- ware acceleration . • GLUT [www.pobox.com/~nate/glut.html] - a window system independent toolkit for writing OpenGL programs. • GLUI [www.cs.unc.edu/~rademach/glui] - a GLUT-based C++ user interface library that provides controls such as buttons, checkboxes, radio buttons, and spinners to OpenGL applications. • Blitz++ [www.oonumerics.org/blitz] - a C++ class library for scientific computing using template techniques to achieve high performance. • CPT [www.its.caltech.edu/~sean/] - a library computing the closest point transform for triangular meshes.

61 62 A. CODE USAGE

A.3 Configuration File A configuration file defines several parameters of the program to avoid frequent recompila- tion. A sample configuration file describes the options available. // triangle mesh file to load by default tmfile = duck // point cloud file to load by default pcfile = knot

// raster resolution raster { // number of samples is 2 ^ (3*depth) depth = 6 }

// default PDE formula PDE { // mean-gaussian-curvature flow formula = -sign(H)*sqrt(K+abs(K)) }

// renderer options renderer { // width and hight of the renderer window windowsize = 512 // initial rotation matrices of the object and the light rotateobj = (.9,.1,-.4,0,0,.9,.4,0,.5,-.4,0.8,0,0,0,0,1) rotatelight = (1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1) }

// files section files { // identifier used in the program bunny { // type of the file type = off // relative path to the file file = ./data/bunny.off // bounding box of the object bbmin = (-0.12,0.01,-0.08) bbmax = (0.08,0.2,0.07) } }

A.4 Triangular Mesh Files The triangular meshes are loaded and stored in a ASCII file, complying with the simple “off” or “tria” format. The file format starts with a header consisting of three lines. The first line con- tains the number 4. The second and the third line hold the number of vertices nv and triangles nt as an integer, respectively. Following are the nv lines of vertices (each consists of three floats). The rest of the file consists of nt lines of triples of vertex indices, each defining a trian- gle. The index of the vertices starts at zero. A.5 CLASSES 63

A.5 Classes The following list consists of vital classes written for the framework. A short description of the functionality and a few members are given for a rough understanding of the code structure.

Config Configuration file reader. This class reads in program configurations from a file. The format for a variable in the con- figuration file is “var = value“. A directory structure can be built by using sets “set {}“. The class only supports reading of the configuration.

Renderer OpenGL window to visualize display lists. This class provides an OpenGL display list viewer. Object can be rotated and panned with a GLUI user interface displayed at the bottom of the window.

Expression Expression Evaluating Class. This class takes a string expression and compiles it to machine code. The expression can then be evaluated with variable substitution. This is used for the speed function. The class supports binary addition, subtraction, multiplication, division, unary minus, parenthesis, abs(), sin(), cos(), sqrt(), pi and user supplied C functions.

Octree Templated Octree Class. This class defines the data container for the rasterband class. It is an octree with all leafes at a fixed level. Every node stores minimum and maximum values of its children. The are linked in all basis directions and stored in a vector. The data type has to offer the range of that data element, which can be the position or the distance value, for example. const Value& getMin/getMax() The value type has to offer compare operators and numeric_limits. For vectors, this should be per element. The compare operator has to define a strict weak ordering and therefore “xmin/max() std::min/max(Value, Value) bool operator

RasterBand 3D sparse uniform sampled data cube. This is the core class of the framework, containing the numerical schemes, the Marching Cubes algorithm and the visualization of the distance field.

TriaMesh Triangular mesh. Gouraud shaded triangular mesh. Can be loaded from and saved to the “off” file format. Con- tains the link to the Closest Point Transform library. A very simple routine computing signed distance fields is available as fallback when the library does not produce accurate results. 64 A. CODE USAGE

GlCpt OpenGL implementation of the Closest Point Transform. This class is not finished yet. It contains an implementation of Closest Point Transform using graphic hardware and OpenGL. The algorithm calculates a signed distance field on a uniform mesh from a closed triangulated mesh. B

BReferences

[1] D. Chopp. “Computing Minimal Surfaces via Level Set Curvature Flow.” Journal of Computational Physics, 106(1):77–91, May 1993.

[2] D. Chopp and J.A.Sethian. Interfaces and Free Boundaries, chapter Motion by Intrinsic Laplacian of Curvature, pages 107–123. Oxford University Press, 1999.

[3] L. Cohen and R. Kimmel. “Finding global minimum for active contours using levelset approach.” In Proceedings of IEEE ICIP. IEEE, 1996.

[4] L. Corrias, M. Falcone, and R. .Natalini. “Numerical Schemes for Conservation Laws via Hamilton-Jacobi Equations.” Mathematics of Compuation, 64:555–580, 1995.

[5] P. de Bruin, F. Vos, F. Post, S. Frisken-Gibson, and A. Vossepoel. “Improving Triangle Mesh Quality with SurfaceNets.” In S. Delp, A. DiGioia, and B. Jaramaz, editors, Medi- cal Image Computing and Computer-Assisted Intervention - MICCAI 2000, Proceedings, Third International Conference, Pittsburgh, PA, USA, Lecture Notes in Computer Sci- ence, pages 804–813. Springer-Verlag, October 2000.

[6] D. Enright, R. Fedkiw, J. Ferzinger, and I. Mitchell. “A Hybrid Particle Level Set Method for Improved Interface Capturing.” 2002.

[7] D. Enright, S. Marschner, and R. Fedkiw. “Animation and Rendering of Complex Water Surfaces.” In Proceedings of ACM SIGGRAPH 2002, pages 736–744. ACM, ACM SIG- GRAPH, July 2002.

[8] L. Evans. Partial Differential Equations. Graduate studies in mathematics. American Mathematical Society, Providence, Rhode Island, isbn 0-8218-0772-2 edition, 1998.

[9] S. Frisken. “Constrained Elastic SurfaceNets: Generating Smooth Models from Binary Segmented Data.” In Lecture Notes in Computer Science, International Conference on Medical Image Computing and Computer-Assisted Intervention, pages 888–898. Sprin- ger, October 1998.

[10] S. Godunov. “Finite difference methods for numerical computation of discontinuou solu- tions of the equations of fluid dynamics.” Mat. Sbornik, 47:271–295, 1959. (Russian).

65 66 B. REFERENCES

[11] J. Gomes and O. Faugeras. “Reconciling Distance Functions and Level Sets.” Journal of Visual Communication and Image Representation, 11:209–223, 2000. [12] M. Grayson. “The Heat Equation Shrinks Embedded Plane Curves to Round Points.” Jounal of Differential Geometry, 26:285, 1987. [13] K. Hoff, T. Culver, J. Keyser, M. Lin, and D. Manocha. “Fast Computation of Generali- zed Voronoi Diagrams using Graphics Hardware.” Computer Graphics, 33(Annual Con- ference Series):277–286, 1999. http://www.cs.unc.edu/ geom/voronoi/. [14] G. Huisken. “Flow by Mean Curvature of Convex Shapes into Spheres.” Journal of Dif- ferential Geometry, 20:237, 1984. [15] S. Kim. “Edge-Preserving Noise Removal, Part I: Second-Order Anisotropic Diffusion.” http://www.ms.uky.edu/ skim/, 2001. [16] R. Kimmel and J. Sethian. “Computing geodesic paths on manifolds.” Proceedings of the National Academy of Sciences, 95(15):8431–8435, July 1998. [17] C. Lin and E. Tadmor. “High Resolution Nonoscillatory Central Schemes for Hamilto- nian-Jacobi Equations.” SIAM J. SCI Comput., 21(6):2163–2186, 2000. [18] W. Lorensen and H. Cline. “Marching Cubes: A High Resolution 3D Surface Construc- tion Algorithm.” In Proceedings of ACM SIGGRAPH 2002, pages 163–169. ACM, ACM SIGGRAPH, 1987. [19] R. Malladi and J. Sethian. “Image Processing via Level Set Curvature Flow.” Procee- dings of the National Academy of Sciences, 92(15):7046–7050, 1995. [20] R. Malladi, J. Sethian, and B. Vemuri. “Evolutionary Fronts for Topology-independent Shape Modeling and Recovery.” In ECCV (1), volume 800 of Lecture Notes in Computer Science, pages 158–175. Springer, 1994. [21] S. Mauch. “A Fast Algorithm for Computing the Closest Point and Distance Transform.” http://www.its.caltech.edu/~sean/, 2000. [22] K. Museth, D. Breen, R. Whitaker, and A. Barr. “Level Set Surface Editing Operators.” In SIGGRAPH 2002 Conference Proceedings, pages 330–338. ACM Transactions on Graphics, July 2002. [23] P. Neskovix and B.B.Kimia. “Three-Dimensional Shape Representation from Curvature Dependent Surface Evolution.” In 1st Conference on Image Processing, pages 6–10. IEEE, 1994. [24] D. Nguyen. “Physically Based Modeling and Animation of Fire.” In Proceedings of ACM SIGGRAPH 2002, pages 721–728. ACM, ACM SIGGRAPH, July 2002. [25] S. Osher and J. Sethian. “Fronts Propagation with Curvature-Dependent Speed: Algo- rithms based on Hamilton-Jacobi Formulations.” Jounal of Computational Physics, 79:12–49, 1998. [26] V. Oliker. “Evolution of Non-parametric Surfaces with Speed Depending on Curvature.” Indiana University Mathematics Journal, 40(1):237–258, 1991. [27] P. Roe. “Approximate Riemann Solvers, Parameter Vectors, and Differencing schemes.” Jounal of Computational Physics, 43:357–372, 1981. 67

[28] E. Rouy and A. Tourin. “A viscosity approach to shape-from-shading.” SIAM Jounal on Numerical Analysis, 29:867–884, 1992. [29] J. Sethian. An Analysis of Flame Propagation. PhD thesis, Department of Mathematics, University of California, Berkeley, CA, 1982. [30] J. Sethian. “Curvature Flow and Entropy Conditions Applied to Grid Generation.” Jour- nal of Computational Physics, 115:440–454, 1994. [31] J. Sethian. “A Fast Marching Level Set Method for Monotonically Advancing Fronts.” Proceedings of the National Academy of Sciences of the United States of America, 93(4):1591–1595, 1996. [32] J. Sethian. Level Set Methods and Fast Marching Methods: Evolving Interfaces in Com- putational Geometry, Fluid Mechanics, Computer Vision and Material Science. Cam- bridge University Press, 2nd edition, November 1998. [33] SGI. “Standard Template Library Programmer’s Guide.” http://www.sgi.com/tech/stl. [34] H. Wenzel. “Turbulent Premixed Combustion in the Laminar Flamelet and the Thin Reaction Zone Regime.” Annual research briefs, Center for Turbulence Research, 1997. [35] H. Zhao, S. Osher, and M. Kang. “Implicit and non-parametric shape reconstruction from unorganized points using variational level set method.” Computer Vision and Image Understanding, 80(3):295–319, 2000.