motivation connected component treecwjs70/c2comptree.pdf · connected components labeling with...

Post on 04-Aug-2020

4 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 1

Connected Component Tree

Jean Cousty

FOUR-DAY COURSE

on

Mathematical Morphology in image analysis

Bangalore 19-22 October 2010

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 2

Motivation

Connectivity plays important role for image processing

Morphological connected filters

Morphological filters acting on components of a set

Morphological filters acting on components of the flat zones of a function

Graphs are adapted for handling digital connectivity

How can connected filters be efficiently implemented?

Problem

2

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 3

Outline

Connected filters on (weighted) graphs

Connected components

Component tree

Example of application

Algorithms for connected filters on (weighted) graphs

Union of disjoint set

Connected component labeling

Component tree extraction

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 4

Structuring a discrete set

Let V be a set

(eg, the set of all image pixels)

Let X be a subset of V

(eg, a binary object to be processed)

3

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 5

Discrete set

V (white & black dots) and X (black dots)

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 6

Discrete set

V (white & black dots) and X (black dots)

4

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 7

Graph

Neighborhood (in blue) of a point (in red)

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 8

Graph

Vertex set (dots) and edge set E (line segments) of a graph (V,E)

5

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 9

Connected sets

Let G = (V,E) be a (undirected) graph

Let X be a subset of V

X is connected if

there exists a path between any two points of X

Definition

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 10

Example: Discrete set that is not connected

6

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 11

Example: Connected discrete set

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 12

Connected components

Let G = (V,E) be a (undirected) graph.

Let X be a subset of V

Let Y be a subset of X

Y is a (connected) component of X if

Y is connected

no proper superset of Y included in X is connected

Definition

Y is a component of X iff for any x in Y

Y is the union of all connected subsets of X that conains x

Property

7

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 13

Example : Connected components partition

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 14

Connected opening a discrete set

According to a given criterion (e.g., the size), keep the most important components of X

8

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 15

Example: area filtering a discrete set

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 16

Example: area filtering a discrete set

9

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 17

From maps to sets

k

Fk = {x E, F(x) k}, i.e., points above kJ. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 18

From maps to sets

k

Fk = {x E, F(x) < k}, i.e., points below k

10

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 19

Structuring a discrete map: level sets decomposition

Let F be a map from V to N and let k be an integer

The (upper) level-set of F at level k is the set made of the points of V whose value is greater than or equal to k

Fk = {x E, F(x) k}

Definition

Any connected component of any (upper) level set of F is called a (upper) component of F

Remark

Any two components of F are either nested or disjoint

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 20

Structuring a discrete map: (upper) Component tree

Components + inclusion relation tree structure

11

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 21

Structuring a discrete map: (upper) Component tree

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 22

Level-sets, components: the 2D case

F

12

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 23

F1

Level-sets, components: the 2D case

F

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 24

Level-sets, components: the 2D case

F2F

13

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 25

F3

Level-sets, components: the 2D case

F

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 26

Level-sets, components: the 2D case

F4F

14

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 27

Cross-sections, components: the 2D case

+ + +

F

F4 F3 F2 F1

28

Component tree: the 2D case

C1 C1 C1 C1 C1C1 C1

C1 C4 C4

C1 C6 C6

C1

C1 C1

C1 C4 C4

C2

11 C1C1

C5 C7 C1

C2 C5 C7 C1

C3

C1C1

C6 C3

C1 C1 C1 C1 C1 C5 C1

C1 C1 C1C3

C3 C1

C1

C1

C2

C5C4

C7

C3

C6

C8

Level 1

Level 2

Level 3

Level 4

Component tree Component mapping

C8

15

29

Component tree: the 2D case

C1 C1 C1 C1 C1C1 C1

C1 C4 C4

C1 C6 C6

C1

C8

C1 C1

C1 C4 C4

C2

11 C1C1

C5 C7 C1

C2 C5 C7 C1

C3

C1C1

C6 C3

C1 C1 C1 C1 C1 C5 C1

C1 C1 C1C3

C3 C1

C1

C1

C2

C5C4

C7

C3

C6

C8

Level 1

Level 2

Level 3

Level 4

Component tree Component mapping

C7

C7

C8

30

Component tree: the 2D case

C1 C1 C1 C1 C1C1 C1

C1 C4 C4

C1 C6 C6

C1

C1 C1

C1 C4 C4

C2

11 C1C1

C5 C7 C1

C2 C5 C7 C1

C3

C1C1

C6 C3

C1 C1 C1 C1 C1 C5 C1

C1 C1 C1C3

C3 C1

C1

C1

C2

C5C4

C7

C3

C6

C8

Level 1

Level 2

Level 3

Level 4

Component tree Component mapping

C6 C6

C6C6

C8

C5

C5

C5C5

C5C4

C4 C4

C4

16

31

Component tree: the 2D case

C1 C1 C1 C1 C1C1 C1

C1 C4 C4

C1 C6 C6

C1

C1 C1

C1 C4 C4

C2

11 C1C1

C5 C7 C1

C2 C5 C7 C1

C3

C1C1

C6 C3

C1 C1 C1 C1 C1 C5 C1

C1 C1 C1C3

C3 C1

C1

C1

C2

C5C4

C7

C3

C6

C8

Level 1

Level 2

Level 3

Level 4

Component tree Component mapping

C8

C2

C2

C2

C2

C2

C2

C2

C2C2

C2C2

C3C3C3C3C3

C3 C3 C3

32

Component tree: the 2D case

C1 C1 C1 C1 C1C1 C1

C1 C4 C4

C1 C6 C6

C1

C1 C1

C1 C4 C4

C2

11 C1C1

C5 C7 C1

C2 C5 C7 C1

C3

C1C1

C6 C3

C1 C1 C1 C1 C1 C5 C1

C1 C1 C1C3

C3 C1

C1

C1

C2

C5C4

C7

C3

C6

C8

Level 1

Level 2

Level 3

Level 4

Component tree Component mapping

C8

C1

17

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 33

Filtering a discrete map : flooding

A leaf of the component tree T of F is:

a regional minimum of F, if T is a lower component tree

a regional maximum of F, if T is an upper component tree

According to a given criterion, we can iteratively remove the leaf components of F

Such a removal is called a flooding

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 34

Flooding: intuitive example step 1

18

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 35

Flooding: intuitive example step 1

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 36

Flooding: intuitive example step 2

19

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 37

Flooding: intuitive example step 3

We remove one branch of T

We flood one “ lobe ” of FJ. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 38

Flooding: formal definition

Let x in V

The elementary flooding of F at x is defined by:

ηxF(y) = F(y) + 1 if x and y belong to the same minimum

ηxF(y) = F(y) otherwise

Any map obtained from F by composition of elementary floodings is called a flooding of F

Definition

20

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 39

Filtering a grayscale map

What criterion (attribute) to select the non-significant minima to be flooded?

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 40

Attributes: height

h

21

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 41

Attributes: area

a

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 42

Attributes: volume

v

22

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 43

Filtering by volume

Regional minimaJ. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 44

Filtering by volume

Regional minima

23

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 45

Application: keep the 10 most volumic lobes

Original image (top) and

its many minima (bottom)

Filtered image (top) and its

10 minima (bottom)

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 46

Algorithms requested for achieving this result

Component tree algorithm

Flooding the minima with attribute below a given threshold

Or alternatively, keeping only the k most significant minima

24

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 47

Algorithms for the component tree

There exist several algorithms for the component tree

Breen & Jones 1996

Salembier, Oliveras & Garido 1998

Mattes & Demongeot 2000

Couprie & Najman 2006

Tarjan’s union find

Connected components labeling

Quasi-linear time component tree extraction

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 48

Disjoint set problem

Maintaining a collection of disjoint subsets of a set V under the operation of union

Each subset X is represented by a unique element of X called the canonical element of X

Three operations allow the collection to be managed:

MakeSet(x): add the set {x} to the collection

Find(x): return the canonical element of the set containing x

Link(x,y):

● Remove the two sets whose canonical elements are x and y

● Add their union

25

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 49

Tarjan’s union-find algorithm

Quasi-linear algorithm: O(m X α(m,|V|))

for m operations

α : inverse of Ackerman function (in practice never greater than 4)

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 50

Connected components labeling with union-find

26

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 51

Connected components labeling with union-find

12

34 6

6

3

75

2

1

47

5

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 52

Connected components labeling with union-find

12

34 6

6

3

75

2

1

47

5

27

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 53

Connected components labeling with union-find

12

34 6

6

3

75

2

1

47

5

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 54

Connected components labeling with union-find

12

34 6

6

3

75

2

1

47

5

28

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 55

Connected components labeling with union-find

12

34 5 6

6

3

75

2

1

47

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 56

Connected components labeling with union-find

12

34 5 6

6

3

75

2

1

47

29

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 57

Connected components labeling with union-find

12

34 5 6

6

3

75

2

1

47

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 58

Connected components labeling with union-find

12

34 5 6

6

3

75

2

1

47

30

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 59

Connected components labeling with union-find

12

34 5 6

6

3

75

2

1

47

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 60

Connected components labeling with union-find

12

34 5 6

6

3

75

2

1

47

31

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 61

Connected components labeling with union-find

12

34 5 6

2

2

72

2

2

27

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 62

Component tree algorithm

General case

Two collections of disjoint subsets of V

Particular case: all values are distinct

One collection of disjoint subsets of V

32

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 63

Component tree algorithm: all values distinct

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 64

Component tree algorithm: all values distinct (init)

A B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

Image Lowest Node nodes Disjoint sets

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

33

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 65

Component tree algorithm: all values distinct (step 1)

A B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = C

Image Lowest Node nodes Disjoint sets

C

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 66

Component tree algorithm: all values distinct (step 2)

A B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = G

Image Lowest Node nodes Disjoint sets

CG

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

34

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 67

Component tree algorithm: all values distinct (step 3)

A B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = A

Image Lowest Node nodes Disjoint sets

CG A

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 68

Component tree algorithm: all values distinct (step 4)

A B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = D

Image Lowest Node nodes Disjoint sets

CG A

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

35

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 69

Component tree algorithm: all values distinct (step 4)

D B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = D

Image Lowest Node nodes Disjoint sets

CG A

y = A

D

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 70

Component tree algorithm: all values distinct (step 4)

D B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = D

Image Lowest Node nodes Disjoint sets

CG A

y = G

D

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

36

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 71

Component tree algorithm: all values distinct (step 5)

H B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = H

Image Lowest Node nodes Disjoint sets

CG A

y = G

DH

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 72

Component tree algorithm: all values distinct (step 6)

E B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = E

Image Lowest Node nodes Disjoint sets

CG A

y = D

DH

E

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

37

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 73

Component tree algorithm: all values distinct (step 6)

E B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = E

Image Lowest Node nodes Disjoint sets

CG A

y = H

DH

E

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 74

Component tree algorithm: all values distinct (step 7)

I B C

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = I

Image Lowest Node nodes Disjoint sets

CG A

y = H

DH

EI

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

38

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 75

Component tree algorithm: all values distinct (step 8)

I B F

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = F

Image Lowest Node nodes Disjoint sets

CG A

y = C

DH

EI

F

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 76

Component tree algorithm: all values distinct (step 7)

I B F

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = F

Image Lowest Node nodes Disjoint sets

CG A

y = E

DH

EI

F

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

39

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 77

Component tree algorithm: all values distinct (step 7)

I B F

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = F

Image Lowest Node nodes Disjoint sets

CG A

y = I

DH

EI

F

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 78

Component tree algorithm: all values distinct (step 9)

I B B

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = B

Image Lowest Node nodes Disjoint sets

CG A

y = A

DH

EI

FB

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

40

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 79

Component tree algorithm: all values distinct (step 10)

I B B

D E F

G H I

A:7B:1C:9

D:6E:4 F:2

G:8H:5I:3DIF

E C

HA

B

G

x = B

Image Lowest Node nodes Disjoint sets

CG A

y = C

DH

EI

FB

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 80

Component tree algorithm: all values distinct

O(|V|)

O(|V|+|E|)

O(|E|.α(|E|,|V|))

O(|E|. α(|E|,|V|))

O(|E|)

O(|E|)

O(|E|)

foreach point x in V in decreasing order of altitude do

foreach neighbor y of x do

● If (F(y) > F(x)) and (Find(x) != Find(y)) do

– adjNode := lowestNode[Find(y)]

– nodes[x].addChild(nodes[adjNode])

– curNode := Link(x,adjNode)

– lowestNode[curNode] := nodes[x]

Time complexity : quasi-linear

with respect to the number of edges and vertices

Requires a sorting pre-processing step

41

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 81

Component tree algorithm: general case

Two union-find implementations needed

One for building the union of connected components over height

● Similar to the one in the case where all values were distinct

One for building the connected components of a given altitude

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 82

Build the component tree

42

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 83

Auxiliary functions

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 84

Example

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

12;

0;

2;

1;

14;

13;

3; 4; 5; 8; 9; 10; 11;

6;

7

[120]

[110]

[100]

[90]

[80]

[70]

[50]

[40]

[20]

43

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 85

step 1

[12] 120

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

Fth1

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 86

Step 2

[12] 120

0 1 1

3 4 5

12 13 14

6 7 8

9 10 11

Fth1

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[0] 110

44

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 87

step 3

[12] 120

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

Fth1

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[0] 110 [2] 100

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 88

step 4

1 1 1

3 4 5

12 13 14

6 7 8

9 10 11

Fth1

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[12] 120

[1] 90

[2] 100[0] 110

45

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 89

step 5

1 1 1

3 4 5

12 13 14

6 7 8

9 10 11

Fth1

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[12] 120

[1] 90

[2] 100[0] 110

[14] 80

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 90

step 6

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

1 1 1

3 4 5

13 13 13

6 7 8

9 10 11

Fth1

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

46

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 91

step 7

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

1 3 1

3 4 5

13 13 13

6 7 8

9 10 11

Fth1

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[3] 50

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 92

step 8

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

1 3 1

3 3 5

13 13 13

6 7 8

9 10 11

Fth1

0 1 2

3 3 5

12 13 14

6 7 8

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[3] 50

47

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 93

step 9

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

1 3 3

3 3 3

13 13 13

6 7 8

9 10 11

Fth1

0 1 2

3 3 3

12 13 14

6 7 8

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[3] 50

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 94

step 10

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

1 3 3

3 3 3

13 13 13

6 7 3

9 10 11

Fth1

0 1 2

3 3 3

12 13 14

6 7 3

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[3] 50

48

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 95

step 11

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

1 3 3

3 3 3

13 9 13

6 7 3

9 10 11

Fth1

0 1 2

3 3 3

12 13 14

6 7 3

9 10 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[3] 50 [9] 50

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 96

step 12

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

1 3 3

3 3 3

13 9 13

6 7 3

9 9 11

Fth1

0 1 2

3 3 3

12 13 14

6 7 3

9 9 11

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[3] 50 [9] 50

49

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 97

step 13

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

1 3 3

9 3 3

13 9 13

6 7 3

9 9 3

Fth1

0 1 2

9 3 3

12 13 14

6 7 3

9 9 3

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

9 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[9] 50

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 98

step 14

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

1 3 3

9 3 3

13 9 13

9 7 3

9 9 3

Fth1

0 1 2

9 3 3

12 13 14

6 7 3

9 9 3

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

6 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[9] 50

[6] 40

50

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 99

step 15

1 3 3

9 9 3

13 9 13

9 9 9

9 9 3

Fth1

0 1 2

9 3 3

12 13 14

6 7 3

9 9 3

Fth2

0 1 2

3 4 5

12 13 14

6 7 8

7 10 11

SubtreeRoot

110 90 100

50 50 50

120 70 80

40 20 50

50 50 50

[1] 90

[2] 100[0] 110 [12] 120 [14] 80

[13] 70

[9] 50

[6] 40

[7] 20

J. Serra, J. Cousty, B.S. Daya Sagar: Course on Math. Morphology 100

Component tree: conclusion

Another insight into connected filters (level sets stacking)

Useful to compute floodings

then attribute openings & closings

Efficient algorithm

Quasi-linear time

Easy implementation

Many applications in signal processing and image analysis

Important for computing connection values

There exist self-dual trees

top related