An Overview of Watershed Algorithm Implementations in Open Source Libraries
Abstract
:1. Introduction
2. Main Approaches of Watershed Segmentation
2.1. Watershed by Flooding
- A1
- We find the local minima in the image. Each of them is assigned with a unique marker.
- A2
- We simulate a flooding process that uses a priority queue that consists of H queues, where H is the number of possible image element values (for example, if the gray level varies from 0–255). When it is filled, the elements of the image with the value of h are pushed into the corresponding queue with the number h.
- (a)
- We fill the priority queue with the elements of image local minima.
- (b)
- We scan the priority queue in sequence from smaller values of h to larger ones. Then, we select the element from the first non-empty queue. If all queues from the priority queue are empty, the algorithm terminates.
- (c)
- We remove the selected element from the queue, and its marker propagates on all unmarked neighbors.
- (d)
- We place all the neighbors marked in the previous step into the priority queue. Then, we proceed to Step A2.
- B1
- Similar to Step A1.
- B2
- A similar priority queue is used, as described in Step A2. Furthermore, each element of the image needs to be marked additionally, depending on whether it was already placed into this queue or not (an additional marker).
- (a)
- We mark elements, that already have a unique marker, with an additional marker.
- (b)
- Into the priority queue, we add elements that have marked neighbors. We also mark them with an additional marker.
- (c)
- Similar to Step A2.
- (d)
- We remove the selected element from the queue. If all its marked neighbors were marked with the same marker, we mark the element itself by this marker. If the selected element was a neighbor of elements with different markers, we mark it with a special marker, meaning that it is an element of the watershed.
- (e)
- Neighbors of this element that have not been marked with an additional marker yet are placed into the priority queue. Then, we proceed to Step B2c.
2.2. Watershed by Rain Falling
- C1
- Pass 1. We mark each element of the image with the location of a lower adjacent element, which has the smallest value (usually realized with pointers). If there are no such elements in the neighborhood, then the current one is marked as an element of the plateau.
- C2
- Elimination of non-minimal plateaus.
- (a)
- Pass 2. We check the neighbors for each element that is marked as a plateau. If among them we find one that is not marked as a plateau and has the same value as the element itself, we push this neighbor into the queue and complete the check of the neighbors for this element.
- (b)
- While the queue of neighbors is not empty, we remove the elements from it. We check their neighbors that are marked as a plateau. We mark them with markers pointing to the location of the removed element and push them all into the queue.
- C3
- Pass 3. We mark the minimum plateau elements with representative values.
- (a)
- First, we mark each element that is marked as a plateau with a marker that points on the element itself.
- (b)
- Sequentially, we take the neighbors of the current element, which have already been passed and have the same value.For the current element and this neighbor, we perform a path compression procedure. It consists of traversing the path using markers as motion pointers, from the given element to that marked with a marker pointing to itself, and then assigning to each marker of the path elements the value of the marker of the finite element on it.After these procedures, we mark the end elements of these compressed paths with a minimum value from their markers.
- C4
- Pass 4. We perform the path compression procedure, described in Step C3b, for every image element. We mark elements with finite element markers of the path traversed by the compression procedure. The algorithm terminates.
2.3. Oversegmentation Problem
3. Implementations in Software Libraries
- The maximum difference from all color channels is accepted as a measure of the difference between an element and its neighbors and as a measure of priority in the queue. If there are two elements x and y having the colors and , respectively, the difference is calculated by the following formula:
- The priority queue size is selected according to the maximum possible difference between the color channels.
4. Comparative Estimation
4.1. Test Images
4.2. Description of Measurement Procedure
4.3. Results
5. Discussion
Author Contributions
Funding
Conflicts of Interest
Abbreviations
2D | Two-dimensional |
3D | Three-dimensional |
WL | Watershed lines |
References
- Suetens, P.; Fua, P.; Hanson, A.J. Computational Strategies for Object Recognition. ACM Comput. Surv. 1992, 24, 5–62. [Google Scholar] [CrossRef]
- Bomans, M.; Hohne, K.H.; Tiede, U.; Riemer, M. 3-D segmentation of MR images of the head for 3-D display. IEEE Trans. Med. Imaging 1990, 9, 177–183. [Google Scholar] [CrossRef] [PubMed]
- McAuliffe, M.J.; Lalonde, F.M.; McGarry, D.; Gandler, W.; Csaky, K.; Trus, B.L. Medical Image Processing, Analysis and Visualization in clinical research. In Proceedings of the 14th IEEE Symposium on Computer-Based Medical Systems, CBMS 2001, 26–27 July 2001; pp. 381–386. [Google Scholar]
- Hsu, W.Y. Segmentation-based compression: New frontiers of telemedicine in telecommunication. Telemat. Inf. 2015, 32, 475–485. [Google Scholar] [CrossRef]
- Natale, F.G.B.D.; Desoli, G.S.; Giusto, D.D.; Vernazza, G. Polynomial approximation and vector quantization: a region-based integration. IEEE Trans. Commun. 1995, 43, 198–206. [Google Scholar] [CrossRef]
- Pham, D.L.; Xu, C.; Prince, J.L. Current Methods in Medical Image Segmentation. Annu. Rev. Biomed. Eng. 2000, 2, 315–337. [Google Scholar] [CrossRef] [PubMed]
- Atta-Fosu, T.; Guo, W.; Jeter, D.; Mizutani, C.M.; Stopczynski, N.; Sousa-Neves, R. 3D Clumped Cell Segmentation Using Curvature Based Seeded Watershed. J. Imaging 2016, 2, 31. [Google Scholar] [CrossRef] [PubMed]
- Waggoner, J.; Zhou, Y.; Simmons, J.; Graef, M.D.; Wang, S. 3D Materials Image Segmentation by 2D Propagation: A Graph-Cut Approach Considering Homomorphism. IEEE Trans. Image Process. 2013, 22, 5282–5293. [Google Scholar] [CrossRef] [PubMed]
- Myasnikov, E.V. Hyperspectral image segmentation using dimensionality reduction and classical segmentation approaches. Comput. Opt. 2017, 41, 564–572. [Google Scholar] [CrossRef]
- Serra, J. Image Analysis and Mathematical Morphology; Academic Press: New York, NY, USA, 1982. [Google Scholar]
- Digabel, H.; Lantuéjoul, C. Iterative algorithms. In Actes du Second Symposium Européen d’Analyse Quantitative des Microstructures en Sciences des Matériaux, Biologie et Médecine, Caen, 4–7 October 1977; Chermant, J.L., Ed.; Dr. Riederer: Stuttgart, Germany, 1978; pp. 85–99. [Google Scholar]
- Lantuéjoul, C. La Squelettisation et son Application aux Mesures Topologiques des Mosaques Polycristallines. Ph.D. Thesis, Ecole des Mines, Paris, France, 1978. [Google Scholar]
- Beucher, S.; Lantuéjoul, C. Use of Watersheds in Contour Detection. In Proceedings of the International Workshop on Image Processing: Real-time Edge and Motion Detection/Estimation, Rennes, France, January 1979; Volume 132. [Google Scholar]
- Meijster, A.; Roerdink, J.B.T.M. A proposal for the implementation of a parallel watershed algorithm. In Computer Analysis of Images and Patterns: 6th International Conference, CAIP ’95 Prague, Czech Republic, September 6–8, 1995 Proceedings; Hlaváč, V., Šára, R., Eds.; Springer: Berlin/Heidelberg, Germany, 1995; pp. 790–795. [Google Scholar]
- Vincent, L.; Soille, P. Watersheds in digital spaces: An efficient algorithm based on immersion simulations. IEEE Trans. Patt. Anal. Mach. Intell. 1991, 13, 583–598. [Google Scholar] [CrossRef]
- De Smet, P.; Pires, R. Implementation and analysis of an optimized rainfalling watershed algorithm. In Proceedings of the SPIE, VCIP’2000, San Jose, CA, USA, 19 April 2000; Volume 3974, pp. 759–766. [Google Scholar]
- Meyer, F. Topographic distance and watershed lines. Signal Process. 1994, 38, 113–125. [Google Scholar] [CrossRef]
- Beare, R.; Chen, J.; Adamson, C.L.; Silk, T.; Thompson, D.K.; Yang, J.Y.M.; Anderson, V.A.; Seal, M.L.; Wood, A.G. Brain extraction using the watershed transform from markers. Front. Neuroinf. 2013, 7, 1–15. [Google Scholar] [CrossRef] [PubMed]
- Atwood, R.; Jones, J.; Lee, P.; Hench, L. Analysis of pore interconnectivity in bioactive glass foams using X-ray microtomography. Scr. Mater. 2004, 51, 1029–1033. [Google Scholar] [CrossRef]
- Wong, C.F.; Yeo, J.Y.; Gan, S.K.E. APD Colony Counter App: Using Watershed algorithm for improved colony counting. Nat. Methods Appl. Notes 2016, 1–3. [Google Scholar] [CrossRef]
- Herusutopo, A.; Bisono, R.W.; Meliala, J.I. Application Of Malaria Detection Of Drawing Blood Cells Using Microscopic Opencv. Commun. Inf. Technol. J. 2011, 5, 65–73. [Google Scholar] [CrossRef]
- Funke, J.; Tschopp, F.; Grisaitis, W.; Sheridan, A.; Singh, C.; Saalfeld, S.; Turaga, S.C. A Deep Structured Learning Approach Towards Automating Connectome Reconstruction from 3D Electron Micrographs. arXiv, 2017; arXiv:1709.02974. [Google Scholar]
- Mashburn, D.N.; Lynch, H.E.; Ma, X.; Hutson, M.S. Enabling user-guided segmentation and tracking of surface-labeled cells in time-lapse image sets of living tissues. Cytometry A 2012, 81A, 409–418. [Google Scholar] [CrossRef] [PubMed]
- Gostick, J.T. Versatile and efficient pore network extraction method using marker-based watershed segmentation. Phys. Rev. E 2017, 96, 023307. [Google Scholar] [CrossRef] [PubMed]
- Gouillart, E.; Nunez-Iglesias, J.; van der Walt, S. Analyzing microtomography data with Python and the scikit-image library. Adv. Struct. Chem. Imaging 2016, 2, 18. [Google Scholar] [CrossRef] [PubMed]
- Johnson, H.J.; McCormick, M.; Ibáñez, L.; Consortium, T.I.S. The ITK Software Guide, 4th ed.; Kitware, Inc.: New York, NY, USA, 2018. [Google Scholar]
- Bradski, G. The OpenCV Library. Dr. Dobb’s J. Softw. Tools 2000, 122–125. [Google Scholar]
- Coelho, L.P. Mahotas: Open source software for scriptable computer vision. J. Open Res. Softw. 2013, 1, e3. [Google Scholar] [CrossRef]
- Beucher, N.; Beucher, S. Mamba Image User Manual. 2017. Available online: http://mamba-image.org/docs/2.0/mamba-um.pdf (accessed on 28 September 2018).
- Van der Walt, S.; Schönberger, J.L.; Nunez-Iglesias, J.; Boulogne, F.; Warner, J.D.; Yager, N.; Gouillart, E.; Yu, T.; The Scikit-Image Contributors. Scikit-image: Image processing in Python. PeerJ 2014, 2, e453. [Google Scholar] [CrossRef] [PubMed]
- Simple Morphological Image Library. Available online: http://smil.cmm.mines-paristech.fr (accessed on 28 September 2018).
- Rueden, C.T.; Schindelin, J.; Hiner, M.C.; DeZonia, B.E.; Walter, A.E.; Arena, E.T.; Eliceiri, K.W. ImageJ2: ImageJ for the next generation of scientific image data. BMC Bioinform. 2017, 18, 529. [Google Scholar] [CrossRef] [PubMed] [Green Version]
- Legland, D.; Arganda-Carreras, I.; Andrey, P. MorphoLibJ: Integrated library and plugins for mathematical morphology with ImageJ. Bioinformatics 2016, 32, 3532–3534. [Google Scholar] [CrossRef] [PubMed]
- Couprie, M.; Marak, L.; Talbot, H. The pink image processing library. In Proceedings of the Poster European Python Scientific Conference, Austin, TX, USA, 11–16 July 2011. [Google Scholar]
- Beucher, S.; Meyer, F. The morphological approach to segmentation: The watershed transformation. In Mathematical Morphology in Image Processing; Marcel Dekker Inc.: New York, NY, USA, 1993; Volume 34, Chapter 12; pp. 452–464. [Google Scholar]
- Couprie, M.; Bertrand, G. Topological Grayscale Watershed Transformation. In Proceedings of the SPIE Vision Geometry V, San Diego, CA, USA, 27 July–1 August, 20 October 1997; Volume 3168, pp. 136–146. [Google Scholar]
- Safonov, I.V.; Mavrin, G.N.; Kryzhanovsky, K.A. Segmentation of Convex Cells with Partially Undefined Edges. Pattern Recognit. Image Anal. 2008, 18, 112–117. [Google Scholar] [CrossRef]
- Bieniek, A.; Moga, A. An efficient watershed algorithm based on connected components. Pattern Recognit. 2000, 33, 907–916. [Google Scholar] [CrossRef]
- Meyer, F. Un algorithme optimal de ligne de partage des eaux. In Proceedings of the 8th Congress AFCET, Lyon-Villeurbanne, France, 25–20 November 1991; Volume 2, pp. 847–859. [Google Scholar]
- Couprie, C.; Grady, L.; Najman, L.; Talbot, H. Power watersheds: A new image segmentation framework extending graph cuts, random walker and optimal spanning forest. In Proceedings of the 2009 IEEE 12th International Conference on Computer Vision, Kyoto, Japan, 27 September–4 October 2009; pp. 731–738. [Google Scholar]
- Perret, B.; Cousty, J.; Guimarães, S.J.; Maia, D.S. Evaluation of Hierarchical Watersheds. IEEE Trans. Image Process. 2018, 27, 1676–1688. [Google Scholar] [CrossRef] [PubMed] [Green Version]
- Meyer, F. Minimum Spanning Forests for Morphological Segmentation. In Mathematical Morphology and Its Applications to Image Processing; Serra, J., Soille, P., Eds.; Springer: Dordrecht, The Netherlands, 1994; pp. 77–84. [Google Scholar]
- Moga, A.N.; Gabbouj, M. Parallel Marker-Based Image Segmentation with Watershed Transformation. J. Parallel Distrib. Comput. 1998, 51, 27–45. [Google Scholar] [CrossRef] [Green Version]
- Beare, R.; Lehmann, G. The watershed transform in ITK—Discussion and new developments. Insight J. 2006, 6, 1–24. [Google Scholar]
- Beucher, N.; Beucher, S. Hierarchical Queues: General Description and Implementation in MAMBA Image Library; Le Centre pour la Communication Scientifique Directe: Villeurbanne, France, 2011. [Google Scholar]
- Neubert, P.; Protzel, P. Compact Watershed and Preemptive SLIC: On Improving Trade-offs of Superpixel Segmentation Algorithms. In Proceedings of the 2014 22nd International Conference on Pattern Recognition, Stockholm, Sweden, 24–28 August 2014; pp. 996–1001. [Google Scholar]
- Kriegel, H.P.; Schubert, E.; Zimek, A. The (black) art of runtime evaluation: Are we comparing algorithms or implementations? Knowl. Inf. Syst. 2017, 52, 341–378. [Google Scholar] [CrossRef]
- Hendriks, C.L.L. Revisiting priority queues for image analysis. Pattern Recognit. 2010, 43, 3003–3012. [Google Scholar] [CrossRef]
- Barnes, R.; Lehman, C.; Mulla, D. Priority-flood: An optimal depression-filling and watershed-labeling algorithm for digital elevation models. Comput. Geosci. 2014, 62, 117–127. [Google Scholar] [CrossRef] [Green Version]
- Meyer, F. Color image segmentation. In Proceedings of the 1992 International Conference on Image Processing and its Applications, Maastricht, The Netherlands, 7–9 April 1992; pp. 303–306. [Google Scholar]
- Grau, V.; Mewes, A.U.J.; Alcaniz, M.; Kikinis, R.; Warfield, S.K. Improved watershed transform for medical image segmentation using prior information. IEEE Trans. Med. Imaging 2004, 23, 447–458. [Google Scholar] [CrossRef] [PubMed]
- Lotufo, R.; Falcao, A. The Ordered Queue and the Optimality of the Watershed Approaches. In Mathematical Morphology and its Applications to Image and Signal Processing; Goutsias, J., Vincent, L., Bloomberg, D.S., Eds.; Springer: Boston, MA, USA, 2000; pp. 341–350. [Google Scholar]
- Tajima, J. Uniform color scale applications to computer graphics. Comput. Vis. Graphics Image Process. 1983, 21, 305–325. [Google Scholar] [CrossRef]
- USC SIPI—The USC-SIPI Image Database. Available online: http://sipi.usc.edu/database (accessed on 28 September 2018).
- Image Processing in OpenCV—Image Segmentation with Watershed Algorithm. Available online: https://docs.opencv.org/3.4.1/d3/db4/tutorial_py_watershed.html (accessed on 28 September 2018).
- ECE533 Digital Image Processing—Public-Domain Test Images for Homeworks and Projects. Available online: https://homepages.cae.wisc.edu/~ece533/images/ (accessed on 28 September 2018).
- Cline, H.E.; Lorensen, W.; Kikinis, R.; Jolesz, F. Three-Dimensional Segmentation of MR Images of the Head Using Probability and Connectivity. J. Comput. Assist. Tomogr. 1990, 14, 1037–1045. [Google Scholar] [CrossRef] [PubMed]
- Wang, Y.; Lin, C.; Miller, J. Improved 3D image segmentation for X-ray tomographic analysis of packed particle beds. Miner. Eng. 2015, 83, 185–191. [Google Scholar] [CrossRef]
- Videla, A.; Lin, C.L.; Miller, J.D. Watershed Functions Applied to a 3D Image Segmentation Problem for the Analysis of Packed Particle Beds. Part. Part. Syst. Charact. 2006, 23, 237–245. [Google Scholar] [CrossRef]
- Yakimchuk, I.; Safonov, I.; Serkova, E.; Evstefeeva, V.Y.; Korobkov, D. Ceramic Proppant Microstructure Characterization by X-Ray Microtomography. Bruker Micro-CT User Meet. 2018, 1, 17–23. [Google Scholar]
- Moga, A.N.; Viero, T.; Dobrin, B.P.; Gabbouj, M. Implementation of a Distributed Watershed Algorithm. In Mathematical Morphology and Its Applications to Image Processing; Serra, J., Soille, P., Eds.; Springer: Dordrecht, The Netherlands, 1994; pp. 281–288. [Google Scholar]
- Moga, A.N.; Cramariuc, B.; Gabbouj, M. Parallel Watershed Transformation Algorithms for Image Segmentation. Parallel Comput. 1998, 24, 1981–2001. [Google Scholar] [CrossRef]
- Bieniek, A.; Burkhardt, H.; Marschner, H.; Nölle, M.; Schreiber, G. A parallel watershed algorithm. In Proceedings of the 10th Scandinavian Conference on Image Analysis (SCIA’97), Lappenranta, Finland, 9–11 June 1997; pp. 237–244. [Google Scholar]
- Moga, A.N.; Gabbouj, M. Parallel image component labelling with watershed transformation. IEEE Trans. Pattern Anal. Mach. Intell. 1997, 19, 441–450. [Google Scholar] [CrossRef] [Green Version]
- Moga, A.N.; Viero, T.; Gabbouj, M.; Nölle, M.; Schreiber, G.; Burkhardt, H. Parallel watershed algorithm based on sequential scanning. In Proceedings of the IEEE Workshop on Nonlinear Signal and Image Processing, Neos Marmaras, Greece, 20–22 June 1995; pp. 991–994. [Google Scholar]
- Noguet, D. A massively parallel implementation of the watershed based on cellular automata. In Proceedings of the IEEE International Conference on Application-Specific Systems, Architectures and Processors, Zurich, Switzerland, 14–16 July 1997; pp. 42–52. [Google Scholar]
- Meijster, A.; Roerdink, J.B.T.M. Computation of Watersheds Based on Parallel Graph Algorithms. In Mathematical Morphology and Its Applications to Image and Signal Processing; Maragos, P., Schafer, R.W., Butt, M.A., Eds.; Springer: Boston, MA, USA, 1996; pp. 305–312. [Google Scholar]
- Meijster, A.; Roerdink, J.B.T.M. A disjoint set algorithm for the watershed transform. In Proceedings of the 9th European Signal Processing Conference (EUSIPCO 1998), Rhodes, Greece, 8–11 September 1998; pp. 1–4. [Google Scholar]
- Roerdink, J.B.; Meijster, A. The Watershed Transform: Definitions, Algorithms and Parallelization Strategies. Fundam. Inf. 2000, 41, 187–228. [Google Scholar]
Library | Version | Source Code Language | Python Object |
---|---|---|---|
ITK | 4.13.0 | C++ | MorphologicalWatershedFromMarkersImageFilter |
OpenCV | 3.4.1 | C++ | watershed |
Mahotas | 1.4.4 | C++ | cwatershed |
Mamba | 2.0.2 | C | basinSegment, watershedSegment |
Skimage | 0.14 | Cython | morphology.watershed |
SMIL | 0.9 | C++ | basins, watershed |
Library | Image | ||||||
---|---|---|---|---|---|---|---|
2D | 3D | ||||||
Board | Cells | Coins | Fruits | Maze | Avg. | Balls | |
ITK | 201 | 246 | 210 | 214 | 193 | 213 | 630 |
Mahotas | 165 | 237 | 192 | 194 | 161 | 190 | 298 |
Mamba | 49 | 115 | 75 | 75 | 40 | 71 | 160 |
Skimage | 271 | 466 | 305 | 312 | 252 | 321 | 499 |
SMIL | 102 | 163 | 140 | 141 | 116 | 132 | 245 |
Library | Image | ||||||
---|---|---|---|---|---|---|---|
2D | 3D | ||||||
Board | Cells | Coins | Fruits | Maze | Avg. | Balls | |
ITK | 306 | 380 | 328 | 332 | 292 | 328 | 1053 |
Mahotas | 167 | 249 | 195 | 202 | 163 | 195 | 290 |
Mamba | 64 | 141 | 94 | 94 | 57 | 90 | 207 |
Skimage | 1225 | 2740 | 1251 | 1326 | 1439 | 1596 | 8392 |
SMIL | 112 | 182 | 127 | 132 | 140 | 139 | 250 |
OpenCV | 36 | 50 | 34 | 38 | 31 | 38 | — |
© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Share and Cite
Kornilov, A.S.; Safonov, I.V. An Overview of Watershed Algorithm Implementations in Open Source Libraries. J. Imaging 2018, 4, 123. https://doi.org/10.3390/jimaging4100123
Kornilov AS, Safonov IV. An Overview of Watershed Algorithm Implementations in Open Source Libraries. Journal of Imaging. 2018; 4(10):123. https://doi.org/10.3390/jimaging4100123
Chicago/Turabian StyleKornilov, Anton S., and Ilia V. Safonov. 2018. "An Overview of Watershed Algorithm Implementations in Open Source Libraries" Journal of Imaging 4, no. 10: 123. https://doi.org/10.3390/jimaging4100123
APA StyleKornilov, A. S., & Safonov, I. V. (2018). An Overview of Watershed Algorithm Implementations in Open Source Libraries. Journal of Imaging, 4(10), 123. https://doi.org/10.3390/jimaging4100123