I've moved!
I've started a new position at the University of Texas Health Science Center-Houston as an assistant professor in the School of Health Information Sciences. Please visit my new webpage:
http://biomathematics.shis.uth.tmc.edu
Thank you! -- Paul (September 7, 2007)
Software: BMPtoLevelSet
About
BMPtoLevelSet is an open-source (GPL) utility to convert an Windows bitmap (BMP) image to a level set function on a Cartesian grid. Using this software, you can create more interesting initial shapes for scientific computations, import shapes from medical images, use photos of bubbles to start multiphase simulations, etc. The software could be used to create initial conditions that match physical experiments, which should aid in validating mathematical models and numerical techniques.
On the left, we see a typical starting image. On the right, we see a contour plot of the resulting level set function. (Contour plot courtesy ContourGL.)
BMPtoLevelSet is written in C++ and was designed to be cross-platform compatible; it should compile and work on Mac OSX and Linux just fine. A Windows binary (exe) file is included.
Downloading BMPtoLevelSet
BMPtoLevelSet requires the following libraries:
- EasyBMP library
- SimpleArray add-on from the EasyBMP library.
Click here to download the most recent version of BMPtoLevelSet (Version 0.25).
What's New in Version 0.25
Version 0.25 is the first release. It provides basic functionality to import a bitmap (BMP) file and output a level set data file. The output uses Δx = Δy =1; you can easily change this to a different value by multiplying the output data by the desired value of Δx.
How it Works
BMPtoLevelSet first imports the image, converts it to greyscale, and maps the range [0,255] to [-1,1]. Thus, the zero contour corresponds to where pixels of value 127.5 were. On an image that was originally black and white, this would be halfway between black and white pixels.
Next, BMPtoLevelSet finds the set S of points on the zero contour using linear interpolation. Then, BMPtoLevelSet currently produces a first approximation of the level set φ by calculating the distance to S at each point on the Cartesian grid. This gives a signed distance function to S, but not to the entire zero contour. This is where Version 0.25 stops.
The next step is to apply a reinitialization scheme to φ to obtain a signed distance function to the actual zero contour. In past work, I've used a TVD-Runge Kutta / WENO scheme to update the PDE
φt + (|grad(φ)|-1)grad(φ) = 0
to steady-state.
However, I'm going to use this opportunity to try high-order fast sweeping methods, which should be computationally faster, accurate, and hopefully more robust near places where the level set function has discontinuous derivatives.
How to Use It
Using BMPtoLevelSet is simple:
C:\BMPtoLevelSet input.bmp output.dat
The level set function will be stored in output.dat in a tab-delimited, ASCII format. For best results, the shape you intend to use should be drawn in black.