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:
  • markerimagea 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 Automaticwhether to include corner neighbors
    Method Automaticthe 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 (VincentSoille)
    {"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 all

Basic Examples  (2)

Watershed segmentation of an image with two regional minima:

Visualize the segmentation:

Watershed segmentation of a 3D image:

Scope  (3)

Mark two regions with a marker image:

Mark two regions with a list of positions:

Mark 3D regions and background with a binary mask:

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":

Method  (1)

Use a minimum saliency method to segment tiles in an image:

Lower saliency thresholds typically yield over-segmented results:

Use higher saliency thresholds to merge similar neighboring components:

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:

Heart chamber segmentation:

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)

Typically, images do not have one regional minimum per component:

Watershed segmentation is conceptually using regional minima as markers:

Computing watershed on the gradient image typically gives a more desired segmentation:

Neat Examples  (1)

Solve a maze puzzle using watershed transform:

Wolfram Research (2010), WatershedComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/WatershedComponents.html (updated 2014).

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

BibTeX

@misc{reference.wolfram_2024_watershedcomponents, author="Wolfram Research", title="{WatershedComponents}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/WatershedComponents.html}", note=[Accessed: 30-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_watershedcomponents, organization={Wolfram Research}, title={WatershedComponents}, year={2014}, url={https://reference.wolfram.com/language/ref/WatershedComponents.html}, note=[Accessed: 30-December-2024 ]}