morphsnakes is an implementation of the Morphological Snakes for image segmentation. morphsnakes supports 2D images and 3D volumes.
Morphological Snakes  are a family of methods for image segmentation. Their behavior is similar to that of Active Contours like Geodesic Active Contours  or Active Contours without Edges . However, traditional approaches for Active Contours require solving PDEs over floating points arrays, which is slow and might have numerical stability issues. Instead of PDEs, Morphological Snakes use morphological operators -such as dilation or erosion- over a binary array. This makes Morphological Snakes faster and numerically more stable than their traditional counterparts.
Two Morphological Snakes methods are available in morphsnakes:
- Morphological Geodesic Active Contours, or MorphGAC, implemented in the
- Morphological Active Contours without Edges, or MorphACWE, implemented in
Option 1: Copy
morphsnakes.py to your project
All the required code is contained in
morphsnakes.py. You can
copy this file into your own project with
It is also possible to install morphsnakes with
pip install morphsnakes
examples.py contains multiple examples of MorphGAC
and MorphACWE. You can take any example from that file as a starting point for
What are the differences between MorphGAC and MorphACWE?
MorphACWE works well when pixel values of the inside and the outside regions of the object to segment have different averages. Unlike MorphGAC, MorphACWE does not require that the contours of the object are well defined, and it can work over the original image without any preprocessing.
MorphACWE is much easier to setup and use than MorphGAC, and much more robust to noise. You should try using MorphACWE first, and only switch to MorphGAC when it is clear to you that MorphACWE is not suitable for the kind of images you are working with.
MorphGAC is suitable for images with visible contours, even when these
contours might be noisy, cluttered, or partially unclear. It requires, however,
that the image is preprocessed to highlight the contours. This can be done
using the function
inverse_gaussian_gradient, although you might want
to define your own version. The quality of the MorphGAC segmentation
depends greatly on this preprocessing step.
: A Morphological Approach to Curvature-based Evolution of Curves and Surfaces, Pablo Márquez-Neila, Luis Baumela and Luis Álvarez. In IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI), 2014, DOI 10.1109/TPAMI.2013.106
: Morphological Snakes. Luis Álvarez, Luis Baumela, Pablo Márquez-Neila. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition 2010 (CVPR10).
: Geodesic Active Contours, Vicent Caselles, Ron Kimmel and Guillermo Sapiro. In International Journal of Computer Vision (IJCV), 1997, DOI:10.1023/A:1007979827043
: Active Contours without Edges, Tony Chan and Luminita Vese. In IEEE Transactions on Image Processing, 2001, DOI:10.1109/83.902291