Watershed algorithms. The watershed algorithm segments and labels an image
using an analogy to a landscape. The image intensities are turned into
the z-height of the landscape and the landscape is "filled with water"
and the bodies of water label the landscape's pixels. Here is the
reference for the original paper:
Lee Vincent, Pierre Soille, Watersheds in digital spaces: An efficient
algorithm based on immersion simulations, IEEE Trans. Pattern Anal.
Machine Intell., 13(6) 583-598 (1991)
Watersheds are often performed on the gradient of an intensity image
or one where the edges of the object boundaries have been enhanced.
The resulting image has a depressed object interior and a ridge which
constrains the watershed boundary.
The seeded watershed uses a pre-existing labeling of the space where
the labels act as seeds for the output watershed. The analogy would
be to use dyed liquids emanating from the seeded pixels, flowing to the
local minima and then filling individual watersheds until the
liquids meet at the boundaries.
This implementation breaks ties by assigning the pixel to the
label that occupied an adjacent pixel first.
T - - the image type, typically real or integer. Technically
complex is supported but only the real part is used.
L - - the labeling type, typically Integer for machine-coded
seeds or possibly String for human labeled seeds.
image - - the intensity image that defines the watershed
landscape. Lower values will be labeled first.
seeds - - a labeling of the space, defining the first pixels
in the space to be labeled. The seeded pixels will be similarly labeled
in the output as will be their watershed neighbors.
structuringElement - - an array of offsets where each element
of the array gives the offset of a connected pixel from a pixel of
interest. You can use AllConnectedComponents.getStructuringElement
to get an 8-connected (or N-dimensional equivalent) structuring
element (all adjacent pixels + diagonals).
output - - a similarly-sized, but initially unlabeled labeling