In the folder code there is the code I used for this project
In the subfolder code/generator for images or animations are some python scripts that generated animations used in the presentations
The main scripts used are called level set { ... } .py
-
Level set without redistancing.py
propagates a level set without doing redistancing and saves an animation -
Level set with redistancing.py
propagates a level set doing redistancing and saves an animation -
Level set with gradient.py
propagates a level set doing redistancing from an image source. The propagations halts at the edges of the image. Saves an animation -
Level set notebook.ipynb
propagates a level set doing redistancing from an image source. The propagations halts at the edges of the image. Saves an animation. Because is it a jupyter notebook it may be more readable and may be used for an eventual lab -
Colab Level set notebook.ipynb
propagates a level set doing redistancing from an image source. The propagations halts at the edges of the image. Saves an animation. Because is it a jupyter notebook it may be more readable and may be used for an eventual lab. This version is compatible with Google Colab, as it downloads miniconda3 and changes the default runtime environment.
In the folder images there are the images that were generated by various scripts
Level set with gradient video.py
I tried to do in a video, but failed miserably
- Python 3.8
- numpy 1.21.5
- opencv-python-4.5.5.64
- scipy-1.8.0
- skfmm 2022.3.26
- Pillow 9.0.0
- matplotlib 3.5.1
To install these if you don't have run
pip install numpy
pip install python-opencv
pip install cipy
pip install scikit-fmm
pip install Pillow
pip install matplotlib
A level set of a function is a
Usually we are insterested in the zero level set
Here there is a animation of the zero level set of a dynamic curve
They can be used to model dynamic curves with changing topology
The curve moves according to a velocity .
Require to solve a PDE
Approximate solution by finite differences
But finite differences have approxximation errors
The curve degrades after a while due to numerical errors propagating
A solution is to reinitialize the curve every a number of iterations as the signed difference
Computation of this quantity is done through the library skfmm
Other implementations do not require redistancing/reinitialization
For image processing we use a velocity that is 0 or close to zero at the edges
Where is the image, and are the edges according to gradient edge detection
This way we the get contours of the image
https://en.wikipedia.org/wiki/Marching_square https://en.wikipedia.org/wiki/Fast_marching_method https://en.wikipedia.org/wiki/Active_contour_model https://en.wikipedia.org/wiki/Eikonal_equation https://en.wikipedia.org/wiki/Level-set_method https://math.berkeley.edu/~sethian/2006/Explanations/level_set_explain.html https://math.berkeley.edu/~sethian/2006/Papers/sethian.fastmarching.pdf https://math.berkeley.edu/~sethian/Papers/sethian.osher.88.pdf https://math.mit.edu/classes/18.086/2007/levelsetpres.pdf https://math.mit.edu/classes/18.086/2006/am57.pdf https://profs.etsmtl.ca/hlombaert/levelset/ https://www.researchgate.net/publication/290437036_A_level_set_method_using_the_signed_distance_function https://www.sciencedirect.com/science/article/pii/S0021999117307441#br0070 https://agustinus.kristia.de/techblog/2016/11/05/levelset-method/ https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.11083.7076&rep=rep1&type=pdf https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=5557813 https://agustinus.kristia.de/techblog/2016/11/05/levelset-method/