this lecture is about mathematical...

58
This lecture is about Mathematical Morphology Lecture 10 c 2002 Fredrik Georgsson, Umeå University Page 1

Upload: others

Post on 07-Oct-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

This lecture is about

• Mathematical Morphology

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 1

Page 2: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

• Within biology, the term morphology is

used for the study of the shape and

structure of animals and plants

• In image processing mathematical

morphology is theoretical framework for

representation, description and

pre-processing.

• The mathematical morphology is based on

set-theory

• The mathematical morphology is an

example of non-linear operations

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 2

Page 3: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 3

Page 4: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Linear filtering

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 4

Page 5: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Morphological filtering

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 5

Page 6: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Median filtering

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 6

Page 7: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 7

Page 8: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Low pass filtered image

05

1015

2025

3035

0

10

20

30

40

0

50

100

150

200

250

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 8

Page 9: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Background subtracted

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 9

Page 10: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Morphological filtered background

05

1015

2025

3035

0

10

20

30

40

0

50

100

150

200

250

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 10

Page 11: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Background subtracted

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 11

Page 12: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology

Let A and B be sets of points from Z2 with

objects a = (a1, a2) and b = (b1, b2).

The Translation of A with x = (x1, x2) is

defined as:

(A)x = {c | c = a + x, ∀a ∈ A}

The Reflection of A is defined as:

A = {x | x = −a, ∀a ∈ A}

The Complement of A is defined as:

Ac = {x | x /∈ A}

The Difference between two sets is defined as:

A−B = {x | x ∈ A, x /∈ B} = A ∩Bc

The intersection and union of sets is supposed

to be familiar

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 12

Page 13: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology The Basics

• A set represents a shape in mathematical

morphology

• Binary images is a subset of Z2 where each

pixel is a tuple of coordinates (x, y) for

either the black or white pixels.

• Intensity images is a subset of Z3 where

each element is a three-dimensional points

who’s first two elements describe the

spatial locality and the last element

describes the intensity at that point.

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 13

Page 14: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Dilation

The Dilation of A ⊂ Z2 and B ⊂ Z

2 is

defined as

A⊕B = {x | (B)x ∩A 6= Ø}

The dilation is all translations x that yields an

intersection between A and the reflected B that

is not the empty set.

∴ dilation ensures that the intersection between

A and B is a subset of A or

A⊕B = {x | [(B)x ∩A] ⊆ A}

B is called the structuring element of the

dilation (as in all other morphological

operations).

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 14

Page 15: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Dilation

1 1 1

1 1 1

1 1 1

Original image Dilated image

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 15

Page 16: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Dilation

1 0 0

0 1 0

0 0 1

Original image Dilated image

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 16

Page 17: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Dilation

A more intuitive definition of the dilation is

(Minkowsky addition)

A⊕B =⋃

b∈B

(A)b

This is, of course, equivalent to the previous

definition

Proof

→: Suppose that x ∈ A⊕B, then there is an

a ∈ A and b ∈ B so that x = a + b which mean

that x ∈ (A)b

←: Suppose that x ∈⋃

b∈B(A)b then there is a

b ∈ B, x ∈ (A)b. This implies that it exists

ana ∈ A so that x = a + b implying that

x ∈ A⊕B

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 17

Page 18: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Dilation

The Minkowsky addition allows us to visualize

the dilation as follows: A copy of the structure

element B is placed at each point x ∈ A.

B

A A⊕B

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 18

Page 19: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Erosion

The Erosion of A ⊂ Z2 and B ⊂ Z

2 is defined

as:

AB = {x | (B)x ⊆ A}

In other words: The Erosion of A with B are

the translation x in which B is completely

covered by A.

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 19

Page 20: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Erosion

1 1 1

1 1 1

1 1 1

Original image

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 20

Page 21: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Erosion

1 0 0

0 1 0

0 0 1

Original image Eroded image

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 21

Page 22: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Duality

Erosion and dilation are dual with with respect

to complement and reflection:

(AB)c = Ac ⊕ B

Since (starting from definitions)

(AB)c = {x | (B)x ⊆ A}c (1)

= {x | (B)x ∩Ac = ∅}c (2)

= {x | (B)x ∩Ac 6= ∅} (3)

= Ac ⊕ B (4)

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 22

Page 23: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Opening

• By combining erosion with dilation

according to

A ◦B = (AB)⊕B

we have an operation that is called

opening.

• The Opening smooths objects by

removing pixels

• An other definition is

A ◦B =⋃

{(B)x | (B)x ⊂ A}

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 23

Page 24: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Closing

• By reversing the erosion and dilation in the

opening, a closing operation is defined:

A •B = (A⊕B)B

• Closing smooths objects by adding pixels.

• All smoothing (both for closing and

opening) is in relation to the size of the

structuring element B.

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 24

Page 25: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Closing

Original image Opened image

Original image Closed image

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 25

Page 26: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Dualitet

Opening and closing are dual with respect to

complement and reflection

(A •B)c = ((A⊕B)B)c

= (A⊕B)c ⊕ B

= {x | (B)x ∩A 6= ∅}c ⊕ B

= {x | (B)x ∩A = ∅} ⊕ B

= {x | (B)x ∩Ac 6= ∅} ⊕ B

= {x | (B)x ⊆ Ac} ⊕ B

= (Ac B)⊕ B

= (Ac ◦ B)

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 26

Page 27: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Dualitet

For opening the following holds

1. A ◦B ⊂ A

2. If C ⊂ D then C ◦B ⊂ D ◦B

3. (A ◦B) ◦B = A ◦B

and for closing

1. A ⊂ A •B

2. If C ⊂ D then C •B ⊂ D •B

3. (A •B) •B = A •B

Operators for which property (3) holds are said

to be idempotent. That is, it does not matter

how many times the operation is applied, the

result is the same as if it only had been applied

once.

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 27

Page 28: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology (A ◦B) •B

Original image

Opened image

Opened+Closed image

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 28

Page 29: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology (A •B) ◦B

Original image

Closed image

Closed+Opened image

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 29

Page 30: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology (A •B) ◦B

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 30

Page 31: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Hit & Miss

If the aim is to locate objects in an image we

can do the following:

1. By calculating AX all objects smaller

than X will vanish. X is reduced to a

point.

2. By calculating Ac (W −X), where W is a

frame to the object, all objects larger than

X will vanish, X is reduced to a point.

The intersection between (1) and (2) will be

the mid-point for each X in the image.

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 31

Page 32: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Hit & Miss

Or slightly more formal:

(AX) ∩ [Ac (W −X)]

If we let B = (B1, B2) and B1 = X,

B2 = W −X we have

A ~ B = (AB1) ∩ (Ac B2)

Which can be written as

A ~ B = (AB1) ∩ (Ac B2) (5)

= (AB1)− (Ac B2)c (6)

= (AB1)− (A⊕ B2) (7)

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 32

Page 33: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Hit & Miss

A R1 = AX

W −X R2 = Ac (W −X)

R1 ∩R2 (R1 ∩R2)⊕X

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 33

Page 34: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Edge

extraction

The pixels that constitutes the edge of an

object A is defined as the points that belong to

the object and has at least one neighbor that

belongs to the background.

These pixels are denoted β(A), and are

precisely the pixels that are removed by

performing an erosion B,

β(A) = A− (AB)

Original image, A A−(A eroded with B)

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 34

Page 35: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Region

growing

Given that we know a point p in side a region

defining with a contour A we can let the point

grow until it fills the entire region by iterating

with

Xk = (Xk−1 ⊕B) ∩Ac

until Xk = Xk+1. X0 is sat to be p.

If the region is 8-connected the complement

will be 4-connected and B must have the

following appearance

0 1 0

1 1 1

0 1 0

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 35

Page 36: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Region

growing

Original Regionfill after 90 iterations

Regionfill after 180 iterations Regionfill after 253 iterations

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 36

Page 37: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Connected

components

Given a point p inside an object we can use the

same principle as in region-growing with a

slight modification. The difference is that the

since object is now defined by ones (and not

zeros surrounded by a contour) we do not have

to invert A.

Xk = (Xk−1 ⊕B) ∩A

where X0 = p.

If A is 8-connected, the object will be

8-connected and we have to use the following B

1 1 1

1 1 1

1 1 1

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 37

Page 38: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Connected

components

Original Connected comp. after 15 iterations

Connected comp. after 30 iterations Connected comp. after 41 iterations

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 38

Page 39: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Convex hull

• Given a set A we can find an

approximation to the convex hull C(A)

by repeated application of

Xik = (X ~ Bi) ∪A

where i = 1, 2, 3, 4 and k = 1, 2, 3, . . ..

Bi are different structuring elements.

• For each i, {X ik} will converge to a set Di.

• The convex hull is the union of all Di

C(A) =

4⋃

i=1

Di

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 39

Page 40: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Convex hull

• The following Bi are used in the algorithm

B1

1 × ×

1 0 ×

1 × ×

B2

1 1 1

× 0 ×

× × ×

B3

× × 1

× 0 1

× × 1

B4

× × ×

× 0 ×

1 1 1

× indicates don’t care.

• This definition (with don’t care) makes it

impossible to use MatLabs implementation

of dilation and erosion since they only use

binary structuring elements.

• The convex hull is implemented in MatLab

by using look-up tables (LUT), see help

makelut and help applylut for more

information.

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 40

Page 41: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Convex hull

Result X416

Result X126

Result X236

Result X320

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 41

Page 42: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Convex hull

Approximation of convex hull

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 42

Page 43: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Math

em

atic

alM

orpholo

gy

Convex

hull

Result X126

Result X236

Result X320

Result X416

Result X531

Result X630

Result X763

Result X830

Lecture

10

c©2002

Fredrik

Georgsson,U

meå

Univ

ersity

Page

43

Page 44: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Convex hull

Approximation of convex hull

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 44

Page 45: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology The Skeleton

The skeleton S(A) of an object A can be

expressed as

S(A) =K⋃

k=0

Sk(A)

where

Sk(A) = (A kB)−((A kB) ◦B

)

and

K = max{k | (A kB) 6= Ø}

and finally

(A kB) = ((. . . ((AB)B) . . .)B︸ ︷︷ ︸

k times

Observe: There is nothing in the algorithm

that guarantees that S(A) will be a connected

component.

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 45

Page 46: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology The Skeleton

An object and its skeleton

K = 15

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 46

Page 47: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology The Skeleton

• A nice property of S(A) is the A can be

reconstructed if we know K.

• This is not possible with a normal skeleton

• The reconstruction is made according to

A =K⋃

k=0

(Sk(A)⊕ kB)

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 47

Page 48: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Pruning

• After finding the skeleton, it is often

desirable to remove short branches from

the graph that constitutes the skeleton.

This is done by removing end-points from

the graph without breaking connectivity.

• Given knowledge of the object (that is how

long branches that can be expected) we

can remove just enough of the graph.

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 48

Page 49: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Pruning

Image, skeleton and graph

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 49

Page 50: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Gray level

• To use mathematical morphology on

gray-scale images the crisp set theory must

be replaced by fuzzy set theory.

• This means that each point (x, y) has a

membership function f(x, y) describing

the degree of membership that the point

has to the foreground and background.

• f(x, y) is the image, b(x, y) is the

structuring element. f c(x, y) is defined as

−f(x, y) and b(x, y) as b(−x,−y).

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 50

Page 51: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Gray level

Dilation A dilation of f with b is defined as

(f ⊕ b)(s, t) = max{f(s− x, t− y) + b(x, y) |

(s− x), (t− y) ∈ Df , (x, y) ∈ Db}

Erosion The erosion of f with b is defined as

(f ⊕ b)(s, t) = min{f(s− x, t− y)− b(x, y) |

(s− x), (t− y) ∈ Df , (x, y) ∈ Db}

Df and Db are the domain for f and b

respectively. Since (x, y) ∈ Db only the points

in the support of f and b can be members of

the final set.

Dilation and erosion are still dual :

(f b)c(x, y) = (f c ⊕ b)(x, y)

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 51

Page 52: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Gray level

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 52

Page 53: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Gray level

Eroded image

Dilated image

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 53

Page 54: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Gray level

• The Opening of f with b is defined as

(f ◦ b)(s, t) = ((f ⊕ b) b)(s, t)

• The opening suppress bright objects

smaller than the structuring element b

• The Closing of f with b is defined as

(f • b)(s, t) = ((f b)⊕ b)(s, t)

• The closing suppress dark objects smaller

than the structuring element b.

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 54

Page 55: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Gray level

Opened image

Closed image

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 55

Page 56: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Gray level

• A morphological low-pass filtering can

be calculated as

l = (f ◦ b) • b

• A morphological gradient filtering can

be calculated as

g = (f ⊕ b)− (f b)

• A ’top-hat’ transform is defined as

h = f − (f ◦ b)

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 56

Page 57: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Gray level

Opened and closed image

Morphological gradient

Top−Hat

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 57

Page 58: This lecture is about Mathematical Morphologycmp.felk.cvut.cz/cmp/courses/dzo/resources/lecture_morphology_georgsson.pdfThis lecture is about Mathematical Morphology Lecture 10 c 2002

Mathematical Morphology Gray level

Gray-level morphology is implemented in

MatLab (see imdilate, imerode,. . . )

However, these implementations require b to be

a binary function. A more general

implementation (as the one used in the

Gonzales book) is given by:

function F=grayerode(f, b)

B=im2col(b,size(b),’sliding’);

fun=inline(’min(x-P1*ones(1,length(x)))’,1);

F=colfilt(f,size(b),’sliding’,fun,B);

function F=graydilate(f, b)

B=im2col(b,size(b),’sliding’);

fun=inline(’max(x+P1*ones(1,length(x)))’,1);

F=colfilt(f,size(b),’sliding’,fun,B);

Lecture 10 c©2002 Fredrik Georgsson, Umeå University Page 58