89
Morphological Image Processing

Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Morphological Image Processing

Page 2: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Introduction

•  In many areas of knowledge Morphology deals with form and structure (biology, linguistics, social studies, etc)

•  Mathematical Morphology deals with set theory

•  Sets in Mathematical Morphology represents objects in an Image

2

Page 3: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

•  Used to extract image components that are useful in the representation and description of region shape, such as

–  boundaries extraction –  skeletons –  convex hull (italian: inviluppo convesso) –  morphological filtering –  thinning –  pruning

Mathematic Morphology

3

Page 4: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Mathematic Morphology mathematical framework used for: •  pre-processing

–  noise filtering, shape simplification, ...

•  enhancing object structure –  skeletonization, convex hull...

•  segmentation –  watershed,…

•  quantitative description –  area, perimeter, ...

4

Page 5: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Z2 and Z3

•  set in mathematic morphology represent objects in an image –  binary image (0 = white, 1 = black) : the element of the set is the

coordinates (x,y) of pixel belong to the object a Z2

•  gray-scaled image : the element of the set is the coordinates (x,y) of pixel belong to the object and the gray levels a Z3

5

X axis

Y axis Y axis

X axis Z axis

Page 6: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Basic Set Operators

6

Set operators Denotations

A Subset B A ⊆ B

Union of A and B C= A ∪ B

Intersection of A and B C = A ∩ B

Disjoint A ∩ B = ∅

Complement of A Ac ={ w | w ∉ A}

Difference of A and B A-B = {w | w ∈A, w ∉ B }

Reflection of A Â = { w | w = -a for a ∈ A}

Translation of set A by point z(z1,z2) (A)z = { c | c = a + z, for a ∈ A}

Page 7: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Basic Set Theory

7

Page 8: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Reflection and Translation

8

ˆ B = {w ∈ E 2 : w = −b, for b∈ B}

(A)z = {c ∈ E 2 : c = a + z, for a∈ A}

Page 9: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Logic Operations

9

Page 10: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Example

10

Page 11: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Structuring element (SE)

11

§  small set to probe the image under study §  for each SE, define origin §  shape and size must be adapted to geometric properties for the objects

Page 12: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Basic idea

•  in parallel for each pixel in binary image: –  check if SE is ”satisfied” –  output pixel is set to 0 or 1 depending on used

operation

12

Page 13: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

How to describe SE

•  Can be described in many different ways •  information needed:

–  position of origin for SE –  positions of elements belonging to SE

13

Page 14: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Five Binary Morphological Operations

•  Erosion

•  Dilation

•  Opening

•  Closing

•  Hit-or-Miss transform

14

Page 15: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Basic morphological operations

•  Erosion

•  Dilation •  combine to keep general shape but smooth with respect to

–  Opening object –  Closening background

15

Page 16: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Erosion

•  Does the structuring element fit the set?

•  Erosion of a set A by structuring element B: all z in A such that B is in A when origin of B=z

shrink the object

16

})(:{ 2 ABEzBA z ⊆∈=−

Page 17: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Erosion

17

Page 18: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 18

Page 19: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 19

Page 20: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Erosion •  Properties

–  L’erosione non è commutativa

–  L’erosione è associativa quando l’elemento strutturante è decomponibile intermini di dilatazioni:

–  Se l’elemento strutturante contiene l’origine (O ∈ B) l’erosione è una trasformazione antiestensiva: l’insieme eroso è contenuto nell’insieme

–  L’erosione è una trasformazione crescente

20

Page 21: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Erosion

21

Page 22: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Erosion

22

Page 23: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Erosion •  Consideriamo ora l’immagine binaria seguente:

•  A causa del valore troppo elevato della soglia alcuni oggetti che

dovrebbero essere separati risultano connessi. Ciò può introdurre degli errori nelle elaborazioni successive (ad esempio, nel conteggio del numero di oggetti presenti nell’immagine).

23

Page 24: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Erosion

24

Page 25: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Dilation •  Does the structuring element hit the set?

•  Dilation of a set A by structuring element B: all z in A such that B hits A when origin of B=z

grow the object

25

Page 26: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Dilation

26

Page 27: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Dilation •  Properties

•  La dilatazione è commutativa –  A ⊕ B = B ⊕ A

•  La dilatazione è associativa –  A ⊕ (B ⊕ C) = (A ⊕ B) ⊕ C

•  Se l’elemento strutturante contiene l’origine (O ∈ B) la dilatazione è una trasformazione estensiva: l’insieme originario è contenuto nell’insieme dilatato (A ⊆ A ⊕ B )

•  La dilatazione è una trasformazione crescente –  A ⊆ C ⇒ A ⊕ B ⊆ C ⊕ B

27

Page 28: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Dilation

28

Page 29: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Dilation

29

Page 30: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Dilation •  Supponiamo ora di binarizzare l’immagine seguente

utilizzando una soglia troppo bassa:

•  A causa del valore troppo basso di soglia l’oggetto presenta delle lacune

30

Page 31: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 31

Examples of Dilation (1)

Page 32: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Dilation : Bridging gaps

32

Page 33: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Usefulness

•  Erosion –  Removal of structures of certain shape and size,

given by SE

•  Dilation –  Filling of holes of certain shape and size, given by SE

33

Page 34: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Combining erosion and dilation

•  WANTED: –  remove structures / fill holes –  without affecting remaining parts

•  SOLUTION: –  combine erosion and dilation –  (using same SE)

34

Page 35: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Erosion : eliminating irrelevant detail

35

structuring element B = 13x13 pixels of gray level 1

Page 36: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Dilation: filling •  Infine, la dilatazione viene usata insieme agli operatori logici per

eseguire operazioni morfologiche più complesse. –  Un esempio è l’operazione di filling, che ricostruisce le regioni

associate agli oggetti (immagine binaria Io) “riempiendo” i contorni estratti mediante un edge detector. Supponendo di aver estratto i contorni (immagine binaria IB) e di conoscere almeno un pixel appartenente all’oggetto (immagine binaria X0), è possibile ricostruire l’oggetto calcolando iterativamente la relazione:

–  dove con B si è indicato l’elemento strutturante

36

Page 37: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Dilation: filling (cont.) –  Quando il calcolo della relazione converge (Xn+1 = Xn)

si può ottenere Io dalla relazione: Io = (Xn) OR (IB)

37

Page 38: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Relazione di dualità fra erosione e dilatazione

•  Detto

•  In generale vale che

38

Page 39: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Relazione di dualità fra erosione e dilatazione

•  Se B è simmetrico

•  quindi la dilatazione dell’oggetto è “equivalente” all’erosione dello sfondo e l’erosione dell’oggetto è “equivalente” alla dilatazione dello sfondo. –  Le operazioni di erosione e dilatazione per uno stesso elemento

strutturante possono essere impiegate in sequenza al fine di eliminare dall’immagine binaria le parti aventi forma “diversa” da quella dell’elemento strutturante senza distorcere le parti che invece vengono mantenute.

39

Page 40: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Opening

Erosion followed by dilation, denoted ∘

•  eliminates protrusions •  breaks necks •  smoothes contour

40

BBABA ⊕−= )(

Page 41: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Opening

41

Page 42: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Opening

42

Page 43: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 43

Example: Opening

Page 44: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Closing

Dilation followed by erosion, denoted • •  smooth contour •  fuse narrow breaks and long thin gulfs •  eliminate small holes •  fill gaps in the contour

44

BBABA −⊕=• )(

Page 45: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Closing

45

Page 46: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Closing

46

Page 47: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 47

Example: Closing

Page 48: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Properties

48

Opening (i)  A°B is a subset (subimage) of A (ii)  If C is a subset of D, then C °B is a subset of D °B (iii)  (A °B) °B = A °B

Closing (i)  A is a subset (subimage) of A•B (ii)  If C is a subset of D, then C •B is a subset of D •B (iii)  (A •B) •B = A •B

Note: repeated openings/closings have no effect!

Page 49: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 49

Page 50: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Duality •  Opening and closing are dual with respect to complementation and

reflection

•  Possiamo sfruttare la dualità per comprendere l’effetto dell’operazione di closing. Poichè il closing dell’oggetto è “equivalente” all’opening dello sfondo, l’operatore di closing esegue il “matching” fra l’elemento strutturante (o il suo riflesso) e le parti dello sfondo, preservando quelle uguali all’elemento strutturante (o al suo riflesso) ed eliminando (cioè annettendo all’oggetto) quelle diverse. Il sostanza l’oggetto viene “dilatato” annettendo le parti dello sfondo diverse da B ( o da ).

50

(A • B)c = (Ac ˆ B )

ˆ B

Page 51: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

51

Page 52: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Usefulness: open & close

52

Page 53: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Application: filtering

53

Page 54: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 54

Page 55: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Hit-or-Miss Transformation ⊛ (HMT)

•  find location of one shape among a set of shapes ”template matching”

•  composite SE: object part (B1) and background part (B2) •  does B1 fits the object while, simultaneously, B2

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

55

)]([)( XWAXABA c −−∩−=∗

Page 56: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Hit-or-Miss Transformation, example (1)

56

This is a powerful method for finding shapes in images. As with all other morphological algorithms, it can be defined entirely in terms of dilation and erosion; in this case, erosion only. Suppose we wish to locate 3x3 square shapes, such as is in the centre of the following image

Page 57: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

57

If we performed an erosion with B being the square structuring element, we would obtain the result given in the following figure

Hit-or-Miss Transformation, example (2)

The result contains two pixels, as there are exactly two places in A where B will fit. Now suppose we also erode the complement of A with a structuring element C which fits exactly around the 3x3 square. (we assume (0,0) is the centre of C)

Page 58: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

58

Hit-or-Miss Transformation, example (3)

If we now perform the erosion we would obtain the result

The intersection of the two erosion operations would produce just one pixel at the position of the centre of the 3x3 square in A, which is just what we want. If had contained more than one square, the final result would have been single pixels at the positions of the centres of each. This combination of erosions forms the hit-or-miss transform.

Page 59: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

59

Hit-or-Miss Transformation, example (4)

Page 60: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

60

Hit-or-Miss Transformation, example (5)

In general, if we are looking for a particular shape in an image, we design two structural elements: B1 which is the same shape, and B2 which fits around the shape. We then write B=(B1,B2) and the Hit-and-miss transform as

Page 61: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 61

Page 62: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Boundary Extraction

62

)()( BAAA −−=β

Page 63: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Example

63

Page 64: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Region Filling

64

,...3,2,1 )( 1 =∩⊕= − kABXX ckk

Page 65: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Example

65

Page 66: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Extraction of connected components

66

Page 67: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Convex hull

•  A set A is is said to be convex if the straight line segment joining any two points in A lies entirely within A.

67

i

iDAC

4

1)(

=∪=

,...3,2,1 and 4,3,2,1 )( ==∪∗= kiABXX iik

ik

Page 68: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Thinning

19/04/17 68

•  Thinning The thinning of a set A by a structuring element B,

defined ( * )

( * )cA B A A B

A A B⊗ = −

= ∩

Page 69: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 69

•  A more useful expression for thinning A symmetrically is based on a sequence of structuring elements:

{ } { }1 2 3

-1

, , ,...,

where is a rotated version of

n

i i

B B B B B

B B

=

1 2

The thinning of by a sequence of structuring element { } { } ((...(( ) )...) )n

A BA B A B B B⊗ = ⊗ ⊗ ⊗

Page 70: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

19/04/17 70

Page 71: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Thinning

71

cBAABAABA)()(

∗∩=

∗−=⊗

Page 72: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Thickening

72

)( BAABA ∗∪=•

Page 73: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Skeletons

73

K

kk ASAS0)()(

=

∪=

BkBAkBAASk )()()( −−−=

})(|max{ Φ≠−= kBAkK

))((0

kBASA k

K

k⊕∪=

=

Page 74: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Skeletons

74

Page 75: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Pruning

75

}{1 BAX ⊗=

AHXX ∩⊕= )( 23

314 XXX ∪=

H = 3x3 structuring element of 1’s

)( 1

8

12k

kBXX ∗∪=

=

Page 76: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Relation between sets and images

76

Sets and binary images. The relation between a binary image and a set X: X is defined by all the pixels with grey value 1

Page 77: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Relation between sets and images

77

This idea can be expanded so that we can define a relation between grey valued images and sets: we regard each specific grey level in the image as a set; we regard the image f as a stack of sets F with the relation

Page 78: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Examples with grayscale images

78

http://maverick.inria.fr/Membres/Adrien.Bousseau/morphology/morphomath.pdf

Page 79: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

79

Page 80: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Examples with grayscale images

80

http://maverick.inria.fr/Membres/Adrien.Bousseau/morphology/morphomath.pdf

Page 81: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Examples with grayscale images

81

http://maverick.inria.fr/Membres/Adrien.Bousseau/morphology/morphomath.pdf

Page 82: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Examples with grayscale images

82

http://maverick.inria.fr/Membres/Adrien.Bousseau/morphology/morphomath.pdf

Page 83: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Examples with grayscale images

83

http://maverick.inria.fr/Membres/Adrien.Bousseau/morphology/morphomath.pdf

Page 84: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Examples with Color images

84

http://maverick.inria.fr/Membres/Adrien.Bousseau/morphology/morphomath.pdf

Page 85: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

Examples with Color images

85

http://maverick.inria.fr/Membres/Adrien.Bousseau/morphology/morphomath.pdf

Page 86: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

86

Page 87: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

87

Page 88: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

88

Page 89: Morphological Image Processing · If we now perform the erosion we would obtain the result The intersection of the two erosion operations would produce just one pixel at the position

89