computes the watershed transform of image, returning the result as an array in which positive integers label the catchment basins.


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:
  • CornerNeighborsAutomaticwhether to include corner neighbors
    MethodAutomaticthe 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.


open all close all

Basic Examples  (2)

Watershed segmentation of an image with two regional minima:

Click for copyable input

Visualize the segmentation:

Click for copyable input

Watershed segmentation of a 3D image:

Click for copyable input

Scope  (3)

Options  (3)

Applications  (8)

Properties & Relations  (2)

Possible Issues  (1)

Neat Examples  (1)

Introduced in 2010
Updated in 2014