This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

WatershedComponents

WatershedComponents[image]
computes the watershed transform of image, returning the result as a matrix in which positive integers label the catchment basins.
WatershedComponents
uses a binary image marker to indicate regions where basins may be created.
  • WatershedComponents finds basins only at the positions corresponding to foreground regions in a binary image marker.
  • In WatershedComponents, marker can be given either as an image, a graphics object, or a list of points in the standard image coordinate system, where x runs from 0 to width and y runs from 0 to height, and position corresponds to the bottom-left corner of the image.
  • Typically, nonzero elements of marker are treated as seeds for the segmentation.
  • In the label matrix returned by WatershedComponents, zeros represent positions that do not belong to any foreground component.
  • For multichannel images, WatershedComponents operates on the intensity averaged over all channels.
  • The default setting is Method. Possible settings include:
"Watershed"morphological watershed method (Meyer)
"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 and methods return the watershed lines, represented as 0s in the label matrix.
  • With the method, only four direct neighbors are considered adjacent. All other methods treat all eight pixels surrounding a given pixel as adjacent.
Use watershed contours to illustrate the trabecular bone structure:
Watershed segmentation of an image:
Watershed segmentation of a gradient image:
Use watershed contours to illustrate the trabecular bone structure:
In[1]:=
Click for copyable input
Out[1]=
 
Watershed segmentation of an image:
In[1]:=
Click for copyable input
Out[1]=
 
Watershed segmentation of a gradient image:
In[1]:=
Click for copyable input
Out[1]=
Preprocessing the image by filling shallow regional maxima helps reduce over-segmentation:
Use a combination of GradientFilter and FillingTransform to segment an image:
Mark two regions:
Use the rainfall method with markers to segment overlapping blobs:
Use a minimum saliency method to segment tiles in an image:
Binary image created from watershed ridges after removing the background:
Heart chamber segmentation:
Approximate the Voronoi diagram of a set of points:
Over-segmentation can be used in a creative way to finely texture the background in an image:
Solve a maze puzzle using watershed transform:
New in 8