Waterfall
Include <mln/morpho/waterfall.hpp>
-
template<typename I, typename N>
auto waterfall(I ima, N nbh) Implementation of the Waterfall algorithm [B94] described in [M15]. The Waterfall is an iterative process starting from a watershed segmentation and removing the watershed lines surrounded by watershed lines whose gradient is bigger. The resulting of the last iteration is the complete image domain.
- Parameters:
ima – The input image
nbh – The neighborhood relationship considered to build the watershed segmentation
- Returns:
A pair (tree, node_map) where tree is the hierarchical representation of the Waterfall and node_map is a mapping from a point of the image to a node of the tree. This node map is usually the initial watershed segmentation.
References
Beucher, S. (1994). Watershed, hierarchical segmentation and waterfall algorithm. In Mathematical morphology and its applications to image processing (pp. 69-76). Springer, Dordrecht.
Meyer, F. (2015, May). The waterfall hierarchy on weighted graphs. In International Symposium on Mathematical Morphology and Its Applications to Signal and Image Processing (pp. 325-336). Springer, Cham.
Example
// (1) Get an image
mln::image2d<std::uint8_t> input = ...;
// (2) Compute the gradient (here using the morphological gradient)
auto grad = mln::morpho::gradient(input, mln::se::disc(3));
// (3) Compute the waterfall hierarchy
auto [t, nodemap] = mln::morpho::waterfall(grad, mln::c8);
// (4) Compute the cut at level 4
t.horizontal_cut(4, nodemap);
Original image |
Watershed segmentation on the gradient of the original image |
Waterfall horizontal cut at level 4 |
-
template<typename I, typename S, typename N>
auto waterfall_from_markers(I ima, S seeds, N nbh) Implementation of the waterfall from user defined markers (instead of local minima in the previous implementation).
- Parameters:
ima – The input image
seeds – Image of markers
nbh – The neighborhood relationship considered to build the watershed segmentation
- Returns:
A pair (tree, node_map) where tree is the hierarchical representation of the Waterfall and node_map is a mapping from a point of the image to a node of the tree. This node map is usually the initial watershed segmentation.
// (1) Get an image
mln::image2d<std::uint8_t> input = ...;
// (2) Get the image of markers
mln::image2d<std::uint8_t> markers = ...;
// (3) Compute the gradient (here using the morphological gradient)
auto grad = mln::morpho::gradient(input, mln::se::disc(3));
// (4) Compute the waterfall hierarchy
auto [t, nodemap] = mln::morpho::waterfall_from_markers(grad, markers, mln::c8);
// (5) Compute the cut at level 4
t.horizontal_cut(4, nodemap);
Original image |
Markers image |
Watershed from markers |
Waterfall horizontal cut at level 1 |