You are on page 1of 99

DIGITAL IMAGE PROCESSING

Dr. Le Dung
Dung.le@hust.edu.vn
0904982398

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

Chng III:
PHN ON NH
(Image Segmentation)

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

Ni dung
TCH BIN NH (EDGE DETECTION)
TCH KHUNG XNG NH (SKELETON EXTRACTION)
TCH VNG NH (REGION SEGMENTATION)

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

KHI NIM BIN CA NH (Image Edges)


Grayscale image

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

Edges

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

Types of Edge

s u r f a c e

d e p t h

s u r f a c e

il l u m in a t io n

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

S thay i chi ti bin


Luminance profile of an edge

S t e p

R o o f
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

L in e
SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

nh Grayscale thng dng tch bin


Color typically isnt need when looking for edges
Less Computation in gray scale, no R,B,G

Gray value = 0.2989*R+ 0.5870*G + 0.1140*B

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

K thut tm bin nh
Luminance profile I(x,y)

First derivative

Second derivative

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

Edge direction and strength


Gradient

Gradient direction:
The edge strength is given by the gradient magnitude

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

10

ng bin nh khi c nhiu

Edge with noise


Edge Magnitude ?
Edge Orientation ?
High Detection Rate and Good Localization ?

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

11

Edge Detection with noise


Gradient with noise

Where is the edge?


HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

12

Cn gim nhiu trc khi tch bin


Images can have noise in them

Heat waves
Dust
Smoke
Acquisition Noise

Solution Noise filter


nh c nhiu
nh tch bin

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

13

Noise reduction
Gaussian Mask Gaussian Filter

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

14

Noise reduction
Gaussian Filter Smoothing (Gaussian blur)

Original
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

Smoothed
SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

15

Edge Detection after noise reduction


Smooth first, then Gradient

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

16

Calculate Gradient Image


- Achieved by obtaining the magnitude for each pixel
from the outConvX[][] and the outConvY[][]
- Iterate through each pixel i and j
- Magnitude[i][j] =

outConvX[i ][j] 2 outConvY[i ][j] 2 )

- Gradient direction = tan -1 (outConvY[ ][]/outCon vX[][])

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

17

Discrete version of gradient

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

18

The Sobel operators

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

19

The Sobel operators

Grad x

Grad y

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

20

The Prewitt operators

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

21

The Compass operators

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

22

The Laplacian Edge Detector

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

23

The Laplace-4 for Edge Detector

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

24

Laplacian Operator with a Blur Edge

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

25

Laplacian Zero-crossing Operator

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

26

The Laplace-8 for Edge Detector

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

27

Canny Edge Detector


Developed by John Canny in 1986

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

28

Canny Edge Detector

1. Noise reduction (5x5 Gaussian filter)


2. Finding the intensity gradient of the image (Sobel X & Y)
3. Non-maximum suppression (loi b im khng cc i)
4. Tracing edges through the image and hysteresis threshold
(ngng tri tr - n hi)
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

29

Edge Detection with Sobel filter

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

30

Edge Detection with Sobel filter should be thinned

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

31

Non-maximum suppression
Non-maximum suppression is an edge thinning technique :
Select the single maximum point (peak) along the gradient direction.

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

32

Peaks
The matrix is represented with values
of the pictures Magnitude[][]
Since current pixels Magnitude[i][j] > relevant
pixels Magnitude[i][j]
12 34 23 Gradient
direction
peak[i][j] = true
85 90 30
23

78

90

Since current pixels Magnitude[i][j] < relevant


pixels Magnitude[i][j]
Gradient
12 34 23
direction
85 90 99
peak[i][j] = false
23
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

78

90

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

33

Non-maximum suppression
Tin trnh thc hin loi b cc im khng cc i :

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

34

Non-maximum suppression
V d:

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

35

Non-maximum suppression
Kt qu v d ng bin c lm mnh

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

36

Double Threshold and Hysteresis

Strong
High threshold
Weak
Connectivity
Weak
Low threshold

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

37

Double Threshold and Hysteresis


Final[] is another Boolean matrix that represents peak
values that are accepted by the double threshold
High Threshold ( strong edges)
Values is selected by the programmer
If the Magnitude[] > High Threshold and peak[] == true then
that pixel is a peak in Final[] (certain edges)

Low Threshold ( weak edges)


Value is selected by the programmer
If High Threshold > Magnitude[] > Low Threshold
and peak[] == true

Tracking: (Hysteresis): Weak edge pixels have a connectivity of


a strong edge pixel.

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

38

Getting the High Threshold


For i = 0 to Row length
For j = 0 to column length
if(peak[i][j] == true && magnitude[i][j] > High)
peak[i][j] = false
final[i][j] = true
else if(peak[i][j] == true && magnitude[i][j] < Low)
peak[i][j] == false
final[i][j] == false

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

39

Example High Threshold


High threshold: 80
Peak Table

Magnitude Table
7

Final Table

77 43 32 21 21

45 81 1

91 1

34 43 65 67 34 2
1

91 1
1

91 1

92 1

83 82 82 3

1
2
Table

True Peak

True Final

False Peak

False Final

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

40

Getting The Low Threshold


MoreToDo = On
While(MoreToDo == On)
{ MoreToDo = Off
For i = 0 to Row length
For j = 0 to column length
if(Final[i][j] == true)
For p = -1 to 1
For q = -1 to 1
if(peak[i+p][j+q] == true)
{ Final[i+p][j+q] == true
peak[i+p][j+q] = false
MoreToDo = On
}
}
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

41

Example Low Threshold


General Peaks Table
with High and Low:

Final Table:

Table
Low Peak
High Peak

True Final

False Peak

False Final

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

42

Output
For i = 0 to Row length
For j = 0 to column length
if(Final[i][j] == true)
print white pixel
else
print black pixel

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

43

Double Threshold and Hysteresis Result

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

44

SKELETON OF IMAGE

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

45

TRCH LC KHUNG XNG NH

Skeleton

Nh phn ha nh (Binary image converter)


Thut ton bin i nh khong cch (Distance Transform)
Lc tch xng nh trn nh Distance transformation image

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

46

DISTANCE TRANSFORM

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

47

DISTANCE TRANSFORM IMAGE

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

48

K THUT N MN TCH XNG

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

49

CC BC N MN TCH XNG (1)


+ Bt u n mn t im c khong cch bng 2, sau lp li vi khong cch
tng dn ln (3,4,5 n khong cch ln nht)
+ im ang xt s khng b n mn trong cc trng hp sau:
4 ln cn trc tip u l im nn (background) v c t nht 1 ln
cn khc l im nh foreground.
Trong 4 ln cn trc tip th c 3 im l im nn (1 im cn li l
foreground).
Trong 4 ln cn trc tip th c 2 im l im nn th
3 trng hp sau l khng n mn:
?

C 4 ln cn trc tip u khng l im nn (tc l c 4 im


u l im foreground)
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

50

CC BC N MN TCH XNG (2)


V d 1: Cho nh Distance transform image sau

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

51

CC BC N MN TCH XNG (2)


V d 1: n mn im nh c khong cch bng 2

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

52

CC BC N MN TCH XNG (2)


V d 1: n mn im nh c khong cch bng 4

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

53

CC BC N MN TCH XNG (2)


V d 1: n mn im nh c khong cch bng 5

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

54

CC BC N MN TCH XNG (2)


V d 1: n mn im nh c khong cch bng 6

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

55

CC BC N MN TCH XNG (2)


V d 1: n mn im nh c khong cch bng 7 Kt thc

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

56

nh xng c th cho kt qu nhn dng tt hn

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

57

TCH VNG NH

Dng Histogram
Dng Connected Component Labeling Algorithm

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

58

TCH VNG NH DNG HISTOGRAM (1)

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

59

TCH VNG NH DNG HISTOGRAM (2)


Histogram
Cutting direction

2 horizontal cutting lines


d12

2
1

Horizontal
Cutting line

Vertical cutting lines 10

Code Area

Border

9 8 7 6

5 4 3 2 1

Histogram

12 pixels

(pixels)

Vertical
direction

Selected area
Threshold 10 pixels

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

pixels
20

Position of numbers

V1

V2

V3

V4

V5

Border

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

60

THUT TON CONNECTED COMPONENT LABELING


Tch cc vng nh khng lin kt

3
3

7
7

7
7

B T i PD NM GA T L AL
B tp r
n ht h u TOt N

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

61

CC BC CA THUT TON CCL (1)


1

Cc im cha
dn nhn c gi
tr bng 1
(im nn gi tr
bng 0)

1
1

1
1

nh cn phn
vng bng
thut ton
CCL

10

Kmax
.....

Mng theo di s kt hp nhn


HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

62

CC BC CA THUT TON CCL (2)


Bt u t im
[0,0] i t tri
sang phi, trn
xung di.

im cha c
dn nhn s
c nh nhn
mi k.
2 im ln cn
phi v di
cha c dn
nhn cng c
nh nhn k lun

1
1

nh cn phn
vng bng
thut ton
CCL

1
1

1
1

1
1

(dng 4-connectivity)
1

10

Kmax

.....

Mng theo di s kt hp nhn


HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

63

CC BC CA THUT TON CCL (3)


Nhn k s
c tng
dn ln

3
1

1
1

nh cn phn
vng bng
thut ton
CCL

1
1

10

Kmax
.....

Mng theo di s kt hp nhn


HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

64

CC BC CA THUT TON CCL (4)


im c
nh nhn k ri
s c dng
nh tip cc
im ln cn phi
v di cha dn
nhn

3
4

nh cn phn
vng bng
thut ton
CCL

Vy khi im ln
cn phi cng
dn nhn ri th
sao?.
1

1
1

10

Kmax
.....

Mng theo di s kt hp nhn


HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

65

CC BC CA THUT TON CCL (5)


Khi im ln cn
phi dn nhn

So snh
dng nh nh
hn
nh cho im
ln cn di.

1
1

nh cn phn
vng bng
thut ton
CCL

ng thi ghi
nhn 1 s kt
hp nhn trong
mng theo di

10

Kmax
.....

Mng theo di s kt hp nhn


HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

66

CC BC CA THUT TON CCL (6)


Tng th nh
nhn cc im
nh v cc v tr
kt hp nhn
trong lt nh
nhn ln u.

nh cn phn
vng bng
thut ton
CCL

10

Kmax
.....

Mng theo di s kt hp nhn


HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

67

CC BC CA THUT TON CCL (7)


nh li nhn cho
cc im nh c
nhn kt hp da
vo mng theo
di s kt hp
nhn.

nh cn phn
vng bng
thut ton
CCL

10

Kmax
.....

Mng theo di s kt hp nhn


HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

68

M RNG CCL: TNH S IM NH MI VNG (1)


Va nh nhn
theo thut ton
CCL va m s
im nh cng
nhn.

3
4

4
5

Ghi li trn

mng theo di
nhn.

3
6

3
8

Nhn

.....

m s im

.....

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

10

Kmax

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

69

M RNG CCL: TNH S IM NH MI VNG (2)


Vng nh va
nh nhn va
nh s lng
im nh (Label
&Weight)

1
1

1
1

Trn mng

theo di nhn s
cng gp s im
nh cc nhn b
kt hp

ng dng ?

1
1

Nhn

.....

m s im

6+5+
2

6+2

.....

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

10

Kmax

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

70

TCH LC VNG NHIU VI CCL ALGORITHM

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

71

TCH LC VNG QUAN TM VI CCL ALGORITHM (1)

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

72

TCH LC VNG QUAN TM VI CCL ALGORITHM (2)

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

73

Morphological Operators
(Cc ton t hnh thi)
Cc ton t Morphological thng nhn mt nh nh
phn (binary image) hay nh a mc xm (greyscale
image) v mt phn t cu trc SE (structuring element)
(mt ma trn, kernel) nh l d liu u vo, sau kt
hp chng bng cch s dng tp php ton nh giao,
hp, bao gm, b (intersection, union, inclusion,
complement) cho ra mt nh kt qu c cng kch thc.
Morphological operations the shape of the object

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

74
X
Morphological Operator: Structuring Elements

SE = kernel

o r ig in

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

75

Morphological Operator: Probing the SE on the Image

SE neither fits, nor


hits the image

Structure
Element
SE fits the image

The binary image

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SE hits (intersects)
the image

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

76

Morphological Operator: Example: Fit - Hit

https://www.cs.auckland.ac.nz/courses/compsci773s1c/lectures/ImageProcessing-html/topic4.htm

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

77

Morphological Operator: Cc k hiu v php ton

A is a set in Z2 ,
a=(a1,a2) an element of A, aA If not, then aA
: null (empty) set
A subset of B: AB
Union of A and B: C=AB
Intersection of A and B: D=AB
Disjoint sets: AB=
Complement of A: Ac = {x|xA}
Difference of A and B:
A-B = {x|xA, x B} = ABc

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

78

Morphological Operator: V d cc php ton

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

79

Morphological Operator: Reflection and Translation


Reflection of B: denoted by BR and X(x1,x2) is reference point.
BR = {x|x=-b, for bB}
Translation of B by X(x1,x2), denoted by (B)x :
(B)x = {c| c=b+x, for bB}

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

80

Morphological Operator: Erosion (xi mn)


A B = {x | (B)x A}
The erosion of A by B is the set of all points x such that B,
translated by x, is contained (fits) in A (B usually is the
structure element)
The basic effect of the Erosion operator on a binary
image is to erode away the boundaries of regions of
foreground pixels.
Thus areas of foreground pixels shrink in size, and
holes within those areas become larger.

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

81

Morphological Operator: Erosion operation


The eroded image
(A B)

The original image


(A)
SE fits

SE hits but doent fit


on the image A
will be eroded
The pixel is eroded
SE = B
3x3
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

82

Morphological Operator: Erosion Example (1)


The eroded image

The original image

?
SE

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

83

Morphological Operator: Erosion Example (2)

SE

Original image

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

The erosion of the


original image

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

84

Morphological Operator: Erosion Applications


Application Example (1)
Boundary Extraction: The boundary of a set A, can be obtained
by first eroding A by B and then performing the set difference
between A and its erosion.

( A) A A B

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

85

Morphological Operator: Erosion Applications


Application Example (2)

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

86

Morphological Operator: Dilation (trng n)


A B = {x | (BR)x A }
1.
2.

Obtaining the reflection of B ( BR) with its origin as


the reference point and then shifting this reflection by x.
The dilation of A by B then is the set of all x
displacements such that BR and A overlap by at least
one nonzero pixel (hit).

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

87

Morphological Operator: Dilation operation


The original image
(A)

The dilated image


(AB)

BR and A overlap (hits)

BR and A dont overlap

SE = B =BR
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

88

Morphological Operator: Dilation Example (1)


The original image

The dilated image

?
SE
=B
= BR

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

89

Morphological Operator: Dilation Exercise


The dilated image ?
The original image

SE
SER

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

90

Morphological Operator: Dilation


Application Example (1)
Hole Filling
1. Forming an array X0 of 0s (the same size as the array
containing A), except the locations in X0 corresponding to the
given point in each hole, which we set to 1.
2. Xk = (Xk-1 + B) Ac

k=1,2,3,

Stop the iteration if Xk = Xk-1

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

91

Morphological Operator: Dilation


Application Example (1)
Hole Filling

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

92

Morphological Operator: Dilation


Application Example (2)

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

93

Morphological Operator:
Duality (Erosion & Dilation)
Erosion and dilation are duals of each other with respect to set
complementation and reflection

A B

A B

A B

A B

and

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

94

Morphological Operator:
Duality (Erosion & Dilation)
Erosion and dilation are duals of each other with respect to set
complementation and reflection

A B

z | B Z A

z | B Z A
c

z | B Z Ac
Ac B

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

95

Morphological Operator: Opening & Closing


The opening of set A by structuring element B,
denoted A B, is defined as
A B A B B
The closing of set A by structuring element B,
denoted A B, is defined as
A B A B B

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

96

Morphological Operator: Opening & Closing


Properties of Opening

(a) A B is a subset (subimage) of A


(b) if C is a subset of D, then C B is a subset of D B
(c) ( A B) B A B
Properties of Closing

(a) A is subset (subimage) of A B


(b) If C is a subset of D, then C B is a subset of D B
(c) ( A B) B A B
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

97

Morphological Operator: Opening Example

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

98

Morphological Operator: Closing Example

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION

l nh s

99

Morphological Operator: Opening & Closing Application

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRONICS AND TELECOMMUNICATION