Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted...

208
Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math´ ematique Mines-ParisTech 2012 February 29 Fernand MeyerCentre de Morphologie Math´ ematiqueMines-ParisTech () Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 1 / 201 arXi

Transcript of Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted...

Page 1: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Watersheds, waterfalls, on edge or node weighted graphs

Fernand MeyerCentre de Morphologie Mathematique

Mines-ParisTech

2012 February 29

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 1 / 201

arX

iv:1

204.

2837

v1 [

cs.C

V]

12

Apr

201

2

Page 2: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Introduction

The watershed transform is one of the major image segmentation tools [4],used in the community of mathematical morphology and beyond. If thewatershed is a successful concept, there is another side of the coin: anumber of definitions and algorithms coexist, claiming to construct awartershed line or catchment basins, although they obviously are notequivalent. We have presented how the idea was conceptualized andimplemented as algorithms or hardware solutions in a brief note :” Thewatershed concept and its use in segmentation : a brief history”(arXiv:1202.0216v1), which contains an extensive bibliography. See also[25] for an extensive review on the watershed concepts and constructionmodes.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 2 / 201

Page 3: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Introduction

The present work studies the topography of a relief defined on a node oredge weighted graph with morphological tools. The catchment basin of aminimum is defined as the sets of points it is possible to reach by a nondescending path starting from this minimum. The watershed zone, i.e. thepoints linked with two distinct minima through a non ascending path, ismore and more reduced as one considers steeper paths.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 3 / 201

Page 4: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Outline

Reminders on weighted graphs

Distances on node or edge weighted graphs

Adjunctions between nodes and edges

The flooding adjunction.

Invariants of the flooding and closing adjunction

Flooding graph

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 4 / 201

Page 5: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Outline

Paths of steepest descent and k-steep graphs

The scissor operator, minimum spanning forests and watershedpartitions

Lexicographic distances and SKIZ

The waterfall hierarchy.

Emergence and role of the minimum spanning tree

Discussion and conclusion

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 5 / 201

Page 6: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Reminder on adjunctions

The following section contains a reminder on adjunctions linking erosionsand dilations by pairs and from which openings and closings are derived[26],[12],[11]

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 6 / 201

Page 7: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Preamble on adjunctions

Let T a complete totally ordered lattice, and D,E be arbitrary setsO : the smallest element and Ω : the largest element of TFun(D,T ) : the image defined on the support D with value in TFun(E ,T ) : the image defined on the support E with value in T

Let f be a function of Fun(D,T ) and g be a function of Fun(E ,T )α : Fun(D,T )→ Fun(E ,T ) andβ : Fun(E ,T )→ Fun(D,T ) be two operators

Definition

α and β form an adjunction if and only if :for any f in Fun(D,T ) and g in Fun(E ,T ) : αf < g ⇔ f < βg

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 7 / 201

Page 8: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Erosions and dilations

Theorem

If (α, β) form an adjunction, then α is a dilation (it commutes with thesupremum of functions in Fun(D,T ) )and β is an erosion (it commutes with the infimum of functions inFun(E ,T ) )

Proof: Let f be a function of Fun(D,T ) and (g)i functions of Fun(E ,T )Thenf < β

∧i

gi ⇔ αf <∧i

gi ⇔ ∀i : αf < gi ⇔ ∀i : f < βgi ⇔ f <∧i

βgi

Reading these equivalences from left to right and replacing f by β∧i

gi

implies that β∧i

gi <∧i

βgi .

Reading these equivalences from right to left and replacing f by∧i

βgi

implies that∧i

βgi < β∧i

gi

establishing that β∧i

gi =∧i

βgi .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 8 / 201

Page 9: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Erosions and dilations (2)

Similarly we show that δ is a dilation, i.e. commutes with the union.Remark: Calling O a constant function equal to O, we have for any f :O < βf implying αO < f . This relation is true for all f , indicating thatαO = O.Similarly, we show that βΩ = Ω, where Ω is the constant function equalto Ω.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 9 / 201

Page 10: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Increasing operators

Lemma

α and β are increasing operators.

Proof.

If f < g then β(f ∧ g) = β(f ) = β(f ) ∧ β(g) < β(g)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 10 / 201

Page 11: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

From one operator to the other

From the relation αf < g ⇔ f < βg one derives expressions of oneoperator in terms of the other one.If α is known, β may be expressed as βg =

∨f | αf < g .

Inversely if β is known, then αf =∧g | f < βg

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 11 / 201

Page 12: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Opening and closing

Lemma

The operator βα is a closing : increasing, extensive and idempotent.Similarly the operator αβ is an opening : increasing, anti-extensive andidempotent.

Proof: Openings and closings, obtained by composition of increasingoperators, are increasing.By adjunction we obtain αf < αf ⇒ f < βαf showing that the closing isextensive and αβf < f ⇐= βf < βf showing that the opening isanti-extensive.In particular, applying an opening to αf yields αf > αβαf .On the other hand, α being increasing, and the closing extensive :f < βαf ⇒ αf < αβαf showing that αf = αβαfApplying β on both sides yields βαf = βαβαf

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 12 / 201

Page 13: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The family of invariants of an opening or a closing

We call Inv(γ) and Inv(ϕ) the family of invariants of γ and ϕ.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 13 / 201

Page 14: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The family of invariants of an opening

Lemma

The family of invariants of an opening is closed by union. And the familyof closings is closed by intersection.

Proof: Let us prove it for openings ; the result for closings being obtainedby duality. Suppose that g1 and g2 are invariant by the opening γ :γ(g1) = g1 and γ(g2) = g2.Then γ(g1 ∨ g2) ≤ g1 ∨ g2 = γ(g1) ∨ γ(g2) by antiextensivityAnd γ(g1 ∨ g2) ≥ γ(g1) ∨ γ(g2) as γ is increasing.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 14 / 201

Page 15: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Invariants of an opening or a closing

αf ∈ Inv(γ) as αf = αβαf = (αβ)αf

βf ∈ Inv(ϕ) as βf = βαβf = (βα)βf

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 15 / 201

Page 16: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The opening as pseudo-inverse operator of the erosion

* The erosion has no inverse as αβg ≤ g .

* The opening is the pseudo inverse of the erosion : αβg is the smallestset having the same erosion as g .

Proof : Suppose that f verifies βf = βg which implies αβf = αβg . Iff ≤ αβg , we have αβf ≤ f ≤ αβg showing that f = αβg

* if If g ∈ Inv(γ), we have γg = αβg = g : on Inv(γ), α = β−1

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 16 / 201

Page 17: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The closing as pseudo-inverse operator of the dilation

* The dilation has no inverse as βαg ≥ g .

* The closing is the pseudo inverse of the dilation : βαg is the largest sethaving the same dilation as g .

* if If g ∈ Inv(ϕ), we have ϕg = βαg = g : on Inv(ϕ), β = α−1

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 17 / 201

Page 18: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Reminder on graphs

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 18 / 201

Page 19: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Graphs : General definitions

A non oriented graph G = [N, E ] : N = vertices or nodes ; E = edges :an edge u ∈ E = pair of vertices (see [1],[10])

A chain of length n is a sequence of n edges L = u1, u2, . . . , un, suchthat each edge ui of the sequence (2 ≤ i ≤ n− 1) shares one extremitywith the edge ui−1 (ui−1 6= ui ), and the other extremity with ui+1

(ui+1 6= ui ).

A path between two nodes x and y is a sequence of nodes(n1 = x , n2, ..., nk = y) such that two successive nodes ni and ni+1 arelinked by an edge.

A cycle is a chain or a path whose extremities coincide.

A cocycle is the set of all edges with one extremity in a subset Y and theother in the complementary set Y .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 19 / 201

Page 20: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Graphs : partial graphs and subgraphs

The subgraph spanning a set A ⊂ N : GA = [A, EA], where EA are theedges linking two nodes of A.The partial graph associated to the edges E ′ ⊂ E is G ′ = [N, E ′]For contracting an edge (i , j) in a graph G , one suppresses this edge uand its two extremities are merged into a unique node k. All edgesincident to i or to j become edges incident to the new node k.Contraction :If H is a subgraph of G , The operator κ : (G , H)→ G ′ contracts all edgesof H in G

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 20 / 201

Page 21: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Graphs : Connectivity

A connected graph is a graph where each pair of nodes is connected by apath

A tree is a connected graph without cycle.

A spanning tree is a tree containing all nodes.

A forest is a collection of trees.

Labelling a graph = extracting the maximal connected subgraphs

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 21 / 201

Page 22: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Weighted graphs

In a graph [N, E ], N represents the nodes, E represents the edges and Tis the set of weights of edges or nodes. (O being the lowest weight and Ωthe largest)Edges and nodes may be weighted : eij is the weight of the edge (i , j) andni the weight of the node i .The following weight distributions are possible:(−, ) : no weights(−, n) : weights on the nodes(e, ) : weights on the edges(e, n) : weights on edges and nodes

Various types of graphs are met in image processing.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 22 / 201

Page 23: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Which types of graphs ?

In ”pixel graphs” the nodes are the pixels and the edges connectneighboring pixels. The weights of the pixels are their value and theweights of edges may be for instance a gradient value computed betweentheir extremities.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 23 / 201

Page 24: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Which types of graphs ?

We will work with ”neighborhood graphs” where the nodes are thecatchment basins and the edges connect neighboring bassins. The edgesare weighted by a dissimilarity measure between adjacent catchmentbasins; the simplest being the altitude of the path-point between twobasins.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 24 / 201

Page 25: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The gabriel graph

Gabriel and Delaunay graphs permit to define neighborhood relationsbetween the sets and nodes of a population.

Two nodes x and y are linked by an edge if there exists no other node inthe disk of diameter (xy). Node weights will express features of the nodes,edge weights relationships between adjacent nodes.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 25 / 201

Page 26: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Gabriel graph modeling a lymphnode

The nuclei of a lymphnode are segmented and their Gabriel graphconstructed.

1.1 : histological section.

1.2 : marking the nuclei.

2.1 : catchment basins ofthe nuclei on the originalimage.

2.2 : node weightedgraph: the node weightsrepresent the nucleustype.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 26 / 201

Page 27: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Minimum spanning trees and forests in an edge weightedgraph

A minimum spanning tree is a spanning tree for which the sum of theedges is minimal.A spanning forest is a collection of trees spanning all nodes.In a minimum spanning forest, the sum of the edges is minimal.The minimum minimorum spanning forest (MSF) has only nodes. Wih anadditional constraint, one gets particular forests:

a MSF with a fixed number of trees, useful in hierarchicalsegmentation [18]

a MSF where each tree is rooted in predefined nodes, useful in markerbased segmentation.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 27 / 201

Page 28: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Flat zones and regional minima on edge weighted graphs

A subgraph G ′ of an edge weighted graph G is a flat zone, if any twonodes of G ′ are connected by a chain of uniform altitude.A subgraph G ′ of a graph G is a regional minimum if G ′ is a flat zone andall edges in its cocycle have a higher altitudeµe : G → µeG : extracts all regional minima of the graph G

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 28 / 201

Page 29: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Flat zones and regional minima on node weighted graphs

A subgraph G ′ of a node weighted graph G is a flat zone, if any two nodesof G ′ are connected by a path where all nodes have the same altitude.A subgraph G ′ of a graph G is a regional minimum if G ′ is a flat zone andall neighboring nodes have a higher altitudeµn : G → µnG : extracts all regional minima of the graph G

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 29 / 201

Page 30: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Contracting or expanding graphs

Contraction:For contracting an edge (i , j) in a graph G , one suppresses this edge u andits two extremities are merged into a unique node k . All edges incident toi or to j become edges incident to the new node k and keep their weights

If H is a subgraph of G , The operator κ : (G , H)→ G ′ contracts all edgesof H in G

Expansion:The operator ( : (−, n)→( G creates for each isolated regionalminimum i a dummy node with the same weight, linked by an edge with i .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 30 / 201

Page 31: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Extracting partial graphs

The following operators suppress a subset of the edges in a graph:χ : (−, )→ χG keeps for each node only one adjacent edges.↓ : (e, )→ ↓ G keeps for each node only its lowest adjacent edges.⇓ : (−, n)→ ⇓ G keeps only the edges linking a node with its lowestadjacent nodes.

These operators may be concatenated:χ ↓ G keeps for each node only one lowest adjacent edge.χ ⇓ G keeps for each node only one edge linking it with its lowest adjacentnodes.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 31 / 201

Page 32: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Distances on a graph

Case of edge weighed graphs

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 32 / 201

Page 33: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Constructing distances on an edge weighted graph.

Distances on an edge weighted graph have chains as support :1) Definition of the weight of a chain, as a measure derived from the edgeweights of the chain elements (example : sum, maximum, etc.)2) Comparison of two chains by their weight. The chain with the smallestweight is called the shortest.The distance d(x , y) between two nodes x and y of a graph is ∞ if thereis no chain linking these two nodes and equal to the weight of the shortestchain if such a chain exists.Given three nodes (x , y , z) the concatenation of the shortest chain πxy

between x and y and the shortest chain πyz between y and z is a chainπxz between x and z , whose weight is smaller or equal to the weight ofthe shortest chain between x and z . To each distance corresponds aparticular triangular inequality : d(x , z) ≤ weight( πxyB πyz ) whereπxyB πyz represents the concatenation of both chains.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 33 / 201

Page 34: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Distance on an edge weighted graph based a the length ofthe shortest chain

Length of a chain: The length of a chain between two nodes x and y isdefined as the sum of the weights of its edges.Distance: The distance d(x , y) between two nodes x and y is theminimal length of all chains between x and y . If there is no chain betweenthem, the distance is equal to ∞.Triangular inequality : For (x , y , z) : d(x , z) ≤ d(x , y) + d(y , z)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 34 / 201

Page 35: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Distance on a graph based on the maximal edge weightalong the chain

The weights are assigned to the edges, and represent their altitudes.Altitude of a chain: The altitude of a chain is equal to the highestweight of the edges along the chain.Flooding distance between two nodes: The flooding distancefldist(x , y) between nodes x and y is equal to the minimal altitude of allchains between x and y . During a flooding process, in which a source isplaced at location x , the flood would proceed along this chain of minimalhighest altitude to reach the pixel y . If there is no chain between them,the level distance is equal to ∞.Triangular inequality : For (x , y , z) : d(x , z) ≤ d(x , y) ∨ d(y , z) :ultrametric inequality

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 35 / 201

Page 36: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The flooding distance is an ultrametric distance

An ultrametric distance verifies* reflexivity : d(x , x) = 0* symmetry: d(x , y) = d(y , x)* ultrametric inequality: for all x , y , z : d(x , y) ≤ maxd(x , z), d(z , y) :the lowest lake containing both x and y is lower or equal than the lowestlake containing x , y and z .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 36 / 201

Page 37: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Distances on a graph : sum and maximum of the edgeweights

The shortest chain (sum of weights of the edges) between x and y is a redline and has a length of 4.The lowest chain (maximal weight of the edges) between x and y is a redline and a maximal weight of 2. A flooding between x and y would followthis chain.For this particular example, the shortest and lowest paths are identical.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 37 / 201

Page 38: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The lexicographic distance or the cumulative effort forpassing the highest edges

Toughness of a chain: We call toughness of a chain the decreasing list ofaltitudes of the highest edges met along this chain.

A B

In fig.A, along the bold chain between x and y , the highest edge rises atthe altitude 3. After crossing it, the highest edge on the remaining chainrises at 2. After crossing it, one is at destination. Hence the toughness ofthe chain from x to y is [3, 2]. Distances are compared in a lexicographicorder. The shortest chain is the red chain in fig.B, it has two edges withweight 2 and its toughness is [2, 2].

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 38 / 201

Page 39: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The lexicographic distance : a more formal definition

The lexicographic length Λ(A) of a chain A = e12e23...en−1n isconstructed as follows. Following the chain from the origin towards its end,one records the highest valuation of the chain, let it be λ1, then again thehighest valuation λ2 on the remaining part of the chain and so on until theend is reached. One gets like that a series of decreasing values:λ1 ≥ λ2 ≥....≥ λn.The lexicographic distance between two nodes x and y will be equal to theshortest lexicographic length of all chains between these two nodes and iswritten lexdist(x , y).

Remark: The lexicographic length of a never increasing path (NAP), issimply equal to the series of weights of its edges, as it is the highest edgealong the lowest path between x and y . Later we introduce shortest pathalgorithms whose geodesics are NAPs.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 39 / 201

Page 40: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The lexicographic distance of depth k

The lexicographic distance of depth k between two nodes x and y iswritten lexdistk(x , y) and obtained by retaining only the k first edges.inlexdist(x , y).

Remark: lexdist1(x , y) is the same as the ultrametric flooding distance asit is the highest edge on the lowest path between x and y .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 40 / 201

Page 41: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Distances on a graph

Case of node weighed graphs

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 41 / 201

Page 42: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Constructing distances on a node weighted graph.

Distances on a node weighted graph have paths as support :1) Definition of the ”length” of a path, as a measure derived from thenode weights of the path elements (example : sum, maximum, etc.)2) Comparison of two paths by their length. The path with the smallestlength is called the shortest.The distance d(x , y) between two nodes x and y of a graph is ∞ if thereis no path linking these two nodes and equal to the length of the shortestpath if such a path exists.Given three nodes (x , y , z) the concatenation of the shortest path πxy

between x and y and the shortest path πyz between y and z is a path πxz

between x and z , whose length is smaller or equal to the length of theshortest path between x and z . To each distance corresponds a particulartriangular inequality : d(x , z) ≤ length( πxyB πyz ) where πxyB πyz

represents the concatenation of both paths.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 42 / 201

Page 43: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Distance on a node weighted graph based on the maximalnode weight along the path

The weights are assigned to the nodes, and represent their altitudes.Altitude of a path: The altitude of a path is equal to the highest weightof the nodes along the path.Flooding distance between two nodes: The flooding distancefldist(x , y) between nodes x and y is equal to the minimal altitude of allpaths between x and y .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 43 / 201

Page 44: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Distance on a node weighted graph based on the cost fortravelling along the cheapest path

The weights are assigned to the nodes and not to the edges. Each nodemay be considered as a town where a toll has to be paid.Cost of a path: The cost of a path is equal to the sum of the tolls to bepaid in all towns encountered along the path (including or not one or bothends).Cost between two nodes: The cost for reaching node y from node x isequal to the minimal cost of all paths between x and y . We writetolldist(x , y). If there is no path between them, the cost is equal to ∞.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 44 / 201

Page 45: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration of the cheapest path

In this figure, the cheapest chain between x and y is in red and the totaltoll to pay is 1 + 1 + 2 + 2 = 6

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 45 / 201

Page 46: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Two adjunctions between edges and nodes on weightedgraphs

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 46 / 201

Page 47: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Two adjunctions between edges and nodes

Definition

We define two operators between edges and nodes :- an erosion [εenn]ij = ni ∧ nj and its adjunct dilation

[δnee]i =∨

eik(k neighbors of i)

- a dilation [δenn]ij = ni ∨ nj and its adjunct erosion[εnee]i =

∧eik

(k neighbors of i)

Lemma

The operators we defined are pairwise adjunct or dual operators:- εne and δen are adjunct operators- εen and δne are adjunct operators- εne and δne are dual operators- εen and δen are dual operators

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 47 / 201

Page 48: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Let us prove that δen and εne are adjunct operatorsIf G = [e, n] and G = [e, n] are two graphs with the same nodes andedges, but with different valuations on the edges and the nodes thenδenn ≤ e ⇔ ∀i , j : ni ∨ nj ≤ e ij ⇔ ∀i , j : ni ≤ e ij ⇔ ∀i , j : ni ≤∧

e ij(j neighbors of i)

= [εnee]i ⇔ n ≤ εnee

which establishes that δen and εen are adjunct operators.

Let us prove that εen and δen are dual operators[εen(−n)]ij = −ni ∧−nj = −(ni ∨ nj ) = − [δenn]ijHence δenn = − [εen (−n)]

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 48 / 201

Page 49: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The flooding adjunction

The dilation [δenn]ij = ni ∨ nj and its adjunct erosion[εnee]i =

∧eik

(k neighbors of i)have a particular meaning in terms of flooding.

If ni and nj represent the altitudes of the nodes i and j , the lowest floodcovering i and j has the altitude [δenn]ij = ni ∨ nj

If i represents a catchment basin, eik the altitude of the pass points withthe neighboring basin k, then the highest level of flooding withoutoverflow through an adjacent edge is [εnee]i =

∧eik

(k neighbors of i).

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 49 / 201

Page 50: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Waterfall flooding on graphs : an erosion

The waterfall flooding is completely specified if one knows the level offlood in each catchment basin

The waterfall flooding fillseach catchment basin upto its lowest pass point.

In terms of graphs : theflooding in a node isequal to the weight of itslowest adjacent edge.

It is an erosion betweennode weights and edgeweights :[εnee]i =

∧eik

(k neighbors of i)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 50 / 201

Page 51: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Waterfall flooding on graphs : an erosion

The waterfall flooding is completely specified if one knows the level offlood in each catchment basin

The waterfall flooding fillseach catchment basin upto its lowest pass point

In terms of graphs : theflooding in a node isequal to the weight of itslowest adjacent edge

It is an erosion betweennode weights and edgeweights :[εnee]i =

∧eik

(k neighbors of i)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 51 / 201

Page 52: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Erosion between edges and nodes

erosion from edges to nodes

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 52 / 201

Page 53: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Dilation between nodes and edges

If ni and nj represent the altitudes of the nodes i and j , the lowest floodcovering i and j has the altitude [δenn]ij = ni ∨ nj

dilation from nodes to edges

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 53 / 201

Page 54: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Erosion between edges and edges / between nodes andnodes

By concatenation of operators between edges and nodes we obtain :

an adjunction between nodes and nodes : (εneεen, δneδen) = (εn, δn)

an adjunction between edges and edges : (εenεne , δenδne) = (εe , δe)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 54 / 201

Page 55: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Opening and closing

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 55 / 201

Page 56: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Opening and closing

As εne and δen are adjunct operators, the operator ϕn = εneδen is a closingon n and γe = δenεne is an opening on e

Similarly the operator ϕe = εenδne is a closing on e and γn = δneεen is anopening on n

In the sequel, the flooding adjunction will play a key role, in particular theassociated opening γe and closing ϕn.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 56 / 201

Page 57: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The opening γe

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 57 / 201

Page 58: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration in one dimension of the opening γe

γe = δenεne : on the left, the result of the erosion, filling each basin to itslowest pass point. On the right the subsequent dilation. Some pass pointshave a reduced altitude : the amount of reduction is indicated in red.These passpoints are those which are not the lowest pass points of acatchment basin.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 58 / 201

Page 59: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration on an edge weighted tree of the opening γe

γe = δenεne : From left to right: 1) an edge weighted graph, in the centre,2) the result of the erosion εne , 3) the subsequent dilation produces anopening. The edges in red are those whose weight has been reduced by theopening. These edges are not the lowest edges of one or their extremities.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 59 / 201

Page 60: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The invariants of the opening γe

Two possibilities exist for an edge (i , j) with a weight λ :

the edge (i , j) has lower neighboring edges at each extremity. Henceεne(i) < λ and εne(j) < λ ; hence δenεne(i , j) = εen(i) ∨ εen(j) < λ

the edge (i , j) is the lowest edge of the extremity i . Then εne(i) = λand εne(j) ≤ λ ; hence δenεne(i , j) = εen(i) ∨ εen(j) = λ

Conclusion: the edges invariant by the opening γe are the edges which arethe lowest edge of one of their extremities. All edges with lower adjacentedges at their extremities have their weight lowered by the opening γe

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 60 / 201

Page 61: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Extracting from an edge weighted graph a partial graphinvariant by the opening γe

The relation εne = εne(δenεne) shows that all edges which are notinvariant by the opening γe = δenεne play no role in the erosion. As amatter of fact, if the opening lowers the valuation of an edge (i , j) and ifthe subsequent erosion εne is not modified, it means that the presence ofthis edge with its weight plays no role in the erosion εne .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 61 / 201

Page 62: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The waterfall graph, partial graph of the lowest adjacentedges

Suppressing in an arbitrary graph g all edges which are not invariant bythe opening γe produces a graph g ′, invariant for the opening γe andcalled waterfall graph. The operator keeping for each node only its lowestadjacent edges is written ↓ : (e, )→ ↓ GProperties:

↓ G spans all the nodes (each node has at least one lowestneighboring edge ; such edges are invariant by γe)

And εne(G ) = εne(↓ G ) (εne assigns to each node the weight of itslowest adjacent edge, which is the same in G as in ↓ G )

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 62 / 201

Page 63: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration on a planar edge weighted graph of the openingγe .

1 1 1

1 1 1

1 1 1

2 1

2 2 2

2 2 232

3 1

4 4 4

4 4 4

4 4 4

4 4 4

4 4 4

4 4 4

6 46 4

6 6 6

8 8 8

8 2

7 4

7 4

7 7 7

7 7 7

8 8 8

1 1 1

erosion opening waterfall graph = edgesinvariant by opening

2 2 22 2 2

2 2 2

1 1 11 1 1

1 1 1

1 1 1

1 1 1

1 1 1

1 1 1

4 4 4

4 4 4

4 4 4

4 4 4

4 4 4

7 7 7

8 8 8

6 6 6

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 63 / 201

Page 64: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Erosion from edges to nodes on the graph ↓ G

A B C D

A: Initial graph GB: Erosion εne from the edges to the nodes on GC: The graph ↓ GD: Erosion εne from the edges to the nodes on ↓ G : εne(G ) = εne(↓ G )

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 64 / 201

Page 65: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Erosion from edges to nodes on the graph ↓ G

Another illustration of εne(G ) = εne(↓ G )

1 1

1 1

1 1

2

2 2

2 23

3

4 4

4 4

4 4

4 4

4 4

4 4

6 6

6 6

8 8

8

7

7

7 7

7 7

8 8

1 1

erosion on the RAG erosion on the waterfall graph

2 22 2

2 2

1 11 1

1 1

1 1

1 1

1 1

1 1

4 4

4 4

4 4

4 4

4 4

7 7

8 8

6 6

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 65 / 201

Page 66: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The invariants of the opening γe

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 66 / 201

Page 67: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The invariants of the opening γe

If (e1, ) and (e2, ) are two edge weight distributions which are invariantfor γe , then (e1 ∨ e2, ) also is invariant for γe .

An arbitrary graph may be transformed into a flooding graph:* For an arbitrary edge weight distribution (e, ) : (γee, ) ∈ Inv(γe)* For an arbitrary node weight distribution (−, n) : (δenn, n) ∈ Inv(γe) asγeδenn = δenεneδenn = δenn

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 67 / 201

Page 68: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The invariants of the opening γe

For a connected graph g = (e, ) ∈ Inv(γe):

any partial spanning graph belongs to Inv(γe)

any subgraph belongs to Inv(γe)

In particular ↓ : G = (e, )→ ↓ G containing for each node only itslowest adjacent edgesand χ ↓ G keeping only one lowest adjacent edge for each node,both belong to Inv(γe)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 68 / 201

Page 69: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The regional minima of the opening γe

Theorem

If G = (e, ) ∈ Inv(γe) and m = (e, ) is the subgraph of its regionalminima, then εnem = (−, εnee) is the subgraph of the regional minima ofthe graph εneG = (−, εnee)

Proof: A regional minimum mk of the graph G = (e, ) ∈ Inv(γe) is aplateau of edges with altitude λ, with all external edges having a weight> λ. If a node i belongs to this regional minimum, its adjacent edges havea weight ≥ λ but it has at least one neighboring edge with weight λ :hence εnee(i) = λ. Consider now an edge (s, t) outside the regionalminimum, with the node s inside and the node t outside the minimum.Then est > λ. As G = (e, ) ∈ Inv(γe), the edge (s, t) is then one of thelowest edges of the nodes t : thus εne(t) = est > λ. This shows that thenodes spanned by the regional minimum mk form a regional minimum ofthe graph εneG = (−, εnee)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 69 / 201

Page 70: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Inverse of εne on the invariants of the opening γe

On Inv(γe) : δenεne = Identity showing that on Inv(γe) := δen = ε−1ne

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 70 / 201

Page 71: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The closing φn

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 71 / 201

Page 72: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The closing ϕn

The closing ϕn is obtained by a dilation δen of the node weights followedby an erosion εne . One remarks on the following figure that the nodeweights remain the same, except the isolated regional minima, which takethe weight of their lowest neighboring node. We give the proof in the nextslide.

denn

e dne enn

n

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 72 / 201

Page 73: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The invariants of the closing ϕn

Two possibilities exist for a node i with a weight λ :

the node i is an isolated regional minimum. Then δen assigns to alledges adjacent to i a weight bigger than λ. The subsequent erosionεne assigns to i the smallest of these weights.

the node i has a neighbor j with a weight µ ≤ λ. Then δen assigns tothe edge (i , j) the weight λ; whatever the weight of the otheradjacent edges. The subsequent erosion εne assigns to i the smallestof these weights, that is λ.

The closing ϕn replaces each isolated node constituting a regionalminimum by its lowest neighboring node and leaves all other nodesunchanged.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 73 / 201

Page 74: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The invariants of the closing φn

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 74 / 201

Page 75: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The invariants of the closing ϕn

A node weighted graph is invariant for the closing ϕn iff it does notcontain isolated regional minima.

For an arbitrary node weight distribution g = (−, n) : ( g creates foreach isolated regional minimum i a dummy node with the same weightlinked by an edge with i . Hence ( g ∈ Inv(ϕn)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 75 / 201

Page 76: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The invariants of the closing ϕn

If (−, n1) and (−, n1) are two node weight distributions which areinvariant for ϕn, then (−, n1 ∧ n2) also is invariant for ϕn.For an arbitrary node weight distribution (−, n) : (−, ϕnn) ∈ Inv(ϕn)For an arbitrary edge weight distribution (e, ) : (e, εnee) ∈ Inv(ϕn) asϕnεnee = εneδenεnee = εnee

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 76 / 201

Page 77: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The invariants of the closing ϕn

For a graph g = (e, ) ∈ Inv(ϕn): any partial or subgraph which does notcreate an isolated regional minimum also belongs to Inv(ϕn)

Each node i belonging to a regional minimum of g is linked with at leastanother node j in this minimum through an edge with the same weight.This edge is one of the lowest adjacent edges of i and links i with one ofits lowest neighboring nodes.

For this reason after pruning, the graphs ↓ g and ⇓ g still belong toInv(ϕn).

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 77 / 201

Page 78: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The regional minima of the closing ϕn

Theorem

If G = (−, n) ∈ Inv(ϕn) and m = (−, n) is the subgraph of its regionalminima, then δenm = (δenn, ) is the subgraph of the regional minima ofthe graph δenG = (δenn, )

Proof: A regional minimum mi of a graph G = (−, n) ∈ Inv(ϕn) is aplateau of pixels with altitude λ, containing at least two nodes (there areno isolated regional minima in Inv(ϕn)). All internal edges of the plateauget the valuation λ by δenn. If an edge (i , j) has the extremity i in theminimum and the extremity j outside, then δenn(i , j) > λ. Hence, for thegraph (δenn, ), the edges spanning the nodes of mi form a regionalminimum.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 78 / 201

Page 79: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Inverse of δen on the invariants of the closing ϕn

On Inv(ϕn) : εneδen = Identity showing that on Inv(ϕn) : εne = δ−1en

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 79 / 201

Page 80: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The flooding graphs

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 80 / 201

Page 81: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The flooding graph

Definition

An edge and node weighted spanning graph G = [N, E ] is a floodinggraph iff its weight distribution (n, e) verify the relations:- δenn = e- εnee = n

Corollary

For a flooding graph weight distribution (n, e) :- n ∈ Inv(ϕn)- e ∈ Inv(γe)

Proof.

e = δenn = δenεnee = γee and n = εnee = εneδenn = ϕnn

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 81 / 201

Page 82: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Properties of the flooding graph

As G is invariant by γe , all its edges are the lowest edge of one of theirextremities.As G is invariant by ϕn, it has no isolated regional minimum.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 82 / 201

Page 83: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The lowest adjacent edges of each node in a flooding graph

In a flooding graph, εnee = n, hence all edges adjacent to a node haveweights which are higher or equal than this node and at least one of themhas the same weight.

On the other hand, each node i has at least one neighbor j which is loweror equal (otherwise it would be an isolated regional minimum). The weighteij verifies eij = δenn(i , j) = ni ∨ nj = ni . This shows that the edges linkinga node with lower or equal nodes have the same weight than this node.

In particular, the edges linking a node i to its lowest neighboring nodesbelong to the lowest adjacent edges of this node and have the sameweight: ⇓ G ⊂ ↓ G and ↓⇓ G =⇓↓ G = ⇓ G

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 83 / 201

Page 84: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Constructing flooding graphs.

If G = (e, ) ∈ Inv(γe) then (e, εnee) is a flooding graph (sincee = γee = δenεnee = δenn)

If G = (−, n) ∈ Inv(ϕn) then (δenn, n) is a flooding graph (sincen = ϕnn = εneδenn = εnee)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 84 / 201

Page 85: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Deriving flooding graphs from ordinary graphs

If G = (e, ) is an arbitrary edge weighted graph, ↓ (e, ) ∈ Inv(γe), asthe edges lowered by γe , have been suppressed, the other edges keepingtheir weights. Recall that εnee = εne ↓ e. The derived flooding graphsimply is (↓ e, εne ↓ e)

If G = (−, n) is an arbitrary node weighted graph,(−,( n) ∈ Inv(ϕn), asisolated regional minima, if any, have been duplicated. The derivedflooding graph simply is (δen( n,( n).

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 85 / 201

Page 86: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Partial graph of a flooding graph

Suppressing edges in a flooding graph, but leaving at least one lowerneighboring edge for each node (like that, no isolated regional minima arecreated) produces a partial graph which also is a flooding graph, with thesame distribution of weights on the nodes and on the remaining edges.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 86 / 201

Page 87: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Regional minima of flooding graphs

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 87 / 201

Page 88: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Regional minima of a flooding graph

We proved earlier these theorems:

If G = (e, ) ∈ Inv(γe) and m = (e, ) is the subgraph of its regionalminima, then εnem = (−, εnee) is the subgraph of the regionalminima of the graph εneG = (−, εnee).

If G = (−, n) ∈ Inv(ϕn) and m = (−, n) is the subgraph of itsregional minima, then δenm = (δenn, ) is the subgraph of theregional minima of the graph δenG = (δenn, ).

As in a flooding graph n = εnee and e = δenn we derive:

Theorem

If G is a flooding graph with the weight distribution (e, n), then the nodeweighted graph (−, n) and the edge weighted graph (e, ) have the sameregional minima subgraph

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 88 / 201

Page 89: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The regional minima on the edge or node graph within theflooding graph

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 89 / 201

Page 90: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Labeling the regional minima on the edge or node graphwithin the flooding graph

As the minima are identical on the nodes or the edges of a flooding graph,it is possible to assign the same labels to nodes or to edges.

labeling the regional minimaon the nodes and/or the edges

22

2

11

1

1

1

1

1

4

4

4

4

4

7

8

6

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 90 / 201

Page 91: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Paths of steepest descent and catchment basins

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 91 / 201

Page 92: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The catchment basins of the minima

Lemma

From each node outside a regional minimum starts a never ascending pathto a regional minimum in a flooding graph.

Proof: Any node i outside a regional minimum has a lower neighboringnode, if it does not belong to a plateau. Otherwise it belongs to a plateau,containing somewhere a node j with a lower neighboring node outside, asthe plateau is not a regional minimum. The plateau being connected, thereexists a path of constant altitude in the plateau between i and j . Followingthis path, it is possible, starting at node i to reach the lower node k . Thisshows that for each node there exists a never ascending path to a lowerneighboring node. Taking this new node as starting node, a still lowernode may be reached. The process may be repeated until a regionalminimum is reached.Thanks to this lemma, it is possible to define the catchment basins of theminima.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 92 / 201

Page 93: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The catchment basins of the minima

Definition

The catchment basin of a minimum m is the set of all nodes from whichstarts a never ascending path towards m.

As in a flooding graph, each node and its lower neighboring edges have thesame weight, each node in such a never ascending path is followed by anedge with the same weight except the last one belonging to a regionalminimum. For this reason the catchment basins based on the node weightsor on the edge weights are identical.The watershed zones are the nodes belonging to more than onecatchment basin.The restricted catchment basins are the nodes which belong to onlyone catchment basin : it is the difference between the catchment basin ofa minimum m and the union of catchment basins of all other minima.From a node in a restricted catchment basin, there exists a unique nonascending path towards a unique regional minimum.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 93 / 201

Page 94: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

M-flooding graphs

The catchment basins rely entirely on the non ascending paths of thegraph reaching a regional minimum. The altitude of the regional minimumhas no importance. If we consider only the end points of such a path, thefact that the minimum is an isolated node or not has no importance either.For this reason, we may relax the definition of the flooding graphs forwhich δenn = e and εnee = n for all edges and nodes.Consider a flooding graph where all non regional minima nodes have apositive weight. Assigning to all minima a weight 0 does not invalidate therelation δenn = e. The relation εnee = n also remains true, except forisolated regional minima. We call M-flooding graphs, the node and edgeweighted graphs verifying δenn = e everywhere and εnee = n for all nodeswhich are not isolated regional minima.In what follows we consider NAP which end with a node in a regionalminimum. Whether this minimum is isolated or not has no importance.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 94 / 201

Page 95: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Extending the restricted cathment basins and reducing thewatershed zone : steep, steeper, steepest flooding graphs

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 95 / 201

Page 96: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Catchment basins and segmentation.

The watershed transform is mainly used for segmentation, with the aim tocreate a partition representing precisely the extension of each object. Largewatershed zones are ambiguous as they separate restricted catchmentbasins without precise localisation of the contour separating them.For obtaining precise segmentations, it is important to reduce these zonesand even suppress them completely if possible. Reducing the number ofnever ascending paths from each node to a regional minimum would helpconstraining the construction of the watershed partition. Ideally, if onlyone such path remains for each node outside the regional minima, thesolution would be unique, the restricted catchment occupy the wholespace and the watershed zones be empty.In this section we show how to reduce the number of paths and keep onlythose which have some degree of steepness. Increasing the steepnessreduces the number of paths.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 96 / 201

Page 97: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Flooding tracks

In a flooding graph each edge is the lowest edge of one of its extremitiesand has the same weigh: we call such a pair made of a node and adjacentedge with the same weight flooding pair.Two couples (i , ij) and (j , jk) are chained if the node in the second coupleis an extremity of the edge of the first couple.A flooding track is a list of chained couples of never increasing weight.The lexicographic weight of a flooding track is the list of neverincreasing weights of its pairs.Two flooding tracks may then be compared by comparing theirlexicographic weights using the lexicographic order relation.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 97 / 201

Page 98: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Pruning the flooding graph to get steeper paths.

We define a pruning operator ↓k operating on a flooding graph G . Thepruning ↓k considers each node outside the regional minima andsuppresses its adjacent edges, if they are not the highest edge of a floodingtrack verifying:

their lexicographic weight is minimal.

their length is k . It may be shorter if its last couple belongs to aregional minimum

After pruning, each node outside the regional minima is the origin of oneor several k-steep flooding tracks (remark that the pruning only suppressesthe highest edge of the track). If there are several of them, they have thesame weights.We call them the k-steep adjacent paths to the node i . We say that thegraph ↓k G has a k-steepness or is k-steep.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 98 / 201

Page 99: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Nested k-steep graphs

As the steepness degree increases, the pruning becomes more and moresevere, producing a decreasing series of partial graphs, hence fork > l : ↓k G ⊂↓l G . Furthermore ↓k↓l G =↓l↓k G =↓k∨l G .

The pruning ↓1 does nothing as each edge is the lowest edge of one of itsextremities in any graph invariant by γe . On the contrary, ↓1=↓transforms an arbitrary graph into a graph invariant by γe .

The pruning ↓2 keeps for each node i the adjacent edges which arefollowed by a second couple of minimal weight. These edges are thoselinking i with one of its lowest neighboring nodes.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs 2012 February 29 99 / 201

Page 100: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

A morphological characterization of k-steep graphs

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 100 / 201

Page 101: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Eroding k-steep graphs

Consider a k-steep graph ↓k G = G = (e, n), with k ≥ 2. We define theerosion εG = (εee, εnn), where εe = εenεne and εn = εneεen.ε(1)G = εG and ε(m)G = εε(m−1)G .

It does not change the catchment basins if we assign to the regionalminima the weight 0, whereas all other nodes and edges have weights > 0(like that as soon the erosion assigns the value 0 to a node or an edge,they remain equal to 0 for all subsequent erosions).

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 101 / 201

Page 102: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Eroding k-steep graphs

Consider a k-steep lexicographic track τ of a flooding graph G made of aseries of non increasing flooding pairs (i1, e1), (i2, e2), . . . , (ik , ek). Nodeand edge of each flooding pair have the same weights. As τ has a minimallexicographic weight, each of its flooding pairs, except the first oneconstitutes one of the lowest adjacent flooding pair of the previous floodingpair. For this reason the erosion εG assigns to the edge eh the weight ofthe adjacent edge eh+1 and to the node ih the weight of the adjacent nodeih+1. In other workds successive erosions (εee, εnn) let glide the value ofeach pair upwards in the track. If this track is of length k, after k − 1erosion, the weight of the ultimate pair will have reached the first one.If such a track is of length l < k, it ends with a pair in a regionalminimum, with the value 0. Successive erosions (εee, εnn) also let glide thevalue of each pair upwards in the track and the last pair, with value 0 alsomoves upwards and reaches the pair (i , ij) after l − 1 erosions. During thenext erosions, the value of the pair (i1, e1) remains stable and equal to 0.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 102 / 201

Page 103: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Eroding k-steep graphs

Consider a k-steep flooding graph G =↓k G . During the k − 1 successiveerosions, the values of the flooding pairs glide upwards along the k-steeplexicographic path. For the erosion l < k, the (l + 1)th pair (s, st) hasreached the pair (i , ij). Hence the edge ij remains one of the lowestadjacent edge of the node i and both share identical weights.But (s, st) belongs to the flooding graph and verifies ns = εnee(s) andns = εnee(s) and so does (i , ij).This shows that the graph ε(l)G still is a flooding graph.

Theorem

For an ordinary flooding graph G , ↓k G is a k-steep flooding graph and forl < k , ε(l) ↓k G still is a flooding graph.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 103 / 201

Page 104: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Eroding flooding graphs

Consider a flooding graph G = (e, n). The erosion εn = εneεen enlargesthe regional minima. Hence if G is invariant by ϕn it is still the case forthe graph (e, εnn)On the contrary, after the erosion εe = εenεne , the graph (εee, n) is notnecessarily invariant for γe . One has to prune the edges which are not thelowest edges of one of their extremities: ↓ εee.Repeating the operator ζG = (↓ εee, εnn) produces a decreasing series ofpartial graphs ζ(n)G = ζζ(n−1)G we will now characterize.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 104 / 201

Page 105: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Two equivalent modes of pruning.

Theorem

For m ≥ 1, and defining ζ(0) = identity , the operators ζ applied toζ(m−1)G and ↓m+1 applied to ↓m G keep and discard the same edges. Theoperators ζ(k). and ↓k+1 produce partial spanning graphs with the sameedges and nodes.

Proof: We prove it by induction.a) m = 1 : ζ and ↓2 select the edges linking a node with its lowest node(this covers the case where the edge belongs to a regional minimum)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 105 / 201

Page 106: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Two equivalent modes of pruning.

b) We suppose that ζ(m−1)G and ↓m G have the same edges and showthat it is still the case for m = m + 1.Consider a couple (i , ij) of ζ(m−1)G . It belongs to a m− 1-steepest track.The second pair (j , jk) of this track also belongs to a (m− 1)−steepesttrack and holds the weight of the lowest pair of the track. The operator ζapplied to ζ(m−1)G assigns this weight to the edge ij but not necessarilyto the node i if there exists another pair (i , il) with a lower weight afterthis erosion. In this case the edge ij is discarded by the operator ζ. But itis also discarded by the operator ↓m+1 G , as no (m + 1)-steepest pathpasses through ij .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 106 / 201

Page 107: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Constructing k-steepest graphs

The operator ↓m G is of theoretical interest but of poor practical value, asit is based on a neighborhood of size m. On the contrary the operator ζ ispurely local and uses a neighborhood of size 1 : an erosion from node tonode, an erosion from edge to edge and the suppression of any edge whichis not the smallest edge of one of its extremities.Repeating m times the operator ζ produces a graph which has the sameedges as the operator ↓m+1 G . It is then sufficient to restore the originalweights of edges and nodes of the graph G onto the graph ζ(m)G toobtain the same result as ↓m+1 G .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 107 / 201

Page 108: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Characterizing k-steepest graphs

Theorem

A graph G is a k-steepest graph if and only if for each l < k , ε(l)G is aflooding graph

Proof: If a graph G is a k-steepest graph, then G =↓k G and we havealready established that for l < k , ε(l) ↓k G is a flooding graph.Inversely suppose that for each l < k , ε(l)G is a flooding graph, thenε(l)G has the same edges as G . As a matter of fact ε(l)G is invariant by γe

and each edge is the lowest edge of a node: ↓ ε(l)G = ε(l)G .But ε(l)G = εε(l−1)G and ↓ εε(l−1)G = (↓ εee, εnn)ε(l−1)G = ζε(l−1)G(considering G = ε(0)G ). It follows that for l < k , we have ε(l)G = ζ(l)G .The operator ζ applied to k times to G never suppresses an edge from G .But we know that ζ(k−1)G and ↓k G have the same nodes and edges,showing that indeed G is a k-steepest graph.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 108 / 201

Page 109: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Deriving an algorithm for delineating the catchment basins

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 109 / 201

Page 110: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The catchment basins of k-steepest paths

It is now possible to imagine an algorithm associated to the operator ζ. IfG is a flooding graph, we assign a a distinct label to each regionalminimum and a weight 0. The operator ζ propagates the weights upwardsalong the steepest tracks as it is repeated. In parallel, we also propagatethe labels: every time a pair (i , ij) takes the weight 0 from a paircontaining a labeled node j , the node i takes the label of j . Like that, asthe labeled zones with weight 0 expand, their labels also expand.We now have to consider two cases. In the first case, we constructrestricted catchment basins separated by watershed zones. In the second,we create a partition by assigning each node to one and only one basin, atthe price of arbitrary choices.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 110 / 201

Page 111: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Catchment basins and watershed zones

During the successive operations ζ, every time a pair (i , ij) takes theweight 0 from a pair containing the node j , the node i takes the label of jprovided the pair (i , ij) is unique. If there are two equivalent pairs (i , ij)and (i , il), it means that there exist two minimal lexicographic tracksstarting at i towards one or two distinct minima. If j and k hold the samelabel, this label is assigned to i . If on the contrary they are distinct, wehave 2 possibilities:

we assign to i a label Z , indicating that it belongs to a watershedzone. The upstream of i also will get this same label Z . The regionswith label Z belong to the watershed zone and the other labeledregions are restricted catchment basins.

we assign to i one of the labels (either randomly, or by applying anadditional rule for braking the ties), producing a partition incatchment basins with an empty watershed zone. The result is notunique and depends on the succession of choices which have beenmade.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 111 / 201

Page 112: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Creating a partition

0 0 0

0 0

0 00

0 00

0 0

0 0 00 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0

0 00 0

0 0

0 0 00 0 00 0 0

0 00 0

0 0

0 0

0 0

0 0

0

0 0

0 0

0 0

0 0 0

0 0 0

0 0 0

0 0 0

On the left a flooding graph where the minima have weights equal to 0and their labels are indicated by distinct colors. The next two figures showthe propagation of the weights and of the labels as the operator ζ hasbeen applied twice in a sequence.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 112 / 201

Page 113: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Partial conclusion

Starting with a node or edge weighted graph we have shown how toextract from it a flooding graph where nodes and edges are weighted.The operators ↓m G extract from the graph G partial graphs which aresteeper and steeper flooding graphs. The series of partial graphs ↓m G isdecreasing with m.The operator ζ permits an iterative construction of ↓m G , using only smalllocal neighborhood transformations.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 113 / 201

Page 114: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The scissor operator and the watershed partitions

In the previous section we introduced pruning operators which extractfrom a flooding graph k-steep flooding graphs. These operators do notmake any choice among the k-steep flooding graphs, they take them all.

We now introduce operators aiming at creating partitions : they extractminimum spanning forests from the flooding graph by pruning. Contrarilyto the preceding operators, they do make arbitrary choices amongequivalent edges to be suppressed.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 114 / 201

Page 115: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The flooding pairs

The previous section has shown how to extract from a node or edgeweighted graph partial graphs which are flooding graphs. In a floodinggraph, each node has at least one adjacent edge with the same weight. Weconsider here the nodes and edges outside the regional minima. Thereexists at least one (in general several) one to one correspondance betweeneach node outside a regional minimum and one of its adjacent edges withthe same weight. For each such one to one correspondance, we callflooding pair, the couple of node and edge which have been associated.They hold the same weight.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 115 / 201

Page 116: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The flooding pairs

Let us show how to construct such a one to one correspondance. If anedge is the lowest adjacent edge of only one of its extremities, then theyform a flooding pair ; this is in particular the case if the other extremity ofthe edge has a lower weight.If on the contrary, it has the same weight as both its extremities, itbelongs to a plateau. As this plateau is not a regional minimum, thereexists a pair of neighboring nodes, a node s inside the plateau and a lowernode t, outside. This edge (s, t) forms a flooding pair with the node s. Asthe plateau is connected, there exists a tree spanning its nodes, having sas root. There exists a unique path between s and each node i of theplateau. The last edge on this path before reaching i and i itself form aflooding pair.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 116 / 201

Page 117: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The scissor operator creates a partition of the nodes

We have shown that there exists at least one (in general several) one toone correspondance between each node outside a regional minimum andone of its adjacent edges with the same weight. For each such one to onecorrespondance, we call flooding pair, the couple of node and edge whichhave been associated.To each such one to one correpondance we associate a a pruning operatorχ, called scissor. This operator suppresses all edges outside a regionalminimum which do not form a flooding pair with one of their extremities.

After applying the operator χ to a flooding graph, there exists one andonly one path from each node to a regional minimum: the catchmentbasins of the minima partition the nodes, and the watershed zones areempty

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 117 / 201

Page 118: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The drainage minimum spanning forest

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 118 / 201

Page 119: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The drainage minimum spanning forest

After contracting all edges in the regional minima of a flooding graph andapplying the scissor operator χ one gets a spanning forest, where each treeis rooted in a minimum:

the resulting graph is a partition where each connected componentcontains a regional minimum node : there exists a path linking eachnode outside the minima with a minimum.

each connected component is a tree as the number of nodes is equalto the number of edges (the number of flooding pairs) plus one (theregional minimum node).

it is a minimum spanning forest : each node is linked to its treethrough one of its lowest neighboring edge. The total weight of eachtree is thus equal to the total sum of the nodes outside the regionalminima. This total weight is independent of the particular choicemade by χ.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 119 / 201

Page 120: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The drainage minimum spanning forest

Expanding again the regional minima and replacing them by a MST ofeach regional minimum creates again a minimum spanning forest, identicalto the preceding one outside the minima.Its total weight is computed as follows:

if Mi is a regional minimum with n nodes of weight λi , the weight ofits MST is equal to (n− 1) ∗ λi

each other node contributes by its weight, which is also the weight ofits lowest adjacent edge.

Each particular forest is based on a particular scissor operator χ and of aparticular MST in each regional minimum. We call φ the operator whichextracts from a flooding graph such a MSF (minimum spanning forest).

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 120 / 201

Page 121: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The catchment basins

G = a flooding graph, C = φG a minimum spanning forest:

Each node belongs to a regional minimum or is the origin of a uniquenever ascending path leading to a regional minimum

each tree of C contains a unique regional minimum ; its nodes formthe catchment basin of this minimum.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 121 / 201

Page 122: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Catchment basins of increasing steepness

G = a flooding graph, ↓m G still is a flooding graph and Cm = φ ↓m G aminimum spanning forest of steepness m.As for m > l : ↓m G ⊂↓l G , any minimum spanning forest Cm = φ ↓m Gis also a minimum spanning forest of ↓l G .For increasing values of m, the number of forests of steepness m decreases.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 122 / 201

Page 123: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 123 / 201

Page 124: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

A flooding graph associated to a distance function

We chose as topographic surface the distance function expressed on thenodes of a hexagonal grid to two binary connected sets, encoded with thevalue 0. The edge weights are obtained by the dilation δen. Like that thelowest neighboring edges of a node connects it with its neighbors withequal or lower weights. In the following figure, the edges with the sameweight have the same color (cyan = 4, magenta = 3, green = 2).

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 124 / 201

Page 125: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The flooding graph of a distance function

As the minima have 2 nodes each, the pixel graph is invariant by ϕn. Thedilation δen assigns weights to the edges and creates a flooding graph.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 125 / 201

Page 126: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The minimum spanning forest by keeping one lowestneighboring edge for each node

The scissor χ leaves one lowest neighboring edge for each node. Thereexists a huge number of choices for χ. The following illustration shows aparticular scissor χ producing an unexpected partition in two catchmentbasins (the catchment basins should be the half plane separated by themediatrix of both binary sets, as illustrated in the previous slide).

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 126 / 201

Page 127: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Two geodesics for the flooding ultrametric distance, leading to anunexpected partition.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 127 / 201

Page 128: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Looking one node further

The operator ↓2 G leaves only the edges linking a node to its lowestneighbors. The following figure shows the remaining edges. The green zonerepresents a restricted catchment basin. The yellow zone is an extendedcatchment basin containing the watershed zone.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 128 / 201

Page 129: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The minimum spanning forest by keeping one edge towardsa lowest neighboring node

The pruning χ ⇓= χ ↓2 leaves for each node one edge towards a lowestneighboring node. The following figure shows one such solution and theresulting partition.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 129 / 201

Page 130: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The catchment basins, skeletons by zone of influence forlexicographic distance functions

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 130 / 201

Page 131: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The geodesics of the k-steepest graphs

The operator ↓k G prunes the flooding graph and leaves only NAPs with asteepness equal to k . From each node of the graph starts a NAP whose kfirst edges have a minimal lexicographic weight. If one follows such a path,the next k edges following each node as one goes downwards along thepath also has a minimal lexicographic weight. This shows that each NAPis a geodesic line for a lexicographic distance function lexdistk we definebelow.After the pruning ↓k some nodes belong to two or more catchment basins.In order to obtain a partition, one applies the scissor operator χ leaving foreach node only one lowest adjacent edge. Like that the thick watershedzones are suppressed and the catchment basins form a partition.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 131 / 201

Page 132: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Constructing a watershed partition as the skeleton byzones of influence of the minima

It is possible to obtain the same result, if one labels the regional minimaand computes for the other nodes the shortest lexicographic distancelexdistk to the minima. If one applies a greedy algorithm, one may inaddition propagate the labels of the minima all along the geodesics andconstruct a partition of the space. If a node is at the same lexicographicdistance of two nodes, a greedy algorithm will arbitrarily assign to it one ofthe labels of the minima. This is quite similar to the operator χ which alsodoes arbitrary choices.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 132 / 201

Page 133: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Defining a lexicographic distance along non ascendingpaths.

Consider a flooding graph. In a NAP, each node except the last one formswith the following edge a flooding pair, i.e. they have the same weights.And these weights are decreasing as one follows the NAP downwards. Thek first values, starting from the top, may be considered as a lexicographicdistance of depth k . In what follows we give a precise definition of suchdistances.The shortest distances and their geodesics may be computed wih classicalalgorithms. Propagating the labels of the minima along the geodesicsduring their construction constructs the zones of influence of the minima,i.e a partition into catchment basins. The solution is not necessarilyunique. However the number of solutions decreases with the depth of thelexicographic distance which is considered.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 133 / 201

Page 134: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Lexicographic distances of depth k

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 134 / 201

Page 135: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Comparing NAPs with the lexicographic order.

Let S be the set of sequences of edge or node weights, i.e. elements of T .Let Sk be the set of sequences with a maximal number k of elements. Fora sequence s ∈ Sk , we define the lexicographic weight wk(s) : it is equalto ∞ if s is not a NAP and equal to s itself otherwise.We define an operator firstk which keeps the k first edges and nodes ofany NAP, or the NAP completely if its length is smaller than k . Theoperator firstk maps any sequence of S into Sk .We define on the NAPs of Sk the usual lexicographic order relation, whichwe will note ≺, such that: (λ1, λ2, . . . , λk) ≺ (µ1, µ2, . . . , µk) if eitherλ1 < µ1 or λi = µi until rank s and λs+1 < µs+1. We define a b asa ≺ b or a = b.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 135 / 201

Page 136: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Comparing NAPs with the lexicographic order.

Like that, it is possible to compare any two sequences s1 and s2 of Sk bycomparing their weights:

if s1 and s2 are not NAPs, then wk(s1) = wk(s2) = ∞ and weconsider that s1 ≡ s2 (they are equivalent)

if one of them, say s1, is a NAP and not the other, thenwk(s1) ≺ wk(s2) = ∞ and s1 ≺ s2

if both of them are NAP, then they compare as their weights:s1 ≺ s2 ⇔ wk(s1) ≺ wk(s2) and s1 ≡ s2 ⇔ wk(s1) = wk(s2)

If s1 and s2 are NAPs belonging to S , we compare them with: s1 ≺ s2 ⇔wk [firstk(s1)] ≺ wk [firstk(s2)]

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 136 / 201

Page 137: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Defining an ”addition” operator, comparing sequences

For NAPs of S we define the operator k called “addition”, whichoperates as a minimum:

ak b =a if a bb if b a

∀a, b ∈ S

The k operation is associative, commutative and has a neutral element∞ called the zero element: ak ∞ = ∞k a = a

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 137 / 201

Page 138: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Defining a ”multiply” operator, concatenating sequences

The operator k , called “multiplication”, permits to compute thelexicographic length Λ(A) of a sequence, obtained by the concatenation oftwo sequences. Let a = (λ1, λ2, . . . , λk) and b = (µ1, µ2, . . . , µk) we willdefine ak b by:

if a or b is not a NAP then ak b = ∞if a and b are NAPs and λk < µ1 then ak b = ∞if a and b are NAPs and λk ≥ µ1 then ak b = wk [firstk(aB b)] ,where aB b is the concatenation of both sequences.

In particular ak ∞ = ∞k a = ∞. so that the zero element is anabsorbing element for k .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 138 / 201

Page 139: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Algebraic shortest paths algorithms

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 139 / 201

Page 140: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

A path algebra on a dioıd structure

The operator k is associative and has a neutral element 0 called unitelement: ak 0 = a. The multiplication is distributive with respect to theaddition both to the left and to the right.The structure (S ,k ,k) forms a dioıd, on which Gondran and Minouxdefined a path algebra [10], where shortest paths algorithms are expressedas solutions of linear systems.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 140 / 201

Page 141: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Transposing the dioıd to square matrices

Addition and multiplication of square matrices of size n derives from thelaws and k : for A = (aij ), B = (bij ), i , j ∈ [1, n] :

C = AB = (cij )⇔ cij = aij bij ∀i , j

C = Ak B = (cij )⇔ cij =∑

1≤k≤naik k bkj ∀i , j

where∑ is the sum relative to .

As there is no ambiguity, for∑

1≤k≤naik k bkj , we simply write ∑

1≤k≤naikbkj

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 141 / 201

Page 142: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Unity and zero matrices

With these two laws, the square matrices also become a dioıd with

zero matrix ε =

ε...........ε....................................................ε...........ε

and unity matrix E =

e...........ε..e..............e..............e................e....ε...........e

We write A0 = E

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 142 / 201

Page 143: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Lexicographic length of paths in a graph

If G = [X , U ] is a weighted graph with

a set X of nodes, numbered i = 1, ......, N.

a set U of edges u = (i , j) with weights sij ∈ S .

The incidence matrix A = (aij ) of the graph is given by:

aij =

sij si (i , j) ∈ U

ε sinon

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 143 / 201

Page 144: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

A path algebra on a dioıd structure

To each path µ = (i1, i2, ....ik) of the graph, one associated itsk-lexicographic weight w(µ) = si1i2 k si2i3 k ....k sik−1ik , which isdifferent from ∞ only if the path is a NAP.If π is a never increasing sequence, then wk [firstk(π)] = firstk(π)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 144 / 201

Page 145: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Shortest paths in the graph

The shortest paths for the lexicographic distance between any couple ofnodes may be computed thanks to An or A(n) = E A1A2 .........An .

Lemma

Anij =

µ∈Cnij

w(µ) and A(n)ij =

µ∈C (n)ij

w(µ)

where:

Cnij is the family of paths between i and j , containing n + 1 nodes

(not necessarily distinct)

C(n)ij is the family of paths between i and j , containing at most n + 1

nodes (not necessarily distinct)

Defining A′ = E A, as est idempotent (a a = a ∀a ∈ S), wehave: A′n = A(n)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 145 / 201

Page 146: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

A path algebra on a dioıd structure

In a graph with N nodes, an elementary path has at most N nodes,separated by N − 1 edges. Hence, necessarily A(N) = A(N−1) and A∗, thelimit of A(n) for increasing n, is also equal to A(N−1).Thanks to A∗, the computation of the catchment basins is immediate. Ifm1 is a regional minimum, then a node i belongs to its catchment basin if

and only if A∗im1≤

mj 6=m1

A∗imj

A∗ may be obtained by the successive multiplications :A, A2 = Ak A, A4 = A2k A2, ...A2i = A2i−1

k A2i−1until

2i ≥ N − 1,, i.e. i ≥ log (N − 1)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 146 / 201

Page 147: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

A path algebra on a dioıd structure

A∗ verifies A∗ = E Ak A∗.Multiplying by a matrix B: A∗B = B Ak A∗B. Defining Y = A∗Bshows that A∗B is solution of the equationY = B Ak Y . Furthermore, it is the smallest solution.With varying B it is possible to solve all types of shortest distances:

The smallest solution of Y = E Ak Y yields A∗E = A∗

with B =

ε...0...ε

, one gets A∗B, the i-th column of the matrix A∗,

that is the distance of all nodes to the node i .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 147 / 201

Page 148: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Solving linear systems

Gondran and Minoux have shown that most of the classical algorithmssolving systems of linear equations (Gauss, Gauss-Seidel, etc.) are stillvalid in this context and correspond often to known shortest pathsalgorithms defined on graphs. We now give a few examples.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 148 / 201

Page 149: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The Jacobi algorithm

Setting B =

0ε......ε

and Y (0) =

ε...ε...ε

, the iteration

Y (k) = A ∗ Y (k−1) B converges to Y (N) = A∗ ∗ B

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 149 / 201

Page 150: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The Gauss Seidel algorithm

A is decomposed as A = L E U, where L is an inferior triangularmatrix, E the unity matrix E , and U an upper triangular matrix. Theupper part of L and lower part of U have the value ε.The solution of Y = A ∗ Y B is obtained by the iteration :Y (k) = LY (k−1) UY (k) BThis algorithm is faster as Jacobi’s algorithm, as the product UY (k)

already uses intermediate results, freshly computed during the currentiteration Y (k).

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 150 / 201

Page 151: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The Jordan algorithm

The Jordan algorithm is used in classical linear algebra for invertingmatrices, by successive pivoting. In our case, where the shortest paths areelementary path the algorithms is:For k from 1 to N :

For each i and j from i to N, do: aij = aij aik ∗ akj

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 151 / 201

Page 152: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The greedy algorithm of Moore-Dijkstra

Gondran established the algebraic counterpart of the famous shortest pathalgorithm by Moore-Dijkstra.Theorem (Gondran): Let Y = A∗B be the solution of Y = AY B, for

an arbitrary matrix B. There exists then an index i0 such that yi0 =∑ bi .

The smallest b is such solution : yi0 = bi0

Each element of Y = AY B is computed by

yk =∑j 6=k

akj ∗ yj bk =∑

j 6=k,i0

akj ∗ yj aki0yi0 bk

Suppressing the line and column of rank i0 and taking for b the vector

b(1)k = aki0yi0 bk , one gets a new system of size N − 1 to solve.

The Moore Dijkstra algorithm can also directly be computed on a floodinggraph G , as presented below.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 152 / 201

Page 153: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Shortest paths algorithms on the graph

The shortest path algorithm of Dijkstra is first presented [22]. Weshow that for a lexicographic distance of depth 1, it becomesalgorithm for constructing the minimum spanning forest of Prim.

The core expanding algorithms take advantage of the particularstructure of the lexicographic distances. They are faster than theDijkstra algorithm and better suited to hardware implementations.For a lexicographic distance of depth 2, they produce the samegeodesics as the topographic distance.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 153 / 201

Page 154: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Architecture of shortest path algorithms.

The shortest path algorithms below are applied on a graph which isinvariant by the opening γe (the regional minima may ad libitum becontracted beforehand). A domain D is used and expanded, containing ateach stage of the algorithms the nodes for which the shortest distance tothe minima is known. Initially the minima are labeled and put in D with avalue 0. We say that a flooding pair (j , jl) is on the boundary of thedomain D, if j is outside D and l inside D. In this case we say that ”jfloods l”, or ”l is flooded by j”. We say that j belongs to the outsideboundary ∂+D of D and l to the inside boundary ∂−D of D.The domain D is progressively expanded by progressive incorporation ofnodes in ∂+D belonging to flooding pairs on the boundary of D.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 154 / 201

Page 155: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The Moore Dijkstra algorithm

The shortest path algorithm by Moore-Dijkstra constructs the distances ofall nodes to the minima in a greedy manner. It uses a domain D whichcontains at each stage of the algorithm the nodes i for which the shortestdistance δ∗k(i) and label λ(i) is known.Initialisation:The nodes of the regional minima are labeled and put in the domain D.Repeat until the domain D contains all nodes:For each flooding pair (j , (jl) on the boundary of D, estimate the shortestpath as δk(j) = ejl k δ∗k(l).The node with the lowest estimate is correctly estimated. If thecorresponding flooding pair is (s, st) :

D = D ∪ sδ∗k(s) = δk(s)

λ(s) = λ(t)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 155 / 201

Page 156: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Correctness of the Moore Dijkstra algorithm

The node with the lowest estimate is correctly estimated and is introducedin the domain D. If is necessarily the shortest path, as any other pathwould have to leave D through another boundary flooding pair with ahigher estimate.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 156 / 201

Page 157: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Controlling the Moore Dijkstra algorithm

The Moore Dijkstra may be advantageously controlled by a hierarchicalqueue structure. Each node, as it gets is estimate is put into the HQ. Aslong the HQ is not empty, the extracted node is among the nodes with thelowest estimate, the one which has been introduced in the HQ first.The HQ has thus the advantage to correctly sequence the treatment in thepresence of plateaus: it treats the nodes in the plateaus from their lowerboundary inwards. The processing order is proportional to the distance ofeach node to the lower boundary of the plateau.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 157 / 201

Page 158: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The Moore Dijkstra algorithm : case where k = 1

The algorithms remains the same but the computations are simplified asδk(j) = ejl 1 δ∗1(l) is simply the weight of the node and the edge in theflooding pair (j , (jl). In other terms, the domain D is expanded byintroducing into D the flooding pair on the boundary of D with the lowestweight. This corresponds exactly to the algorithm of PRIM forconstructing minimum spanning forests. The same algorithm has beenused in [16] for constructing the waterfall hierarchy.This is not surprising, as for k = 1, the lexicographic weight of a NAPsimply is the weight of the first edge. The distance is in this case theultrametric flooding distance.Remark: There is a complete freedom in the choice of the flooding pairswhich are introduced at any time into D. A huge number of solutions arecompatible with this distance, some of them quite unexpected asillustrated by an example given above.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 158 / 201

Page 159: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The core expanding shortest distance algorithm

Due to the particular structure of lexicographic distances, it is possible toidentify another type of nodes for which the shortest distance mayimmediately be computed. Let ∂−D︸︷︷︸ be the set of nodes in the boundary

∂−D with the lowest valuation firstk−1(d∗k ). For each t ∈ ∂−D︸︷︷︸ and for

each s ∈ ∂+D flooding t we do ets k firstk−1 δ∗k(t) producing a NAP oflength k. The value of δ∗k(t) firstk−1 is simply obtained by appending theweight of s to firstk−1 δ∗k(t). As t belongs to ∂−D︸︷︷︸, this value is the

smallest possible.This analysis shows that each node of ∂−D︸︷︷︸ permits to introduce into D, all

its neighbors by which it is flooded, whatever their weight. This algorithmis more ”active” as Dijkstra’s algorithm, as each node inside Dk is able tolabel and introduce into D all its flooding neighbors at the same time.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 159 / 201

Page 160: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The core expanding shortest distance algorithm

The algorithm is the following;Initialisation:The nodes of the regional minima are labeled and put in the domain D.Repeat until the domain D contains all nodes:Let ∂−D︸︷︷︸ be the subdomain of D of nodes flooded by nodes outside D

with the lowest valuation firstk−1(d∗k ). For each t ∈ ∂−D︸︷︷︸ and t is flooded

by ∈ ∂+D :

D = D ∪ sδ∗k(s) = ets k firstk−1 δ∗k(t)

λ(s) = λ(t)

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 160 / 201

Page 161: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Controlling the core expanding shortest distance algorithm

The core expanding shortest distance algorithm may also beadvantageously controlled by a hierarchical queue structure. Each node, asit is introduced in D is put into the HQ. As long the HQ is not empty, theextracted node is among the nodes with the lowest estimate, the onewhich has been introduced in the HQ first. This node gives its label andthe correct distances to all its neighbors outside D by which it is flooded.If a node extracted from the HQ belongs to a plateau, as it has beenintroduced in the HQ, it is closer to the lower boundary of the plateauthan other nodes which may have been introduced in the HQ later.The algorithm is particularly suitable for a hardware implementation: eachnode is entered in the HQ only once. On the contrary, with theMoore-Dijkstra algorithm a node may be introduced several times in theHQ, as its estimate may vary before it gets its definitive value.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 161 / 201

Page 162: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The core expanding shortest distance algorithm: casewhere k = 1

The domain ∂−D︸︷︷︸ has been defined as the subdomain of D of nodes

flooded by nodes outside D with the lowest valuation firstk−1(d∗k ). For

k = 1, we have firstk−1(d∗k ) is empty, and ∂−D︸︷︷︸ occupies the whole domain

∂−D. This means that any node in ∂−D can be expanded by appendingone of the outside node through which it is flooded. The algorithms forconstructing graph cuts by J.Cousty find also their place in this context [9]We have illustrated this situation earlier, showing that the minimumspanning forests with 0 steepness may be absolutely unexpected.Controling the algorithm with a hierarchical queue limits the anarchy tosome extend.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 162 / 201

Page 163: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The core expanding shortest distance algorithm: casewhere k = 2

If k = 2, then the valuation firstk−1(d∗′k i)) = first1(d∗2 (i)) is the valuation

of the node i itself. This means that ∂−D︸︷︷︸ contains the nodes with lowest

weight belonging to ∂−D. If i is such a node, it introduces into D each ofits neighbors j belonging to ∂+D, each with a valuation first1(d∗2 (j)) equalto its weight nj .If in addition, one uses a HQ for controlling the process, we get theclassical algorithm for constructing catchment basins [17],[19].

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 163 / 201

Page 164: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The classical watershed algorithm

Label the nodes of the minima and them in the domain D, each with apriority with a weight.As long as the HQ is not empty, extract the node j with the highestpriority from the HQ:For each unlabeled neighboring (on the flooding graph) node i of j :

* label(i) = label(j)* put i in the queue with priority νi

As a matter of fact, this algorithm has first been derived from thewatershed line, as zone of influence of the minima for the topographicdistance, defined below.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 164 / 201

Page 165: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The topographic distance

Consider an arbitrary path π = (x1, x2, ..., xp) between two nodes x1 andxn. The weight νp at node xp can be written:νp = νp − νp−1 + νp−1 − νp−2 + νp−2 − νp−3 + .... + ν2 − ν1 + ν1

The node k − 1 is not necessarily the lowest node of node k , thereforeνk−1 ≥ εnνk and νk − νk−1 ≤ νk − εnνk .Replacing each increment νk − νk−1 by νk − εnνk will produce a sumνp − εnνp + νp−1 − εnνp−1 + .... + ν2 − εnν2 + ν1 which is larger thanνp. It is called the topographic length of the path π = (x1, x2, ..., xp). Thepath with the shortest topographic length between two nodes is called thetopographic distance between these nodes.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 165 / 201

Page 166: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The topographic distance

The path with the shortest topographic length between two nodes is calledthe topographic distance between these nodes [23],[19]. It will only beequal to νp in the case where the path (x1, x2, ..., xp) precisely is a path ofsteepest descent, from each node to its lowest neighbor. In other terms thetopographic distance and the distance lexdist2 have the same geodesics.If we define the toll to pay along a path π = (x1, x2, ..., xp) as ν1 for thefirst node and νi − εnνi for the others, then the lowest toll distance for anode xp to a regional minimum will be νp if there exists a path of steepestdescent from xp to x1. In other terms, xp and x1 belong to the samecatchment basins if one considers the topographic distance. But they alsobelong to the same catchment basin if one considers the depth 2lexicographic distance, as, by construction, xk is the lowest neighbor ofxk−1.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 166 / 201

Page 167: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Distance on a node weighted graph based on the cost fortravelling along the cheapest path

We recall the toll distance presented earlier.The weights are assigned to the nodes and not to the edges. Each nodemay be considered as a town where a toll has to be paid.Cost of a path: The cost of a path is equal to the sum of the tolls to bepaid in all towns encountered along the path (including or not one or bothends).Cost between two nodes: The cost for reaching node y from node x isequal to the minimal cost of all paths between x and y . We writetolldist(x , y). If there is no path between them, the cost is equal to ∞.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 167 / 201

Page 168: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration of the cheapest path

In this figure, the shortest chain between x and y is in red and the totaltoll to pay is 1 + 1 + 2 + 2 = 6

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 168 / 201

Page 169: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Reconstruction of an image by integration

Finally, any image f may be considered as the global toll of its pixel graphif one takes:

as reference nodes the regional minima of the image. Each of themhas as toll its altitude.

as local toll for all other nodes, the difference between their altitudeand the altitude or their lowest neighbor: g = f − εf

If in addition, we give a different label to each regional minimum, we mayas previously propagate this label along each smallest toll path. We obtainlike that a tessellation: to each minimum is ascribed a catchment basin:the set of all nodes which are closer to this minimum then to any otherminimum.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 169 / 201

Page 170: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Inversely: the catchment basins of the cheapest paths for adistribution of tolls.

Inversely we may chose a number of starting nodes called roots, with a tollto pay and for all other nodes, the toll to pay for reaching or crossing thisnode. The toll to pay constitutes a topographic surface where each root isa regional minimum. In addition we propagate the labels of the minimaalong the geodesics of the cheapest distance, and get a partition of thenodes. As a result one get a partition of the space, where each region witha given label is the catchment basin of the root with the same label forthis distance function.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 170 / 201

Page 171: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Assigning to each node the global toll for reaching it,starting from one of the roots.

6 6 6

8 8

4 4 4

4 9

5 5 5

5 5

6 6 7

7 7

1 1 1

1 1

0 0 0

0 0

2 2 3

3 3

1 1 1

3 3

2 2 2

2 2

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 171 / 201

Page 172: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration of the cheapest path

For each node we have indicated the local toll value (left value) and theglobal toll to pay to reach the closest reference node, who shares the samecolor (label):

Each reference node became a regional minimum of the graph.The local toll of any other node is equal to the difference between itsglobal toll and the global toll of its lowest neighbor.Each non reference node got its value and label from one of its lowestneighbors.The values of the nodes are computed and the labels propagatedalong a path of steepest descent.

6

4 5

6

1 0

2

1

8

9 5

7

1 0

3

3

2 2

The catchment basins of this surface are the SKIZ of the minima, both forthe topographic distance and for the depth 2 lexicographic distance.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 172 / 201

Page 173: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration of the cheapest path

6

4 5

6

1 0

2

1

8

9 5

7

1 0

3

3

2 2

The catchment basins of this surface are the SKIZ of the minima, both forthe topographic distance and for the depth 2 lexicographic distance. Eachnode is the extremity of a geodesic line, which is the same both for the tolldistance and for the lexicographic distance of depth 2 computed on thesame topographic surface.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 173 / 201

Page 174: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Top down or bottom up

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 174 / 201

Page 175: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The influence of the depth k

For increasing values of k, the domain ∂−D︸︷︷︸ becomes smaller and smaller,

indicating that the number of equivalent catchment basins compatiblewith a given lexicographic depth is reduced as the value of k becomesbigger. This is in accordance with the fact that with increasing values ofk , the pruning ↓k becomes more and more severe.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 175 / 201

Page 176: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Obtaining catchment basins with k − steepness

After applying the operator ↓k on a flooding graph G , there remain onlyNAP with k steepness.The same is true if we apply the operator ζ(k−1) in order to prune edges ofG and subsequently restore the initial weights of the edges onto theremaining edges.If the only NAPs remaining in the graph have a k steepness, any shortestpath algorithm with a lower steepness will extract them In particular themost simple algorithms for the distances d1 or d2 will extract catchmentbasins of steepness k .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 176 / 201

Page 177: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration : lexicographic distances

The follownig 3 images show respectively the shortest lexicographicdistances of depth 1, 2 and 3. If a path is the shortest path for alexicographic distance of depth k , it also is a shortest path for alexicographic distance of smaller depth. The following three figures presentthe lexicographic distances of depth 1, 2 and 3. The partition ofcatchment basins for the distance 3 is also solution for the distance 2 and1. Similarly the partition for distance 2 is also solution for distance 1. Thenumber of solutions decreases with the lexicographic depth.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 177 / 201

Page 178: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration : lexicographic distance of depth 1

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 178 / 201

Page 179: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration : lexicographic distance of depth 2

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 179 / 201

Page 180: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Illustration : lexicographic distance of depth 3

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 180 / 201

Page 181: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Erosion and pruning

Repeating the operator ζG = (↓ εee, εnn) produces a decreasing series ofpartial graphs ζ(n)G = ζζ(n−1)G , which are steeper and steeper. In thefollowing figures, we present in red the edge which is not the lowest edgeof one of its extremities. After pruning this edge, the operator is appliedagain. Applying ζ a number n of times is equivalent to constructing thepartitions compatible with a SKIZ for a lexicographic distance of depthn + 1. In our case, ζ(3)G produces a graph with the same edges as thepruning χ applied to the graph where each edge has been weighted by itslexicographic distance of depth 4 to the nearest minimum, illustrated inthe previous figure.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 181 / 201

Page 182: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Erosion and pruning

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 182 / 201

Page 183: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The hierarchy of nested catchment basins

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 183 / 201

Page 184: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Watershed and waterfalls

The waterfall hierarchy has been introduced by S.Beucher in order toobtain a multiscale segmentation of an image [2],[3],[3]. Given atopographic surface S1, typically a gradient image of the image tosegment, a first watershed transform produces a first partition π1.The waterfall flooding of S1 consists in flooding each catchment basin upto its lowest neighboring pass point, producing like that a topographicsurface with less minima. The watershed segmentation of this surfaceproduces a coarser partition π2 where each region is the union of anumber of regions of π1.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 184 / 201

Page 185: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Chaining the waterfall floodings

Flooding each catchment basin of S1 up to its lowest pass point producesa new topographic surface S2 which will be submitted to the sametreatment as the initial surface S1. Its watershed transform produces asecond partition π2. The partition π2 is coarser than π1 as each of its tileis a union of tiles of π1.The following figure shows how the flooding of S1

produces S2, which, in the second figure, has also been flooded.

The same process can be repeated several times until a completely flatsurface is created. The partitions obtained by the watershed constructionon the successive waterfall floodings are coarser and coarser : they form ahierarchy.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 185 / 201

Page 186: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

The waterfall hierarchy

A 1 dimensional topographic surface is represented through the altitude ofits pass points in the figure below. The first flooding assigns weights to thenodes and its watershed construction produces 4 catchment basins,separated by 3 watershed lines. The second flooding has only 2 catchmentbasins separated by 1 watershed line. The last image orders the watershedlines of the initial image into 3 categories, in cyan the watershed lineswhich disappeared during the first flooding, in dark blue those whichdisappeared after the second flooding and in red the one which survivedthe second flooding.

9 1 4 3 7 10 2 6 8 5

1 1 2 1 1 3 1 1 2 1

9 1 4 3 7 10 2 6 8 5 9 1 4 3 7 10 2 6 8 5

9 1 4 3 7 10 2 6 8 5 9 1 4 3 7 10 2 6 8 5

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 186 / 201

Page 187: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Watershed and waterfalls

Let us come back to the watershed on weighted graphs. The watershed ofthe topographic surface produces a partition π1 into catchment basins,represented by its region adjacency graph RAG1. The first flooding floodseach catchment basin up to its lowest neighboring pass point. Thiscorresponds to the erosion εne of the graph RAG1. The theory of thewatershed on weighted graphs can now be applied on this graph. Theresulting watershed appears in form of minimum spanning forest MSF1;each tree of the forest spans a catchment basin of the partition π2.The next level of the hierarchy may be represented by a new regionadjacency graph RAG2, whose nodes are obtained by contracting each treeof the forest MSF1 in the graph RAG1. Repeating the same treatment tothe graph RAG2 produces the next level of the hierarchy, where each treeof the minimum spanning forest MSF2 has been obtained by mergingseveral trees of the MSF1. The process is then repeated until a graph iscreated with only one regional minimum.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 187 / 201

Page 188: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Construction of the level 1 of the hierarchy

We start with an arbitrary node or edge weighted and connected graphG . As explained earlier, we extract a graph flooding graph G ′. For asteepness k , we prune G ′ and get ↓k G ′. The scissor operator χ producesa minimum spanning forest F1 = χ ↓k G ′, spanning the finest watershedpartition, the lowest level of the hierarchy.The graph representing the second level of the hierarchy is obtained bycontracting all edges of the forest F1 ; each tree becomes one node. Thenodes are connected by edges of the graph G . The result of thiscontraction G ′1 = κ(G , F1). is again a connected graph, to which the sametreatment as previously can be applied.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 188 / 201

Page 189: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Construction of the level 2 of the hierarchy

Only the nodes of the graph G ′1 are weighted : G ′1 = (e1, ). The nodeswill be weighted with εne and we get the graph (e1, εnee1), which becomesa flooding graph of steepness k in ↓k (e1, εnee1). A final scissor operatorcreates a forest F2 spanning nodes of G ′1. F2 represents the level 2 of thehierarchy, and the nodes of G spanned by each of its trees constitutes acatchment basin of level 2.The contraction κ(G ′1, F1) produces again a connected graph G ′2 = (e1, )to which the same treatment may be applied.This process is repeated until the graph κ(G ′m, Fm) contains a uniqueregional minimum of edges.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 189 / 201

Page 190: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Emergence of a minimum spanning tree

Each new minimum spanning forest Fn makes use of new edges of theinitial graph. The union of all MSF constructed up to the iteration m,⋃k≤m

Fk , is a minimum spanning forest of the initial graph G , which

converges to a MST of G as m increases. Hence the union of all edgespresent in the series Fn is a minimum spanning tree of the graph G .The particular minimum spanning tree which emerges depends upon thedepth k of the pruning operator ↓k , and of the particular choices amongalternative solutions made by the pruning operators χ used at each step.We call the operator extracting the minimum spanning tree µ(G ).The figure in the next slide presents a RAG, its flooding graph in the firstrow, and in the second row the MSFs

⋃k≤m

Fk for m = 1, 2, 3. The last one

being the MST.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 190 / 201

Page 191: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Emergence of a minimum spanning tree

RAG Flooding graph

MSF level 1 MSF level 2 MSF level 3

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 191 / 201

Page 192: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Emergence of a minimum spanning tree

If G and G ′ are two flooding trees, G ′ being a partial tree of G included inG , then the pruning operators χ have less choices for pruning G ′ as forpruning G . For this reason the family of MST derived for G ′ is included inthe family of MST derived for G : µ(G ′) ⊂ µ(G ) .In particular if one considers the decreasing sequence of minimumspanning forests χ ↓k G , one obtains decreasing families of MST : fork < l , we have

µ(↓l G )

µ(↓k G )

. The choices are more and moreconstrained. One gets minimum spanning trees which are steeper andsteeper for increasing k in ↓k G .

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 192 / 201

Page 193: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Discussion

All MSTs of an edge weighted graph share a fundamental property :between any two nodes of the graph, there exists a unique path in theMST which links them, and this path has a minimal flooding weight.Thanks to this property, replacing the graph G by its MST T permits toconstruct the catchment basins linked to the lexdist1 . This procedure isfast but has no control on the quality of the result if one chooses an MSTat random (the one which is produced by the preferred MST extractionalgorithm). Fast, as there are as the number of edges is strongly reduced(in a tree : number of edges = number of nodes -1). Limiting, as one hasno control on the steepness of the watershed which is ultimately extracted.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 193 / 201

Page 194: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Discussion

In order to get high quality partitions and segmentations, one has tocarefully chose the MST. The preceding slide has shown that the MSTsform a decreasing family of trees as their steepness increases. Higherquality segmentations will be obtained for a higher steepnes. In order toimprove things, one may prune the graph G with the operator ζk beforeextracting one of its MST, yielding a MST of k-steepness.One has then to consider a trade-off between the required speed and thequality of results one targets. This obviously also depends on the type ofgraphs. Some graphs contain only very few MST ; in the extreme case, agraph where all edges have distinct weights, contains a unique MST.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 194 / 201

Page 195: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Conclusion

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 195 / 201

Page 196: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Outcome

Starting with the flooding adjunction, we have introduced the floodinggraphs, for which node and edge weights may be deduced one from theother.Each node weighted or edge weighted graph may be transformed in aflooding graph, showing that there is no superiority in using one or theother, both being equivalent.We have introduced pruning operators ↓k and ζ(k) which extractsubgraphs of increasing steepness. For an increasing steepness, the numberof never ascending paths becomes smaller and smaller. This reduces thewatershed zone, where catchment basins overlap.The scissor operator χ, associating to each node outside the regionalminima one and only one edge choses a particular watershed partition.Again, with an increasing steepness, the number of equivalent solutionsbecomes smaller. Ultimaterly, for natural image, an infinite steepness leadsto a unique solution, as it is not likely that two absolutely identical nonascending paths of infinite steepness connect a node with two distinctminima.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 196 / 201

Page 197: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Outcome

Finally, we have shown that the NAP paths remaining after the pruning ↓kor ζ(k) are identical with geodesics of lexicographic distances.We have shown how the path algebra may be adapted to lexicographicdistances.We have presented the Moore-Dijkstra algorithm for constructing skeletonsby zone of influence for lexicographic distances.For the depth 1, the lexicographic distance becomes the flooding distanceand the algorithms become classical algorithms for constructing minimumspanning forests.For the depth 2, it is equivalent with the topographic distance.The beneficial effect of hierarchical queue algorithms is highlighted, as itpermits to correctly divide plateaus among neighboring catchment basins.We also presented the core expanding algorithms which are particularlyefficient for lexicographic distances.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 197 / 201

Page 198: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Outcome

The waterfall hierarchy is obtained by contracting the trees of a firstwatershed construction and the new graph submitted to a novel watershedconstruction. The process is iterated until only one region remains.The union of the edges of all forests produces constitute a minimumspanning tree of the initial graph.MST and MSF defined before only for edge weighted graphs may beextended to node weighted graphs.MST and MSF may be ordered into nested classes according to theirsteepness.The classical order is thus inverted : classically a MST is extracted fromthe graph as a first step, and a MSF derived from it, by cutting a numberof its edges. This way of doing leaves not much control as the quality ofthe result depends upon the choice of the MST.As MST and MSF may be ordered into nested classes according to theirsteepness.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 198 / 201

Page 199: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Outcome

The algebraic approach to the watershed presented here sets the stage inwhich a number of earlier definitions and algorithms may be reinterpreted :

the waterfall algorithm [3]

the watershed line defined a zone of influence of the minima forvarious distances, in particular the flooding distance and thetopographic distance [19],[23]. In the case of the flooding distanceapplied on an edge weighted graph, one finds the graph cuts [9], andthe algorithm for constructing a waterfall hierarchy described in [16]

the role of the hierarchical queues for a correct division of plateausbetween catchment basins if one uses myopic distances [17]

We also explored the place of the choice for constructing a watershedpartition. The choice becomes more and more restricted as one considerslexicographic distances with increasing depth.The waterfall hierarchy transposed to MST provides a hierarchicaldecomposition of the MST.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 199 / 201

Page 200: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Outcome

Old algorithms may be reinterpreted, in particular those relying on pruningand labeling graphs [7], [15], [24],[28].The classical algorithm for constructing watersheds derived from thehierarchical queues is a particular case of core expanding algorithm.In order to reduce the number of equivalent watershed partitions one isable to extract from a flooding graph, one may use a mixture of pruningζ(k) up to a given depth, and on the resulting graph apply a myopicalgorithm, with a lexicographic depth of 1 or 2.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 200 / 201

Page 201: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

References

The watershed transform introduced by S.Beucher and C. Lantuejoul [4] isone of the major image segmentation tools, used in the community ofmathematical morphology and beyond. If the watershed is a successfulconcept, there is another side of the coin: a number of definitions andalgorithms coexist, claiming to construct a wartershed line or catchmentbasins, although they obviously are not equivalent. We have presentedhow the idea was conceptualized and implemented as algorithms orhardware solutions in a brief note :” The watershed concept and its use insegmentation : a brief history” (arXiv:1202.0216v1), which contains anextensive bibliography. Here we give a more restricted list of references.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 201 / 201

Page 202: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

[1] C. Berge.Graphs.Amsterdam: North Holland, 1985.

[2] S. Beucher.Segmentation d’Images et Morphologie Mathematique.PhD thesis, E.N.S. des Mines de Paris, 1990.

[3] S. Beucher.Watershed, hierarchical segmentation and waterfall algorithm.ISMM94 : Mathematical Morphology and its applications to SignalProcessing, pages 69–76, 1994.

[4] S. Beucher and C. Lantuejoul.Use of watersheds in contour detection.In Proc. Int. Workshop Image Processing, Real-Time Edge andMotion Detection/Estimation, 1979.

[5] S. Beucher and C. Lantuejoul.Use of watersheds in contour detection.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 201 / 201

Page 203: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

In Watersheds of Functions and Picture Segmentation, pages1928–1931, Paris, May 1982.

[6] S. Beucher and F. Meyer.The morphological approach to segmentation: the watershedtransformation.In E. Dougherty, editor, Mathematical morphology in imageprocessing, chapter 12, pages 433–481. Marcel Dekker, 1993.

[7] Moga A. Bieniek, A.An efficient watershed algorithm based on connected components.Pattern Recognition, 33(6):907–916, 2000.cited By (since 1996) 78.

[8] Gunilla Borgefors.Distance transformations in digital images.Comput. Vision Graph. Image Process., 34:344–371, June 1986.

[9] Jean Cousty, Gilles Bertrand, Laurent Najman, and Michel Couprie.Watershed cuts: Minimum spanning forests and the drop of waterprinciple.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 201 / 201

Page 204: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

IEEE Transactions on Pattern Analysis and Machine Intelligence,31:1362–1374, 2009.

[10] M. Gondran and M. Minoux.Graphes et Algorithmes.Eyrolles, 1995.

[11] H. Heijmans.Morphological Image Operators, Advances in Electronics and ElectronPhysics, Supplement 24, Editor-in-Chief P. Hawkes.Boston: Academic Press, 1994.

[12] H. Heijmans and C. Ronse.The algebraic basis of mathematical morphology, part I: Dilations anderosions.Comput. Vision, Graphics and Image Processing, 50:245–295, 1990.

[13] C. Lantuejoul.La squelettisation et son application aux mesures topologiques demosaıques polycristallines.PhD thesis, Ecole nationale superieure des mines de Paris, 1978.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 201 / 201

Page 205: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

[14] C. Lantuejoul and S. Beucher.On the use of the geodesic metric in image analysis.J. Microsc., 1981.

[15] F. Lemonnier.Architecture Electronique Dediee aux Algorithmes Rapides deSegmentation Bases sur la Morphologie Mathematique.PhD thesis, E.N.S. des Mines de Paris, 1996.

[16] B. Marcotegui and S. Beucher.Fast implementation of waterfalls based on graphs.ISMM05 : Mathematical Morphology and its applications to SignalProcessing, pages 177–186, 2005.

[17] F. Meyer.Un algorithme optimal de ligne de partage des eaux.In Proceedings 8eme Congres AFCET, Lyon-Villeurbanne, pages847–857, 1991.

[18] F. Meyer.Minimal spanning forests for morphological segmentation.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 201 / 201

Page 206: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

ISMM94 : Mathematical Morphology and its applications to SignalProcessing, pages 77–84, 1994.

[19] F. Meyer.Topographic distance and watershed lines.Signal Processing, pages 113–125, 1994.

[20] F. Meyer and S. Beucher.Morphological segmentation.JVCIP, 1(1):21–46, Sept. 1990.

[21] Fernand Meyer.Grey-weighted, ultrametric and lexicographic distances.In Christian Ronse, Laurent Najman, and Etienne DecenciA¨re,editors, Mathematical Morphology: 40 Years On, volume 30 ofComputational Imaging and Vision, pages 289–298. SpringerNetherlands, 2005.

[22] E.F. Moore.The shortest path through a maze.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 201 / 201

Page 207: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

In Proc. Int. Symposium on Theory of Switching, volume 30, pages285–292, 1957.

[23] Laurent Najman and Michel Schmitt.Watershed of a continuous function.Signal Processing, 38(1):99 – 112, 1994.Mathematical Morphology and its Applications to Signal Processing.

[24] D. Noguet.A massively parallel implementation of the watershed based oncellular automata.In Application-Specific Systems, Architectures and Processors, 1997.Proceedings., IEEE International Conference on, pages 42 –52, jul1997.

[25] Jos B. T. M. Roerdink and Arnold Meijster.The watershed transform: Definitions, algorithms and parallelizationstrategies.Fundamenta Informaticae, 41:187–228, 2001.

[26] J. Serra, editor.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 201 / 201

Page 208: Watersheds, waterfalls, on edge or node weighted …Watersheds, waterfalls, on edge or node weighted graphs Fernand Meyer Centre de Morphologie Math ematique Mines-ParisTech 2012 February

Image Analysis and Mathematical Morphology. II: TheoreticalAdvances.Academic Press, London, 1988.

[27] Soille Pierre Vincent, Luc.Watersheds in digital spaces: An efficient algorithm based onimmersion simulations.IEEE Transactions on Pattern Analysis and Machine Intelligence,13(6):583–598, 1991.

[28] Iwanowski M. Aswiercz, M.Fast, parallel watershed algorithm based on path tracing.Lecture Notes in Computer Science (including subseries LectureNotes in Artificial Intelligence and Lecture Notes in Bioinformatics),6375 LNCS(PART 2):317–324, 2010.

Fernand MeyerCentre de Morphologie MathematiqueMines-ParisTech ()Watersheds, waterfalls, on edge or node weighted graphs2012 February 29 201 / 201