Top Banner
2009-05-13 Digital Image Processing Achim J. Lilienthal AASS Learning Systems Lab, Dep. Teknik Room T1209 [email protected] Marco Trincavelli Part 6: Binary Image Operations and Morphological Image Processing Course Book Chapter 2.5 + 9
120

Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Aug 17, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

2009-05-13

Digital Image Processing

Achim J. Lilienthal

AASS Learning Systems Lab, Dep. Teknik

Room T1209

[email protected]

Marco Trincavelli

Part 6: Binary Image Operations and

Morphological Image Processing

Course Book Chapter 2.5 + 9

Page 2: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

1. Binary Image Operations

z Basic Concepts of Set Theory (Recap)

z Logic Operations (Recap)

z Neighbourhood Relations

z Distance Measures

2. Basic Morphological Operators

z Dilation, Erosion

z Opening, Closing

z Hit-or-Miss Transform

Contents

Page 3: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

3. Morphological Algorithms

z Boundary Extraction, Region Filling

z Extraction of Connected Components

z Convex Hull

z Thinning, Thickening

z Skeletonization

Contents

Page 4: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Binary Image Operations

Contents

Page 5: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Binary Image Operations1

z Basic Concepts of Set Theory

union of A and B:

C=AB={c|cA or cB}

intersection of A and B:

C=AB={c|cA and cB}

disjoint/mutually exclusive: AB=

AB

AB

Page 6: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Logic Operations Involving Binary Images1

A B

NOT A A AND B

A OR B A XOR B

XOR

Page 7: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Neighbourhood Relations1

z Neighbourhood Relations Between Pixels

y a pixel has 4 or 8 neighbours in 2D

depending on the neighbour definition:

x 4-neighborhood N4(p)

each neighbor must share

an edge with the pixel

x ND(p): diagonal neighbors of p

x 8- neighborhood N8(p)

each neighbor must share

an edge or a corner with the pixel

Page 8: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Adjacency

y 4-adjacency

x p and q are similar, and q is in N4(p)

y 8-adjacency

x p and q are similar, and q is in N8(p)

y m-adjacency (mixed)

x p and q are similar, and either

• q is in N4(p), or

• q is in ND(p) and

the set N4(p)N4(q) does not contain similar pixels

x "include diagonal pixels if not 4-connected anyway"

Neighbourhood Relations1

Page 9: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. LilienthalAchim J. Lilienthal

Neighbourhood Relations1

z Adjacency

y 4-adjacency

x p and q are similar, and q is in N4(p)

y 8-adjacency

x p and q are similar, and q is in N8(p)

y m-adjacency (mixed)

x p and q are similar, and either

• q is in N4(p), or

• q is in ND(p) and

the set N4(p)N4(q) does not contain similar pixels

y two image subsets S1 and S2 are adjacent if ... ?

Page 10: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Adjacency

y 4-adjacency

x p and q are similar, and q is in N4(p)

y 8-adjacency

x p and q are similar, and q is in N8(p)

y m-adjacency (mixed)

x p and q are similar, and either

• q is in N4(p), or

• q is in ND(p) and

the set N4(p)N4(q) does not contain similar pixels

y two image subsets S1 and S2 are adjacent if

some pixel in S1 is adjacent to some pixel in S2.

Neighbourhood Relations1

Page 11: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Path Between p and q

y two pixels p=(x0,y0) and q=(xn,yn) are connected if there

is a sequence of adjacent pixels between p and q (a path)

y length of the path is n

Neighbourhood Relations1

p=(x0,y0)

q=(xn,yn)

(x1,y1)

(xn-1,yn-1)

adjacent

adjacent

...

Page 12: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Path Between p and q

y 4-, 8-, or m-path (depending on the type of adjacency)

Neighbourhood Relations1

4-path 8-path

Page 13: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Connected Components

y S: subset of pixels in an image

y pixels p and q are connected in S if there is a path

between them consisting only of pixels from S

y for any pixel p in S, the set of pixels in S connected to p

is called a connected component of S

y every two pixels in a connected

component are connected

y S is a connected set if it has only

one connected component

(a region of an image)

Neighbourhood Relations1

8-connected set

Page 14: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. LilienthalAchim J. Lilienthal

Binary Image Operations1

z Boundary

y consider a region R (= connected set)

y boundary := ?

x discuss appropriate definitions

Page 15: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Binary Image Operations1

z Boundary

y consider a region R (= connected set)

y boundary := the set of pixels

with one or more neighbours not in R

y

Page 16: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

Contents

Page 17: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Mathematical Morphology

y mathematical tools to deal with form and structure

y "the language of mathematical morphology is set theory"

x sets 2 in case of binary images

x sets 3 in case of gray-scale images

z Application

y pre-processing: noise-filtering, shape simplification, …

y enhancing object structure: skeletonization, convex hull, …

y segmentation: watershed

y quantitative description: area, perimeter, …

2 Basic Morphological Operators

Page 18: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation And Erosion

y defined with respect to a structuring element (SE)

z Structuring Element (Kernel)

y small set to probe the image

y defined by an origin …

y … and its shape and size

z Basic Idea

y check a condition for the structuring element

y output pixel = 1 if condition is satisfied, 0 otherwise

2

Page 19: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

})ˆ(|{ ABzBA z

z Dilation ( + )

y does the mirrored SE

(set B) touch the set A?

y grows objects

y dilation of A by B (SE):

all z such that

B hits A when B is translated by z

(i.e. the origin of B is at z)

})ˆ(|{ AABzBA z or

B

^

^

2

Page 20: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation ( + ), Example

2

B

Page 21: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 22: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 23: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 24: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 25: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 26: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 27: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 28: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 29: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 30: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation Example

2

BA

Page 31: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion (⊖)

y does the SE

(set B) fit into the set A?

y shrinks objects

y erosion of A by B (SE):

all z such that B

translated by z is contained in A

(i.e. the origin of B is at z)

2

B

})(|{ ABzBA z

Page 32: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

B

Page 33: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

BA

Page 34: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

BA

Page 35: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

BA

Page 36: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

BA

Page 37: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

BA

Page 38: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

BA

Page 39: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

BA

Page 40: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

BA

Page 41: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Erosion Example

2

BA

Page 42: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation

y bridging gaps

z Erosion

y eliminating small details

z Structuring Element

y specifies the structure of elements ...

x ... that are removed by erosion

x ... that are filled by dilation

y is typically symmetric about the origin BB ˆ

2

B

Page 43: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Different Structuring Elements, Dilation

2

Page 44: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Different Structuring Elements, Dilation

2

Page 45: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Different Structuring Elements, Erosion

2

Page 46: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Different Structuring Elements, Erosion

2

Page 47: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation and Erosion Duality

y dilation and erosion are duals of each other

with respect to set complementation and reflection

2

BABA CC ˆ

BAA B CBA

Page 48: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Dilation and Erosion Duality

y dilation and erosion are duals of each other

with respect to set complementation and reflection

2

BABA CC ˆ

CAA B̂ BAC ˆ

Note: set B is

reflected twice!

Page 49: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Opening (∘) = Erosion Followed by Dilation

y smoothes wrt to the foreground (the contour objects)

x breaks "narrow" isthmuses

x eliminates "thin" protrusions

y "narrow" / "thin" in relation to the SE

y geometric interpretation

x "structuring element rolling inside"

2

BBABA

ABBBA zz

Page 50: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Geometric Interpretation of Opening

y union of all (B)z where (B)z fits into A

2

ABBBA zz

ABBwwBA zz

Page 51: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Opening

2

A A⊖B

Page 52: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Opening

2

A⊖B A∘B

Page 53: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Opening

2

A A⊖B

Page 54: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Opening

2

A⊖B A∘B

Page 55: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Opening

y eliminating irrelevant detail …

... without affecting the remaining parts

2

erosion: SE=square of size 13x13

dilation: SE=square of size 13x13

BBABA

Page 56: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Closing () = Dilation Followed by Erosion

y smoothes with respect to the background

x fuses "narrow" breaks

x eliminates "small" holes

y "narrow" / "thin" in relation to the SE

y geometric interpretation

x "structuring element rolling outside"

2

BBABA

ABBBA zz

C

Page 57: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Geometric Interpretation of Closing

y complement of the union of all (B)z where (B)z fits into AC

2

Czz ABBBA

Page 58: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Closing

2

A A+ B

Page 59: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Closing

2

A+ B AB

Page 60: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Closing

2

A+ B AB

Page 61: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Closing

2

A A+ B

Page 62: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Closing

2

A+ B AB

Page 63: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Closing

2

A+ B AB

Page 64: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Properties of Opening and Closing

z Opening

y A∘B is a subset of A ("opening of A is A")

y if C is a subset of D then C∘B is a subset of D∘B

y repeated openings have no effect (idempotent)

z Duality

y see next slide ...

2

BDBCDC

BABBA

Page 65: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Properties of Opening and Closing

z Closing

y A is a subset of AB ("closing of A is A")

y if C is a subset of D then CB is a subset of DB

y repeated closings have no effect (idempotent)

z Opening and Closing Duality

y duals with respect to complementation and reflection

2

BDBCDC

BABBA

BABA CC ˆ

Page 66: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Properties of Opening and Closing

z Opening and Closing Duality

y duals with respect to complementation and reflection

2

A A∘B (A∘B)C

AC ACB

BB ˆ

Page 67: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

2009-05-13

Digital Image Processing

Achim J. Lilienthal

AASS Learning Systems Lab, Dep. Teknik

Room T1209

[email protected]

Marco Trincavelli

Part 6: Binary Image Operations and

Morphological Image Processing

Course Book Chapter 2.5 + 9

Page 68: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Application: Filtering (Opening + Closing)

y eliminating noise with little morphological distortion

2

original image

Page 69: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Application: Filtering (Opening + Closing)

1. erosion: A⊖B

2

Page 70: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Application: Filtering (Opening + Closing)

2. dilation: (A⊖B) + B = A∘B

2

Page 71: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Application: Filtering (Opening + Closing)

3. dilation: (A∘B) + B

2

Page 72: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators

z Application: Filtering (Opening + Closing)

4. erosion: ((A∘B) + B)⊖B = (A∘B)B

2

Page 73: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

z Hit-or-Miss Transform (⊛)

y find pixels with a specific neighbourhood

("template matching")

y composite structuring element:

object part (B1) and background part (B2)

y does B1 fit the object while simultaneously

B2 misses the object, i.e. B2 fits the background

y with B = (B1,B2); B1: object (X), B2: local background (W – X)

Page 74: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

z Hit-or-Miss Transform (⊛)

A=XYZ

B1 B2

A⊖B1

YX

Z

Page 75: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

z Hit-or-Miss Transform (⊛)

AC

B1 B2

AC⊖B2

YX

Z

Page 76: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

z Hit-or-Miss Transform (⊛)

AC

B1 B2

AC⊖B2

YX

Z

Page 77: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

z Hit-or-Miss Transform (⊛)

B1 B2

A⊛X=(A⊖B1)(Ac⊖B2)A=XYZ

Page 78: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

z Hit-or-Miss Transform (⊛)

y find pixels with a specific neighbourhood

("template matching")

y composite structuring element:

object part (B1) and background part (B2)

y does B1 fit the object while simultaneously

B2 misses the object, i.e. B2 fits the background

y with B = (B1,B2); B1: object (X), B2: local background (W – X)

21)( BABABA C

)ˆ()( 21 BABABA

Page 79: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

z Applications of the Hit-or-Miss Transform

y locate isolated foreground pixels

x no neighbouring foreground pixels

y locate foreground endpoints

x one or zero neighbouring foreground pixels

y locate foreground contour points

x pixels having at least one neighbouring background pixel

y locate multiple foreground points

x pixels having more than two neighbouring foreground pixels

Page 80: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

4-connected isolated points (A⊛B)

SE for 4-connected isolated points

z Hit-or-Miss Transform to Find Isolated Points

y how should the HMT structuring elements look like?

input image4-connected isolated points (A⊛B)

Page 81: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

z Hit-or-Miss Transform to Find Isolated Points

input image 4-connected isolated points (A⊛B)

B1 B2

SE for 4-connected isolated points

Page 82: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

4-connected isolated points (A⊛B)

SE for 4-connected isolated points

z Hit-or-Miss transform to find 4-connected endpoints

y how should the HMT structuring elements look like?

input image endpoints

Page 83: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Basic Morphological Operators2

z Hit-or-Miss Transform to Find Foreground Endpoints

input image endpoints (A⊛Ba A⊛Bb A⊛Bc A⊛Bd)

B1 Ba2 Bb

2 Bc2 Bd

2

SEs for 4-connected endpoints

Page 84: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms

Contents

Page 85: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms3

z Boundary Extraction

y (A) boundary of A

y boundary extraction

x erosion and set difference )()( BAAA

8-connected boundary boundary 4-connected with AC

4-connected boundary boundary 8-connected with AC

Page 86: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms3

z Region Filling

y start with a point p = X0 inside the boundary

y iterative dilation, complementation, and intersection

y terminate if Xk = Xk-1

y final result:

set union Xk-1 A

! intersection with Ac limits

the result to inside the

region of interest

c

kk ABXX 1

A Ac

black = background

Page 87: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms3

z Region Filling

A

B

X0 X1 X2

X6 X7 X8

X7 A

Ac

Page 88: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Region Filling

y requires a seed pixel inside the boundary

seed

one filled final resultwhite discs with

black spots

not straightforward to automatise

Morphological Algorithms3

Page 89: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Extraction of Connected Components3

z Extraction of the Connected Component Y in A

y start with a point p = X0 inside Y

y iterative dilation and intersection with A

y terminate if Xk = Xk-1

y final result:

set union Y=Xk-1=Xk

! intersection with A keeps

the result to the object Y

in A

ABXX kk 1

X0

Page 90: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Extraction of Connected Components3

B

X0

X1 X2

X3 X4 Y

Page 91: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms – Convex Hull3

z Convex Hull – Definitions

y convex region R

x straight line from x1 to x2 is in R for any x1, x2R

y convex hull H of a region R

x smallest convex set containing R

y convex deficiency D

x H – R

R: green

H: green + brown

D: brown

Page 92: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms – Convex Hull3

z Obtaining a Convex Region

y set of Structuring Elements

x can contain don’t care symbols

x typically obtained from one

structuring element by rotation

y iterative Hit-or-Miss transform

x iteratively apply HMT with Bi to A

x simplified HMT where no background match is required

x stop if convergence is achieved ( Di) if Xk = Xk-1

y final result

x union of the resulting Di

Bi

don’t care

Page 93: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms – Convex Hull3

z Obtaining a Convex Region

y initialisation

y iterative Hit-or-Miss transform with Bi

y convergence and final result

AX i 0

iI

i

DAC 1

)(

i

k

i

k

i

k

i XXXD1

,

,...3,2,1,,...,2,1,1 kIiABXX i

k

i

k

Page 94: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms – Convex Hull3

z Obtaining a Convex Region

Xi0=A X1

4

Page 95: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms – Convex Hull3

z Obtaining a Convex Region

X14 X2

2 X38 X4

2

Page 96: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms – Convex Hull3

z Obtaining a Convex Region

Page 97: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms – Convex Hull3

z Obtaining a Convex Region

y problem

x C(A) is convex but not necessarily minimal in size

y limit growth to the original dimensions

x horizontally and vertically or more complex (diagonal, ...)

Page 98: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Morphological Algorithms – Thinning3

z Thinning – Idea

y finding structural elements to preserve

x topology, end points

y iterative use of Hit-or-Miss transform – one thinning pass:

y simplified HMT where no background match is required

z Alternative Expression for Symmetric Thinning

y thin by a suitable sequence of B={B1,B2,...,Bn}

y repeat whole sequence until no further changes occur

)( BAABA cBAABA )(

nBBBABA ...... 21

Page 99: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Thinning

B1 B2 B3 B4 B5 B6 B7 B8

A A ⊗ B1

3 Morphological Algorithms – Thinning

Page 100: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Thinning

A ⊗ B2 A ⊗ B3

A ⊗ B4 A ⊗ B5

B2

B4 B5

B3

Morphological Algorithms – Thinning3

Page 101: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Thinning

A ⊗ B6 A ⊗ B7

A ⊗ B8 A ⊗ B1

B1

B6

B8

B7

Morphological Algorithms – Thinning3

Page 102: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Thinning

... A ⊗ B4 A ⊗ B5

A ⊗ B6

B4 B5

B6... no further changes

Morphological Algorithms – Thinning3

Page 103: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Morphological Dual of Thinning

y definition: iterative use of Hit-or-Miss transform

y can also be defined as a sequential operation

y can be implemented as thinning the background

x A Ac

x thin Ac Ac ⊗ {B}

x complement the result A {B} = (Ac ⊗ {B})c

)( BAABA

nBBBABA ...... 21

Morphological Algorithms – Thickening3

Page 104: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

A Ac

Ac ⊗{B}

(Ac ⊗{B})c

disconnected points removed

Morphological Algorithms – Thickening3

Page 105: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Skeletonization Algorithms

y residual of openings (Serra[1982]) GW pp. 543

y Distance Transformation

x detecting ridges in distance map of the boundary points

Morphological Algorithms – Skeletonization3

Page 106: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Distance Transform

z Distance Transform

y representation of distances in an image

y transformation from binary image to DT image

y distance transform as grey-level landscape

x each object pixel is labelled

with the distance to its closest pixel in the background

y skeleton = maxima in the distance

to the border

3

Page 107: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Distance Transform – Examples3

z Distance Transform Examples – Euclidean Distance

Page 108: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

city block chess board

Distance Transform – Examples3

Page 109: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

city block chess board

Distance Transform – Examples3

Page 110: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

0 0 0 0 0 0 0 1 1 2

0 0 0 0 0 0 1 1 2 2

0 0 0 0 0 1 1 2 2 3

0 0 0 0 1 1 2 2 3 3

0 0 0 1 1 2 2 3 3 4

0 0 1 1 2 2 3 3 4 4

0 1 1 2 2 3 3 4 4 5

0 1 2 2 3 3 4 4 5 5

0 1 2 3 3 4 4 5 5 6

0 1 2 3 4 4 5 5 6 6

0 0 0 0 0 0 0 1 2 3

0 0 0 0 0 0 1 2 3 4

0 0 0 0 0 1 2 3 4 5

0 0 0 0 1 2 3 4 5 6

0 0 0 1 2 3 4 5 6 7

0 0 1 2 3 4 5 6 7 8

0 1 2 3 4 5 6 7 8 9

0 1 2 3 4 5 6 7 8 9

0 1 2 3 4 5 6 7 8 9

0 1 2 3 4 5 6 7 8 9

city block chess board

Distance Transform – Examples3

Page 111: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

Distance Transform3

z Distance Transform as Grey Level Landscape

Page 112: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Distance Transform for Path Planning

y used for robot navigation

y constrained DT

x find shortest path

x avoid obstacles

x basic DT + obstacle regions

Distance Transform – Applications3

Page 113: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

obstaclep0constrained distance transform

Distance Transform for Path Planning3

Page 114: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Hill Climbing Using Steepest Path

Distance Transform for Path Planning3

Page 115: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

3

z Distance Transform for Thickness Measurements

y DT gives a rough measure

of the object’s thickness

at each point

y the highest distance label

in the object

gives the maximum thickness

Distance Transform – Applications

Page 116: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Distance Transform, Sensitivity to Noise

3 Distance Transform

Page 117: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

z Skeletonization Algorithms

y residual of openings (Serra[1982]) GW pp. 543

y Distance Transformation

x detecting ridges in distance map of the boundary points

y Voronoi diagram

x partitioning of a plane

into convex polygons

such that each polygon

contains one generating point

and every point in a polygon

is closer to its generating point

than to any other

Morphological Algorithms – Skeletonization3

Page 118: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

1. Binary Image Operations

z Basic Concepts of Set Theory (Recap)

z Logic Operations (Recap)

z Neighbourhood Relations

z Distance Measures

2. Basic Morphological Operators

z Dilation, Erosion

z Opening, Closing

z Hit-or-Miss Transform

Contents

Page 119: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

Achim J. Lilienthal

3. Morphological Algorithms

z Boundary Extraction, Region Filling

z Extraction of Connected Components

z Convex Hull

z Thinning, Thickening

z Skeletonization

Contents

Page 120: Part 6: Binary Image Operations and Morphological Image ...130.243.105.49/Research/Learning/courses/dip/2011/... · Digital Image Processing Achim J. Lilienthal AASS Learning Systems

2009-05-13

Digital Image Processing

Achim J. Lilienthal

AASS Learning Systems Lab, Dep. Teknik

Room T1209

[email protected]

Marco TrincavelliMarco Trincavelli

Course Book Chapter 2.5, 9

Part 3: Binary Image Operations and

Morphological Image Processing

Thank you!