WatershedComponents
WatershedComponents[image]
computes the watershed transform of image, returning the result as an array in which positive integers label the catchment basins.
WatershedComponents[image,marker]
uses a binary image marker to indicate regions where basins may be created.
Details and Options
- WatershedComponents[image] finds basins at each regional minimum in image.
- WatershedComponents works with 2D as well as 3D images.
- WatershedComponents works with binary, grayscale, and multichannel images, operating on the intensity averaged over all channels.
- In the returned label array, zeros represent positions that do not belong to any foreground component.
- WatershedComponents[image,marker] finds basins only at the positions corresponding to foreground regions in a binary image marker.
- The target region marker can be any of the following:
-
markerimage a marker image {pos1,pos2,…} a list of positions - Positions posi are assumed to be in the standard image coordinate system.
- Typically, nonzero elements of marker are treated as seeds for the segmentation.
- The following options can be specified:
-
CornerNeighbors Automatic whether to include corner neighbors Method Automatic the method to use - Possible Method settings include:
-
"Watershed" morphological watershed method (Meyer) (default) "Basins" modified watershed algorithm (Beucher, Meyer) "Rainfall" gradient descent or rainfall algorithm (Osma-Ruiz) "Immersion" watershed immersion algorithm (Vincent–Soille) {"MinimumSaliency",t} gradient descent algorithm that merges adjacent basins if their minimum boundary height is less than t - The "Watershed" and "Immersion" methods return the watershed lines, represented as 0s in the label array.
- With the "MinimumSaliency" method, CornerNeighbors->False is always used. All other methods by default use CornerNeighbors->True.
Examples
open allclose allBasic Examples (2)
Scope (3)
Options (3)
CornerNeighbors (2)
By default, diagonally adjacent pixels are considered as neighbors:
Use CornerNeighborsFalse to only consider horizontally and vertically adjacent pixels as neighbors:
CornerNeighbors setting is ignored with Method->"MinimumSaliency":
Applications (8)
Separate overlapping components using the distance transform image:
Visualize the separation of the overlapping components:
Use watershed segmentation to separate overlapping 3D components:
Compute distance transform of the volume:
Run watershed segmentation on the distance transform of a 3D volume and visualize the segmentation:
Use 3D markers to enhance the segmentation:
Binary image created from watershed ridges after removing the background:
Use local maxima of smoothed data as markers:
Watershed segmentation using detected marker point:
Preprocessing the image by filling shallow regional maxima helps reduce over-segmentation:
Use a combination of GradientFilter and FillingTransform to segment an image:
Approximate the Voronoi diagram of a set of points:
Compute watershed transform of the distance transform of the image:
Show the boundary of the components (Voronoi diagram) and the initial points:
Over-segmentation can be used in a creative way to finely texture the background in an image:
Properties & Relations (2)
The methods "Basins", "Rainfall", and "MinimumSaliency" assign all pixels to a catchment basin:
The methods "Watershed" and "Immersion" compute watershed lines separating the components:
Use the default method to compute watershed lines separating the components:
Typically, plateau pixels are separated based on their proximity to regional minima:
The method "MinimumSaliency" assigns all plateau pixels to the same component:
Possible Issues (1)
Text
Wolfram Research (2010), WatershedComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/WatershedComponents.html (updated 2014).
CMS
Wolfram Language. 2010. "WatershedComponents." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/WatershedComponents.html.
APA
Wolfram Language. (2010). WatershedComponents. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WatershedComponents.html