svd and digital image processing - tfe-moodle 2 · george matheron and jean serra are two founders...

100
Image Processing Morphological image processing

Upload: others

Post on 14-Aug-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Image Processing

Morphological image

processing

Page 2: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Outline

2

What is Mathematical Morphology?

Background Notions

Introduction to Set Operations on Images

Basic operation

Erosion, Dilation, Opening, Closing, Hit-or-Miss

Algorithms

Morphological operations on gray-level images

Page 3: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Morphology

3

Morphology, in biology, is the study of the size,

shape, and structure of animals, plants, and

micro-organisms and the relationships of their

internal parts.

Morphology, in linguistics, is the study of the

internal construction of words

Mathematical morphology?

Page 4: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Mathematical morphology

4

Mathematical Morphology was founded in the mid-sixties in France

George Matheron and Jean Serra are two founders of mathematical

morphology

Study of geometry of porous media

Mathematical morphology is well established discipline in applied

mathematics and image analysis

International Symposium on Mathematical Morphology

Page 5: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Mathematical morphology

5

The theory for the analysis of spatial structures

Analysis of shapes and form of objects

It is based on set theory, integral geometry and

lattice algebra

Structuring elements

Mathematical morphology framework is used for:

Image filtering (shape simplification, enhancing object

structure,...)

Image segmentation (watersheds)

Image measurements (area, perimeter, granulometry)

Pattern recognition

Texture analysis

Page 6: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Quick Example

Image after segmentation Image after segmentation and

morphological processing

6

Page 7: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

7

Morphological Image Processing…

used to extract image components that are

useful in the representation and description of

region shape, such as

boundaries extraction

skeletons

convex hull

morphological filtering

thinning

pruning

Page 8: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Morphological Image Processing

8

“Mathematical Morphology” – as a tool for extracting image

components, that are useful in the representation and description

of region shape.

Morphological image processing (or morphology) describes a

range of image processing techniques that deal with the shape

(or morphology) of features in an image

Morphological operations are typically applied to remove

imperfections introduced during segmentation, and typically

operate on bi-level images

The language of mathematical morphology is – Set theory.

Unified and powerful approach to numerous image processing

problems.

Page 9: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

9

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 Z2

gray-scaled image : the element of the set is

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

and the gray levels Z3

Page 10: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Basic Concepts in Set Theory

Subset

Union

Intersection

disjoint / mutually exclusive

Complement

Difference

Reflection

Translation

Page 11: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

11

Basic Set Theory

Page 12: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

12

Reflection and Translation

} ,|{ˆ Bfor bbwwB

} ,|{)( Afor azaccA z

Page 13: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Logic Operations Involving

Binary Pixels and Images

13

The principal logic operations used in image processing

are: AND, OR, NOT (COMPLEMENT).

These operations are functionally complete.

Logic operations are preformed on a pixel by pixel basis between

corresponding pixels (bitwise).

Other important logic operations :

XOR (exclusive OR), NAND (NOT-AND)

Logic operations are just a private case for a binary set operations, such :

AND – Intersection , OR – Union, NOT-Complement.

Page 14: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

14

Example

Page 15: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Structuring Element (SE)

15

Small set used to probe the image under study

For each SE, define an origin:

the origin of the SE is in point p

The shape and size must be adapted to geometric

properties for the objects

Page 16: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

SE can be described in many different ways!

Information needed:

Position of origin for SE

Position of elements belonging to SE

16

Structuring Element (SE)

OBS!

Matlab assumes that the center of the structuring elements is its origin

Page 17: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Structuring Elements, Hits &

Fits

B

AC

Structuring Element

Fit: All on pixels in the

structuring element cover

on pixels in the image [A]

Hit: Any on pixel in the

structuring element covers

an on pixel in the image [B]

All morphological processing operations are based

on these simple ideas 17

Page 18: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Fundamental Operations

Fundamentally morphological image

processing is very like spatial filtering

The structuring element is moved across

every pixel in the original image to give a

pixel in a new processed image

The value of this new pixel depends on the

operation performed18

Page 19: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Five binary morphological operators

⊖ Erosion

⊕ Dilation

◦ Opening

• Closing

⊗ Hit-or-Miss transform19

Page 20: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

⊖Erosion

Does the structuring element fit the set?

Erosion of a set X by structuring element B,

: all x in X such that B is in X when

origin of B is x

Gonzalez-Woods:

Shrink the object

20

Page 21: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Erosion

otherwise 0

fits if 1),(

fsyxg

Erosion of image f by structuring element s is

given by f s

The structuring element s is positioned with

its origin at (x, y) and the new pixel value is

determined using the rule:

21

Page 22: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Erosion Example

Original image Erosion by 3*3

square structuring

element

Erosion by 5*5

square structuring

element

22

Page 23: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Erosion Example 2

Original

image

After erosion

with a disc of

radius 10

After erosion

with a disc of

radius 20

After erosion

with a disc of

radius 5

23

Page 24: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Erosion can split apart

joined objects

Erosion can strip away

extrusion

Erosion shrinks objects

How is Erosion used?

24

Page 25: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Does the structuring element hit the set?

Dilation of a set X by structuring element B,

: all x in X such that the reflection of B

hits X when origin of B is x

Gonzalez-Woods:

Enlarge the object

⊕ Dilation

25

Page 26: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Dilation of image f by structuring element s is

given by f s

The structuring element s is positioned with

its origin at (x, y) and the new pixel value is

determined using the rule:

⊕ Dilation

otherwise 0

hits if 1),(

fsyxg

26

Page 27: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

⊕ Dilation Example

Original image Dilation by 3*3

square structuring

element

Dilation by 5*5

square structuring

element

27

Page 28: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Dilation Example

Structuring element

Original image After dilation

28

Page 29: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Dilation can repair

breaks

Dilation can repair

intrusions

Dilation enlarges objects

How is Dilation used?

29

Page 30: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

⊖ Erosion - properties

It is commutative

It is increasing, i.e.,

if A ⊂ C, then A ⊖ B ⊂ C ⊖ B

If the origin belongs to the structuring element B,

then the erosion is anti-extensive, i.e., A ⊖ B ⊂ A

It is distributive over set intersection, i.e.,

(A1 ∩ A2) ⊖ B = (A1 ⊖ B) ∩ (A2 ⊖ B)

It is translation invariant

30

Page 31: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

⊕ Dilation - properties

It is commutative

It is increasing, i.e.,

if A ⊂ C, then A ⊕ B ⊂ C ⊕ B

If the origin belongs to the structuring element B,

then it is extensive A ⊂ A ⊕ B

It is distributive over set union, i.e.,

(A1 ∪ A2) ⊕ B = (A1 ⊕ B) ∪ (A2 ⊕ B)

It is translation invariant

31

Page 32: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Erosion - Dilation duality

Erosion and dilation are dual with respect to complementation and

reflection

32

Page 33: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Compound Operations

More interesting morphological operations

can be performed by performing

combinations of erosions and dilations

The most widely used of these compound

operations are:

Opening

Closing

33

Page 34: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

The opening of image f by structuring

element s, denoted f ○ s is simply an erosion

followed by a dilation

f ○ s = (f s) s

◦ Opening

Original shape After erosion After dilation

(opening) 34

Page 35: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

◦ Opening

35

erosion followed by dilation, denoted ∘

eliminates protrusions

breaks necks

smoothes contour

BBABA )(

Page 36: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

◦ Opening

erosion followed by dilation, denoted ∘

eliminates protrusions

breaks necks

smoothes contour

36

BBABA )(

Page 37: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

◦ Opening Example

Original

Image

Image

After

Opening

37

Page 38: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

38

◦ Opening

BBABA )(})(|){( ABBBA zz

Page 39: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

The closing of image f by structuring element

s, denoted f • s is simply a dilation followed by

an erosion

f • s = (f s)s

• Closing

Original shape After dilation After erosion

(closing) 39

Page 40: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

• Closing

dilation followed by erosion, denoted •

smooth contour

fuse narrow breaks and long thin gulfs

eliminate small holes

fill gaps in the contour

40

BBABA )(

Page 41: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

41

• Closing

BBABA )(

Page 42: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

42

Properties

Opening(i) AB 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 AB(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 has no effect!

Page 43: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

• Closing Example

Original

Image

Image

After

Closing

43

Page 44: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Morphological Processing

Example: filtering

erosion

opening

opening

+ dilation

opening + closing

Page 45: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Morphological Algorithms

Using the simple technique we have looked at

so far we can begin to consider some more

interesting morphological algorithms

Hit-or-miss transform

Boundary extraction

Region filling

Extraction of connected components

Thinning/thickening

Skeletonisation

Pruning

45

Page 46: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

⊗ Hit-or-miss transformation

The hit-or-miss transform is a general binary

morphological operation that can be used to look

for particular patterns of foreground and

background pixels in an image.

The hit-and-miss transform is a basic tool for

shape detection.

To detect a shape:

Hit object

Miss background

46

Page 47: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

⊗ Hit-or-miss transformation

The structural elements (SE) used for Hit-or-

miss transforms are an extension to the ones

used with dilation, erosion etc.

The SE contain both foreground and background

pixels, rather than just foreground pixels, i.e. both

ones and zeros.

If the SE covers something which matches

the content of the SE it is a hit, otherwise it is

a miss

47

)()()( 21 BABABX

Page 48: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

⊗ Hit-or-miss transformation

Transformation that involves two structuring

elements

First has to fit with the object while,

simultaneously, the second has to fit the

background

First has to hit the object while, simultaneously,

second has to miss it

A ⊗ B = (A ⊖ B1) ∩ (AC ⊖ B2)

Composite SE B = (B1,B2): Object part (B1) and

background (B2)48

Page 49: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

⊗ Hit-or-miss transformation

Alternative:

A ⊗ B = (A ⊖ B1) ∩ (AC ⊖ B2)

= (A ⊖ B1) ∩ (A ⊕ ˆB2)C

= (A ⊖ B1) \ (A ⊕ ˆB2)

B1 and B2 share the same origin and are

disjoint sets

49

Page 50: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

⊗ Hit-or-miss transformation

50

Structuring

elements

Page 51: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Extracting the boundary (or outline) of an object is often

extremely useful

The boundary can be given simply as

β(A) = A – (AB)

Boundary Extraction

51

Page 52: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Boundary Extraction Example

Original Image Extracted Boundary

A simple image and the result of performing

boundary extraction using a square 3*3

structuring element

52

Page 53: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Given a pixel inside a boundary, region filling

attempts to fill that boundary with object

pixels (1s)

Region Filling

Given a point inside

here, can we fill the

whole circle?

53

Page 54: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

The key equation for region filling is

Where X0 is simply the starting point inside

the boundary, B is a simple structuring

element and Ac is the complement of A

This equation is applied repeatedly until Xk is

equal to Xk-1

Region Filling

.....3,2,1 )( 1 kABXX c

kk

54

Page 55: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Region Filling Step By Step

Page 56: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Region Filling Example

Original Image One Region

Filled

All Regions

Filled

56

Page 57: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

57

Extraction of connected

components

.....3,2,1 )( 1 kABXX kk

Page 58: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

58

Example

Page 59: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Convex hull

i

iDAC

4

1)(

,...3,2,1 and 4,3,2,1 )( kiABXX ii

k

i

k

A set A is said to

be convex if the

straight line

segment joining

any two points in

A lies entirely

within A.

59

Page 60: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Thinning

The thinning of a set A by a structuring element B, can

be defined by terms of the hit-and-miss transform:

A more useful expression for thinning A symmetrically is

based on a sequence of structuring elements:

{B}={B1, B2, B3, …, Bn}

Where Bi is a rotated version of Bi-1. Using this concept

we define thinning by a sequence of structuring

elements:

Page 61: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Thinning cont…

The process is to thin by one pass with B1 ,

then thin the result with one pass with B2, and

so on until A is thinned with one pass with Bn.

The entire process is repeated until no further

changes occur.

Each pass is preformed using the equation:

Page 62: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

62

Thinning

cBAA

BAABA

)(

)(

Page 63: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Thickening

Thickening is a morphological dual of

thinning.

Definition of thickening .

As in thinning, thickening can be defined as a

sequential operation:

the structuring elements used for thickening

have the same form as in thinning, but with

all 1’s and 0’s interchanged.

Page 64: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Thickening - cont

A separate algorithm for thickening is often used in practice, Instead the usual procedure is to thin the background of the set in question and then complement the result.

In other words, to thicken a set A, we form C=Ac , thin C and than form Cc.

depending on the nature of A, this procedure may result in some disconnected points. Therefore thickening by this procedure usually require a simple post-processing step to remove disconnected points.

Page 65: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Thickening- example

We will notice in the next example that the

thinned background forms a boundary for the

thickening process, this feature does not

occur in the direct implementation of

thickening

This is one of the reasons for using

background thinning to accomplish

thickening.

Page 66: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Thickening example

Page 67: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Thinning and Thickening

67

Page 68: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Skeleton

The notion of a skeleton S(A) of a set A is

intuitively defined, we deduce from this figure

that:

a) If z is a point of S(A) and (D)z is the largest disk

centered in z and contained in A (one cannot

find a larger disk that fulfils this terms) – this

disk is called “maximum disk”.

b) The disk (D)z touches the boundary of A at two

or more different places.

Page 69: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Skeleton The skeleton of A is defined by terms of erosions and

openings:

with

Where B is the structuring element and indicates

k successive erosions of A:

k times, and K is the last iterative step before A erodes to an empty

set, in other words:

in conclusion S(A) can be obtained as the union of

skeleton subsets Sk(A).

Page 70: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

BkBAkBAASk )()()(

70

Skeletons

K

kk ASAS

0

)()(

})(|max{ kBAkK

))((0

kBASA k

K

k

Page 71: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

71

Page 72: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Skeleton

A can be also reconstructed from subsets

Sk(A) by using the equation:

Where denotes k successive

dilations of Sk(A) that is:

Page 73: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

73

Pruning

}{1 BAX

AHXX )( 23

314 XXX

)( 1

8

12

k

kBXX

H = 3x3 structuring element of 1’s

Page 74: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

74

Page 75: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

75

Page 76: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

76

Page 77: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

77

Page 78: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Gray-Scale Images

In gray scale images on the contrary to binary

images we deal with digital image functions of

the form f(x,y) as an input image and b(x,y) as a

structuring element.

(x,y) are integers from Z*Z that represent a

coordinates in the image.

f(x,y) and b(x,y) are functions that assign gray

level value to each distinct pair of coordinates.

For example the domain of gray values can be

0-255, whereas 0 – is black, 255- is white.

Page 79: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Gray-Scale Images

Page 80: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Dilation – Gray-Scale

Equation for gray-scale dilation is:

Df and Db are domains of f and b.

The condition that (s-x),(t-y) need to be in the domain of f and x,y in the domain of b, is analogous to the condition in the binary definition of dilation, where the two sets need to overlap by at least one element.

Page 81: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Dilation – Gray-Scale (cont)

We will illustrate the previous equation in terms of

1-D. and we will receive an equation for 1 variable:

The requirements the (s-x) is in the domain of f and x is in the domain of b imply that f and b overlap by at least one element.

Unlike the binary case, f, rather than the structuring element b is shifted.

Conceptually f sliding by b is really not different than b sliding by f.

Page 82: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Dilation – Gray-Scale (cont)

The general effects of performing dilation on

a gray scale image is twofold:

1. If all the values of the structuring elements are

positive than the output image tends to be

brighter than the input.

2. Dark details either are reduced or elimanted,

depending on how their values and shape relate

to the structuring element used for dilation

Page 83: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Dilation – Gray-Scale example

Page 84: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Erosion – Gray-Scale

Gray-scale erosion is defined as:

The condition that (s+x),(t+y) have to be in the

domain of f, and x,y have to be in the domain of

b, is completely analogous to the condition in the

binary definition of erosion, where the structuring

element has to be completely combined by the

set being eroded.

The same as in erosion we illustrate with 1-D

function

Page 85: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Erosion– Gray-Scale example 1

Page 86: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Erosion– Gray-Scale (cont)

General effect of performing an erosion in grayscale

images:

1. If all elements of the structuring element are positive, the output

image tends to be darker than the input image.

2. The effect of bright details in the input image that are smaller in

area than the structuring element is reduced, with the degree of

reduction being determined by the grayscale values surrounding

by the bright detail and by shape and amplitude values of the

structuring element itself.

Similar to binary image grayscale erosion and dilation

are duals with respect to function complementation and

reflection.

Page 87: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Dilation & Erosion– Gray-Scale

“flat-top” structuring element in the shape of a parallelepiped of unit

height and size 5x5 pixels

87

Page 88: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Opening And Closing Similar to the binary algorithms

Opening –

Closing –

In the opening of a gray-scale image, we

remove small light details, while relatively

undisturbed overall gray levels and larger bright

features

In the closing of a gray-scale image, we remove

small dark details, while relatively undisturbed

overall gray levels and larger dark features

Page 89: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Opening And Closing

Opening a G-S picture is describable as

pushing object B under the scan-line graph,

while traversing the graph according the

curvature of B

Page 90: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Opening And Closing

Closing a G-S picture is describable as pushing object B

on top of the scan-line graph, while traversing the graph

according the curvature of B

The peaks are usually remains in their original form

Page 91: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Opening And Closing

Page 92: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Applications of G-S Morphology

Morphological smoothing Perform opening followed by a closing

The net result of these two operations is to remove or attenuate both bright and dark artifacts or noise.

Morphological gradient Dilation and erosion are use to compute the

morphological gradient of an image, denoted g:

It uses to highlights sharp gray-level transitions in the input image.

Obtained using symmetrical structuring elements tend to depend less on edge directionality.

Page 93: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Applications of G-S Morphology

Morphological smoothing

Morphological gradient

Page 94: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Applications of G-S Morphology

Top-hat transformation Denoted h, is defined as:

Cylindrical or parallelepiped structuring element functionwith a flat top.

Useful for enhancing detail in the presence of shading.

Textural segmentation The objective is to find the boundary between different

image regions based on their textural content.

Close the input image by using successively larger

structuring elements.

Then, single opening is preformed ,and finally a simple threshold that yields the boundary between the textural regions.

Page 95: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Applications of G-S Morphology

Top-hat transformation

Textural segmentation

Page 96: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Applications of G-S Morphology

Granulometry Granulometry is a field that deals principally with

determining the size distribution of particles in an image.

Because the particles are lighter than the background, we can use a morphological approach to determine size distribution. To construct at the end a histogramof it.

Based on the idea that opening operations of particular size have the most effect on regions of the input image that contain particles of similar size.

This type of processing is useful for describing regions with a predominant particle-like character.

Page 97: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Applications of G-S Morphology

Granulometry

Page 98: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

Matlab examples

98

%%dilation

originalBW = imread('text.png');

se = strel('line',11,90);

dilatedBW = imdilate(originalBW,se);

figure, imshow(originalBW), figure,

imshow(dilatedBW)

originalI = imread('cameraman.tif');

se = strel('ball',5,5);

dilatedI = imdilate(originalI,se);

figure, imshow(originalI), figure, imshow(dilatedI)

se1 = strel('line',3,0);

se2 = strel('line',3,90);

composition = imdilate(1,[se1 se2],'full');

Page 99: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

99

%%erosion

originalBW = imread('text.png');

se = strel('line',11,90);

erodedBW = imerode(originalBW,se);

figure, imshow(originalBW)

figure, imshow(erodedBW)

originalI = imread('cameraman.tif');

se = strel('ball',5,5);

erodedI = imerode(originalI,se);

figure, imshow(originalI), figure, imshow(erodedI)

Page 100: SVD and digital image processing - TFE-Moodle 2 · George Matheron and Jean Serra are two founders of mathematical morphology Study of geometry of porous media Mathematical morphology

100

%%closing

originalBW = imread('circles.png');

figure, imshow(originalBW);

se = strel('disk',10);

closeBW = imclose(originalBW,se);

figure, imshow(closeBW);

%%opening

original = imread('snowflakes.png');

se = strel('disk',5);

afterOpening = imopen(original,se);

figure, imshow(original), figure, imshow(afterOpening)

%%HMT

bw=[0 0 0 0 0 0;0 0 1 1 0 0;0 1 1 1 1 0

0 1 1 1 1 0;0 0 1 1 0 0;0 0 1 0 0 0];

interval = [0 -1 -1;1 1 -1;0 1 0];

bw2 = bwhitmiss(bw,interval)