Lecture 5. Morphological Image Processing Introduction ► Morphology: a branch of biology that deals with the form and structure of animals and plants ► Morphological image.

Download Report

Transcript Lecture 5. Morphological Image Processing Introduction ► Morphology: a branch of biology that deals with the form and structure of animals and plants ► Morphological image.

Lecture 5. Morphological Image
Processing
Introduction
►
Morphology: a branch of biology that deals with the form
and structure of animals and plants
►
Morphological image processing is used to extract image
components for representation and description of region
shape, such as boundaries, skeletons, and the convex hull
11/7/2015
2
Preliminaries (1)
►
Reflection
The reflection of a set B, denoted B, is defined as
B  {w | w  b, for b  B}
►
Translation
The translation of a set B by point z  ( z1 , z2 ), denoted ( B) Z ,
is defined as
( B) Z  {c | c  b  z,for b  B}
11/7/2015
3
Example: Reflection and Translation
11/7/2015
4
Preliminaries (2)
►
Structure elements (SE)
Small sets or sub-images used to probe an image under study for
properties of interest
11/7/2015
5
Examples: Structuring Elements (1)
origin
11/7/2015
6
Examples: Structuring Elements (2)
Accommodate the
entire structuring
elements when its
origin is on the
border of the
original set A
Origin of B visits
every element of A
At each location of
the origin of B, if B
is completely
contained in A,
then the location is
a member of the
new set, otherwise
it is not a member
of the new set.
11/7/2015
7
Erosion
With A and B as sets in Z 2 , the erosion of A by B, denoted A
B,
defined
A
B   z | ( B) Z  A
The set of all points z such that B, translated by z, is contained by A.
A
11/7/2015
B   z | ( B) Z  Ac  
8
Example
of
Erosion
(1)
11/7/2015
9
Example
of
Erosion
(2)
11/7/2015
10
Dilation
2
With A and B as sets in Z , the dilation of A by B,
denoted A  B, is defined as
 

A  B= z | B  A  
z
The set of all displacements z , the translated B and A
overlap by at least one element.
 

A  B  z |  B  A  A

z

11/7/2015
11
Examples of Dilation (1)
11/7/2015
12
Examples of Dilation (2)
11/7/2015
13
Duality
►
Erosion and dilation are duals of each other with respect to
set complementation and reflection
 A  B
c
 Ac  B
and
c
A

B

A
B


c
11/7/2015
14
Duality
►
Erosion and dilation are duals of each other with respect to
set complementation and reflection
 A  B
c
  z |  B  Z  A
c
  z |  B  Z  A  
c
c
  z |  B  Z  Ac  
 Ac  B
11/7/2015
15
Duality
►
Erosion and dilation are duals of each other with respect to
set complementation and reflection
 A  B
c
    A  
  z |  B   A  
c
 z| B
Z
c
Z
 Ac  B
11/7/2015
16
Opening and Closing
►
Opening generally smoothes the contour of an object,
breaks narrow isthmuses, and eliminates thin protrusions
►
Closing tends to smooth sections of contours but it
generates fuses narrow breaks and long thin gulfs,
eliminates small holes, and fills gaps in the contour
11/7/2015
17
Opening and 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
11/7/2015
18
Opening
The opening of set A by structuring element B,
denoted A B, is defined as
A B
11/7/2015
 B  |  B 
Z
Z
 A
19
Example: Opening
11/7/2015
20
Example: Closing
11/7/2015
21
11/7/2015
22
Duality of Opening and Closing
►
Opening and closing are duals of each other with respect
to set complementation and reflection
c
A
B

(
A
B)
 
c
c
A
B

(
A
B)


c
11/7/2015
23
The Properties of Opening and 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
11/7/2015
24
11/7/2015
25
The Hit-or-Miss
Transformation
if B denotes the set composed of
D and its background,the match
(or set of matches) of B in A,
denoted A  B,
A * B   A  D    Ac  W  D  
B   B1 , B2 
B1 : object
B2 : background
A  B   A  B1   ( Ac  B2 )
11/7/2015
26
Some Basic Morphological Algorithms (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 
11/7/2015
27
Example 1
11/7/2015
28
Example 2
11/7/2015
29
Some Basic Morphological Algorithms (2)
►
Hole Filling
A hole may be defined as a background region surrounded
by a connected border of foreground pixels.
Let A denote a set whose elements are 8-connected
boundaries, each boundary enclosing a background region
(i.e., a hole). Given a point in each hole, the objective is to
fill all the holes with 1s.
11/7/2015
30
Some Basic Morphological Algorithms (2)
►
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
11/7/2015
31
Example
11/7/2015
32
11/7/2015
33
Some Basic Morphological Algorithms (3)
►
Extraction of Connected Components
Central to many automated image analysis applications.
Let A be a set containing one or more connected
components, and form an array X0 (of the same size as the
array containing A) whose elements are 0s, except at each
location known to correspond to a point in each connected
component in A, which is set to 1.
11/7/2015
34
Some Basic Morphological Algorithms (3)
►
Extraction of Connected Components
Central to many automated image analysis applications.
X k  ( X k 1  B)  A
B : structuring element
until X k  X k -1
11/7/2015
35
11/7/2015
36
11/7/2015
37
Some Basic Morphological Algorithms (4)
►
Convex Hull
A set A is said to be convex if the straight line segment
joining any two points in A lies entirely within A.
The convex hull H or of an arbitrary set S is the smallest
convex set containing S.
11/7/2015
38
Some Basic Morphological Algorithms (4)
►
Convex Hull
Let B i , i  1, 2, 3, 4, represent the four structuring elements.
The procedure consists of implementing the equation:
X ki  ( X k 1 * B i )  A
i  1, 2,3, 4 and k  1, 2,3,...
with X 0i  A.
When the procedure converges, or X ki  X ki 1 , let D i  X ki ,
the convex hull of A is
4
C ( A)   D i
i 1
11/7/2015
39
11/7/2015
40
11/7/2015
41
Some Basic Morphological Algorithms (5)
►
Thinning
The thinning of a set A by a structuring element B, defined
A  B  A  ( A * B)
 A  ( A * B)
11/7/2015
c
42
Some Basic Morphological Algorithms (5)
►
A more useful expression for thinning A symmetrically is
based on a sequence of structuring elements:
1
2
3
n
B

B
,
B
,
B
,...,
B
  

where B i is a rotated version of B i -1
The thinning of A by a sequence of structuring element {B}
A {B}  ((...(( A  B1 )  B 2 )...)  B n )
11/7/2015
43
11/7/2015
44
Some Basic Morphological Algorithms (6)
►
Thickening:
The thickening is defined by the expression
A
B  A   A* B
The thickening of A by a sequence of structuring element {B}
A {B}  ((...(( A
B1 )
B 2 )...)
Bn )
In practice, the usual procedure is to thin the background of the set
and then complement the result.
11/7/2015
45
Some Basic Morphological Algorithms (6)
11/7/2015
46
Some Basic Morphological Algorithms (7)
►
Skeletons
A skeleton, S ( A) of a set A has the following properties
a. if z is a point of S ( A) and ( D) z is the largest disk
centered at z and contained in A, one cannot find a
larger disk containing ( D) z and included in A.
The disk ( D) z is called a maximum disk.
b. The disk ( D) z touches the boundary of A at two or
more different places.
11/7/2015
47
Some Basic Morphological Algorithms (7)
11/7/2015
48
Some Basic Morphological Algorithms (7)
The skeleton of A can be expressed in terms of
erosion and openings.
K
S ( A)   S k ( A)
k 0
with K  max{k | A  kB  };
S k ( A)  ( A  kB )  ( A  kB ) B
where B is a structuring element, and
( A  kB )  ((..(( A  B )  B )  ...)  B )
k successive erosions of A.
11/7/2015
49
11/7/2015
50
11/7/2015
51
Some Basic Morphological Algorithms (7)
A can be reconstructed from the subsets by using
K
A   ( Sk ( A)  kB )
k 0
where Sk ( A)  kB denotes k successive dilations of A.
( Sk ( A)  kB)  ((...(( S k ( A)  B )  B )...  B )
11/7/2015
52
11/7/2015
53
Some Basic Morphological Algorithms (8)
►
Pruning
a. Thinning and skeletonizing tend to leave parasitic components
b. Pruning methods are essential complement to thinning and
skeletonizing procedures
11/7/2015
54
Pruning:
Example
11/7/2015
X1  A {B}
55
Pruning:
Example
X 2    X1 * B
8
k 1
11/7/2015
k

56
Pruning:
Example
X3   X2  H   A
H : 3  3 structuring element
11/7/2015
57
Pruning:
Example
X 4  X1  X 3
11/7/2015
58
Pruning:
Example
11/7/2015
59
Some Basic Morphological Algorithms (9)
►
Morphological Reconstruction
It involves two images and a structuring element
a. One image contains the starting points for the
transformation (The image is called marker)
b. Another image (mask) constrains the transformation
c. The structuring element is used to define connectivity
11/7/2015
60
Morphological Reconstruction: Geodesic
Dilation
Let F denote the marker image and G the mask image,
F  G. The geodesic dilation of size 1 of the marker image
with respect to the mask, denoted by DG(1) ( F ), is defined as
DG(1) ( F )   F  B   G
The geodesic dilation of size n of the marker image F
with respect to G, denoted by DG( n ) ( F ), is defined as
DG( n ) ( F )  DG(1) ( F )  DG( n1) ( F ) 
with DG(0) ( F )  F .
11/7/2015
61
11/7/2015
62
Morphological Reconstruction: Geodesic
Erosion
Let F denote the marker image and G the mask image.
The geodesic erosion of size 1 of the marker image with
respect to the mask, denoted by EG(1) ( F ), is defined as
EG(1) ( F )   F  B   G
The geodesic erosion of size n of the marker image F
with respect to G, denoted by EG( n ) ( F ), is defined as
EG( n ) ( F )  EG(1) ( F )  EG( n1) ( F ) 
with EG(0) ( F )  F .
11/7/2015
63
11/7/2015
64
Morphological Reconstruction by Dilation
Morphological reconstruction by dialtion of a mask image
G from a marker image F , denoted RGD ( F ), is defined as
the geodesic dilation of F with respect to G, iterated until
stability is achieved; that is,
RGD ( F )  DG( k ) ( F )
with k such that DG( k ) ( F )  DG( k 1) ( F ).
11/7/2015
65
11/7/2015
66
Morphological Reconstruction by Erosion
Morphological reconstruction by erosion of a mask image
G from a marker image F , denoted RGE ( F ), is defined as
the geodesic erosion of F with respect to G, iterated until
stability is achieved; that is,
RGE ( F )  EG( k ) ( F )
with k such that EG( k ) ( F )  EG( k 1) ( F ).
11/7/2015
67
Opening by Reconstruction
The opening by reconstruction of size n of an image F is
defined as the reconstruction by dilation of F from the
erosion of size n of F ; that is
OR( n ) ( F )  RFD  F  nB  
where  F  nB  indicates n erosions of F by B.
11/7/2015
68
11/7/2015
69
Filling Holes
Let I ( x, y ) denote a binary image and suppose that we
form a marker image F that is 0 everywhere, except at
the image border, where it is set to 1- I ; that is
1  I ( x, y )
F ( x, y )  
0

then
if ( x, y ) is on the border of I
otherwise
H   R ( F ) 
D
Ic
11/7/2015
c
70
SE : 3  3 1s.
11/7/2015
71
H   R ( F ) 
D
Ic
11/7/2015
c
72
Border Clearing
It can be used to screen images so that only complete objects
remain for further processing; it can be used as a singal that
partial objects are present in the field of view.
The original image is used as the mask and the following
marker image:
 I ( x, y )
F ( x, y)  
 0
X  I  RID ( F )
11/7/2015
if ( x, y ) is on the border of I
otherwise
73
11/7/2015
74
Summary (1)
11/7/2015
75
Summary (2)
11/7/2015
76
11/7/2015
77
11/7/2015
78
Gray-Scale Morphology
f ( x, y) : gray-scale image
b( x, y): structuring element
11/7/2015
79
Gray-Scale Morphology: Erosion and Dilation
by Flat Structuring
f ( x  s, y  t )

 f  b ( x, y)  (min
s ,t )b
f ( x  s, y  t )

 f  b ( x, y)  max
( s ,t )b
11/7/2015
80
11/7/2015
81
Gray-Scale Morphology: Erosion and Dilation
by Nonflat Structuring
f ( x  s, y  t )  bN ( s, t )

 f  bN  ( x, y)  (min
s ,t )b
f ( x  s, y  t )  bN ( s, t )

 f  bN  ( x, y)  max
( s ,t )b
11/7/2015
82
Duality: Erosion and Dilation
 f b 
c
 c 
( x, y )   f  b  ( x, y )



where f c   f ( x, y ) and b  b( x,  y )
 f b 
c
 f  b
11/7/2015
c
 c 
  f b



 ( f  b)
c
83
Opening and Closing
f b   f  b  b
f  b   f  b  b
 f b
f
11/7/2015
c
 f


bf b
c


b  f b   f b
c
c
84
11/7/2015
85
Properties of Gray-scale Opening
(a) f bf
(b) if f1f 2 , then  f1 b    f 2 b 
(c )
f
b b  f b
where er denotes e is a subset of r and also
e( x, y )  r ( x, y ).
11/7/2015
86
Properties of Gray-scale Closing
(a ) f f b
(b) if f1f 2 , then
(c )
11/7/2015
 f b b 
 f1 b    f 2 b 
f b
87
11/7/2015
88
Morphological Smoothing
►
Opening suppresses bright details smaller than the
specified SE, and closing suppresses dark details.
►
Opening and closing are used often in combination as
morphological filters for image smoothing and noise
removal.
11/7/2015
89
Morphological Smoothing
11/7/2015
90
Morphological Gradient
►
Dilation and erosion can be used in combination with
image subtraction to obtain the morphological gradient of
an image, denoted by g,
g  ( f  b)  ( f  b)
►
The edges are enhanced and the contribution of the
homogeneous areas are suppressed, thus producing a
“derivative-like” (gradient) effect.
11/7/2015
91
Morphological Gradient
11/7/2015
92
Top-hat and Bottom-hat Transformations
►
The top-hat transformation of a grayscale image f is
defined as f minus its opening:
That ( f )  f  ( f b)
►
The bottom-hat transformation of a grayscale image f is
defined as its closing minus f:
Bhat ( f )  ( f  b)  f
11/7/2015
93
Top-hat and Bottom-hat Transformations
►
One of the principal applications of these transformations
is in removing objects from an image by using structuring
element in the opening or closing operation
11/7/2015
94
Example of Using Top-hat Transformation in
Segmentation
11/7/2015
95
Granulometry
►
Granulometry deals with determining the size of
distribution of particles in an image
►
Opening operations of a particular size should have the
most effect on regions of the input image that contain
particles of similar size
►
For each opening, the sum (surface area) of the pixel
values in the opening is computed
11/7/2015
96
Example
11/7/2015
97
11/7/2015
98
Textual Segmentation
►
Segmentation: the process of subdividing an image into
regions.
11/7/2015
99
Textual Segmentation
11/7/2015
100
Gray-Scale Morphological Reconstruction (1)
►
Let f and g denote the marker and mask image with the
same size, respectively and f ≤ g.
The geodesic dilation of size 1 of f with respect to g is
defined as
Dg(1) ( f )   f  g   g
where  denotes the point-wise minimum operator.
The geodesic dilation of size n of f with respect to g is
defined as
Dg( n ) ( f )  Dg(1)  Dg( n 1) ( f )  with Dg(0) ( f )  f
11/7/2015
101
Gray-Scale Morphological Reconstruction (2)
►
The geodesic erosion of size 1 of f with respect to g is
defined as
Eg(1) ( f )   f  g   g
where  denotes the point-wise maximum operator.
The geodesic erosion of size n of f with respect to g is
defined as
Eg( n ) ( f )  Eg(1)  Eg( n 1) ( f )  with Eg(0) ( f )  f
11/7/2015
102
Gray-Scale Morphological Reconstruction (3)
►
The morphological reconstruction by dilation of a grayscale mask image g by a gray-scale marker image f, is
defined as the geodesic dilation of f with respect to g,
iterated until stability is reached, that is,
RgD ( f )  Dg( k )  f 
with k such that Dg( k )  f   Dg( k 1)  f 
The morphological reconstruction by erosion of g by f is
defined as
E
(k )
f
with k such that Eg( k )  f   Eg( k 1)  f 
Rg ( f )  Eg
11/7/2015
103
Gray-Scale Morphological Reconstruction (4)
►
The opening by reconstruction of size n of an image f is
defined as the reconstruction by dilation of f from the
erosion of size n of f; that is,
OR(n) ( f )  RDf  f  nb
The closing by reconstruction of size n of an image f is
defined as the reconstruction by erosion of f from the
dilation of size n of f; that is,
CR(n) ( f )  REf  f  nb
11/7/2015
104
11/7/2015
105
Steps in the Example
1.
Opening by reconstruction of the original image using a horizontal
line of size 1x71 pixels in the erosion operation
OR(n) ( f )  RDf  f  nb
2.
Subtract the opening by reconstruction from original image
f '  f  OR( n) ( f )
3.
Opening by reconstruction of the f’ using a vertical line of size 11x1
pixels
f 1  OR( n) ( f ')  RDf  f ' nb '
4.
11/7/2015
Dilate f1 with a line SE of size 1x21, get f2.
106
Steps in the Example
5.
Calculate the minimum between the dilated image f2
and and f’, get f3.
6.
By using f3 as a marker and the dilated image f2 as
the mask,
R Df 2 ( f 3)  D(f k2)  f 3
with k such that D(f k2)  f 3  D(f k21)  f 3
11/7/2015
107