
182 Graphs and Images
Local minima
Water level
B1
B2 B3 B4
Function
Watersheds
Figure 12.5: A 1D illustration of the watershed algorithm (top). The
water level is gradually raised from all local minima and whenever two
catchment basins meet, a watershed is found. A 2D illustration of part
of the image from Figure 12.2 as a height function (bottom); one can see
the catchment basins and watersheds.
seed until they reach a ridge or maxima in the function, thus
partitioning the function terrain into regions (watersheds).
Using a priority queue based on the height function, this can
be performed in one loop as follows:
Watershed( Graph G, function h )