chapter 9 morphological image processing - eskisehir.edu.treem.eskisehir.edu.tr/cihant/eem...
TRANSCRIPT
EEM 463 Introduction to Image Processing
Chapter 9Morphological Image
Processing
Fall 2017
Assist. Prof. Cihan Topal
Anadolu University, Dept. EEE
Slides Credit: Frank (Qingzhong) Liu
12/25/2017 2
Introduction
► Morphology: a branch of biology that deals with theFORM and STRUCTURE of animals and plants
► Morphological image processing is used to extract imagecomponents for representation and description of regionshape, such as boundaries, skeletons, and the convexhull, connectivity analysis, blob analysis, ...
► Develop methods (region filling, thinning, thickening, andpruning) that are frequently used in conjunction withthese algorithms as pre-or post-processing steps
12/25/2017 3
Preliminaries (1)
► Reflection
► Translation
The reflection of a set , denoted , is defined as
{ | , for }
B B
B w w b b B
1 2The translation of a set by point ( , ), denoted ( ) ,
is defined as
( ) { | , for }
Z
Z
B z z z B
B c c b z b B
𝐵
𝐵
12/25/2017 4
Example: Reflection and Translation
12/25/2017 5
Preliminaries (2)
► Structure elements (SE)
Small sets or sub-images used to probe an image under study for properties of interest
12/25/2017 6
Examples: Structuring Elements (1)
origin
12/25/2017 7
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.
12/25/2017 8
Erosion
2With and as sets in , the erosion of by , denoted ,
defined
| ( )Z
A B Z A B A B
A B z B A
The set of all points such that , translated by , is contained by .z B z A
| ( ) c
ZA B z B A
12/25/2017 9
Example of
Erosion (1)
12/25/2017 10
Example of
Erosion (2)
12/25/2017 11
Dilation
2With and as sets in , the dilation of by ,
denoted , is defined as
A B= |z
A B Z A B
A B
z B A
• Does the structuring element hit the set?
𝐵
|z
A B z B A A 𝐵
The set of all displacements , the translated and
overlap by at least one element.
z B A𝐵
12/25/2017 12
Examples of Dilation (1)
12/25/2017 13
Examples of Dilation (2)
12/25/2017 14
Duality
► Erosion and dilation are duals of each other with respect to set complementation and reflection
c c
c c
A B A B
and
A B A B
𝐵
𝐵
The duality property is useful particularly when the structuring element is symmetric with respect to its origin (as often is the case)
𝐵 = 𝐵
|
|
|
cc
Z
cc
Z
c
Z
c
A B z B A
z B A
z B A
A B
𝐵
12/25/2017 15
Duality
► Erosion and dilation are duals of each other with respect to set complementation and reflection
|
|
cc
Z
c
Z
c
A B z B A
z B A
A B
𝐵
𝐵
12/25/2017 16
Duality
► Erosion and dilation are duals of each other with respect to set complementation and reflection
𝐵
12/25/2017 17
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.
12/25/2017 18
Opening and Closing
The opening of set by structuring element ,
denoted , is defined as
A B
A B
A B A B B
The closing of set by structuring element ,
denoted , is defined as
A B
A B
A B A B B
12/25/2017 19
Opening
The opening of set by structuring element ,
denoted , is defined as
|Z Z
A B
A B
A B B B A
12/25/2017 20
Example: Opening
12/25/2017 21
Example: Closing
12/25/2017 22
12/25/2017 23
Duality of Opening and Closing
► Opening and closing are duals of each other with respect to set complementation and reflection
( )c cA B A B
( )c cA B A B
12/25/2017 24
The Properties of Opening and Closing
► Properties of Opening
► Properties of Closing
(a) is a subset (subimage) of
(b) if is a subset of , then is a subset of
(c) ( )
A B A
C D C B D B
A B B A B
(a) is subset (subimage) of
(b) If is a subset of , then is a subset of
(c) ( )
A A B
C D C B D B
A B B A B
12/25/2017 25
12/25/2017 26
The Hit-or-Miss Transformation
if denotes the set composed of
and its background,the match
(or set of matches) of in ,
denoted ,
* c
B
D
B A
A B
A B A D A W D
1 2
1
2
1 2
,
: object
: background
( )c
B B B
B
B
A B A B A B
12/25/2017 27
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
12/25/2017 28
Example 1
12/25/2017 29
Example 2
12/25/2017 30
Some Basic Morphological Algorithms (2)
► Hole Filling
A hole may be defined as a background regionsurrounded by a connected border of foregroundpixels.
Let A denote a set whose elements are 8-connectedboundaries, each boundary enclosing a backgroundregion (i.e., a hole). Given a point in each hole, theobjective is to fill all the holes with 1s.
12/25/2017 31
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
12/25/2017 32
Example
12/25/2017 33
12/25/2017 34
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 connectedcomponents, and form an array X0 (of the same size asthe array containing A) whose elements are 0s, exceptat each location known to correspond to a point in eachconnected component in A, which is set to 1.
12/25/2017 35
Some Basic Morphological Algorithms (3)
► Extraction of Connected Components
Central to many automated image analysis applications.
1
-1
( )
: structuring element
until
k k
k k
X X B A
B
X X
12/25/2017 36
12/25/2017 37
12/25/2017 38
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.
12/25/2017 39
Some Basic Morphological Algorithms (4)
► Convex Hull
1
Let , 1, 2, 3, 4, represent the four structuring elements.
The procedure consists of implementing the equation:
( * )
1, 2,3,4 and 1,
i
i i
k k
B i
X X B A
i k
0
1
4
1
2,3,...
with .
When the procedure converges, or , let ,
the convex hull of A is
( )
i
i i i i
k k k
i
i
X A
X X D X
C A D
12/25/2017 40
12/25/2017 41
12/25/2017 42
Some Basic Morphological Algorithms (5)
► Thinning
The thinning of a set A by a structuring element B, defined
( * )
( * )c
A B A A B
A A B
12/25/2017 43
Some Basic Morphological Algorithms (5)
► 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 B
A B A B B B
12/25/2017 44
12/25/2017 45
Some Basic Morphological Algorithms (6)
► Thickening:
The thickening is defined by the expression
*A B A A B
1 2
The thickening of by a sequence of structuring element { }
{ } ((...(( ) )...) )n
A B
A B A B B B
In practice, the usual procedure is to thin the background of the set
and then complement the result.
12/25/2017 46
Some Basic Morphological Algorithms (6)
12/25/2017 47
Some Basic Morphological Algorithms (7)
► Skeletons
A skeleton, ( ) of a set has the following properties
a. if is a point of ( ) and ( ) is the largest disk
centered at and contained in , one cannot find a
larger disk containing ( )
z
z
S A A
z S A D
z A
D and included in .
The disk ( ) is called a maximum disk.
b. The disk ( ) touches the boundary of at two or
more different places.
z
z
A
D
D A
12/25/2017 48
Some Basic Morphological Algorithms (7)
12/25/2017 49
Some Basic Morphological Algorithms (7)
0
The skeleton of A can be expressed in terms of
erosion and openings.
( ) ( )
with max{ | };
( ) ( ) ( )
where is a structuring element, and
K
kk
k
S A S A
K k A kB
S A A kB A kB B
B
( ) ((..(( ) ) ...) )
successive erosions of A.
A kB A B B B
k
12/25/2017 50
12/25/2017 51
12/25/2017 52
Some Basic Morphological Algorithms (7)
0
A can be reconstructed from the subsets by using
( ( ) )
where ( ) denotes successive dilations of A.
( ( ) ) ((...(( ( ) ) )... )
K
kk
k
k k
A S A kB
S A kB k
S A kB S A B B B
12/25/2017 53
12/25/2017 54
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
12/25/2017 55
Pruning: Example
1 { }X A B
12/25/2017 56
Pruning: Example
8
2 11
* k
kX X B
12/25/2017 57
Pruning: Example
3 2
: 3 3 structuring element
X X H A
H
12/25/2017 58
Pruning: Example
4 1 3X X X
12/25/2017 59
Pruning: Example
12/25/2017 60
Summary (1)
12/25/2017 61
Summary (2)
12/25/2017 62
12/25/2017 63
Gray-Scale Morphology
►Unlike binary images we deal with digital imagefunctions of the form f(x,y) as an input imageand b(x,y) as a structuring element.
► f(x,y) and b(x,y) are functions that assign graylevel value to each distinct pair of coordinates.
►Remember that, the domain of gray values canbe 0-255, whereas 0 is black, 255 is white.
12/25/2017 64
12/25/2017 65
Gray-Scale Morphology
( , ) : gray-scale image
( , ): structuring element
f x y
b x y
12/25/2017 66
Gray-Scale Morphology: Erosion and Dilation by Flat Structuring
( , )
( , )
( , ) min ( , )
( , ) max ( , )
s t b
s t b
f b x y f x s y t
f b x y f x s y t
► The condition that (x-s),(y-t) need to be in the domain off and x,y in the domain of b,
It is completely analogous to the condition in the binary definition oferosion, where the structuring element has to be completely combinedby the set being eroded.
It is analogous to the condition in the binary definition of dilation, wherethe two sets need to overlap by at least one element.
12/25/2017 67
Effects of Grayscale Erosion
► General effect of performing an erosion in grayscaleimages:
If all elements of the structuring element are positive, the outputimage tends to be darker than the input image.
The effect of bright details in the input image that are smaller inarea than the structuring element is reduced, with the degree ofreduction being determined by the grayscale values surrounding bythe bright detail and by shape and amplitude values of thestructuring element itself.
► Similar to binary image grayscale erosion and dilation areduals with respect to function complementation andreflection.
12/25/2017 68
Effects of Greyscale Dilation
►The general effects of performing dilation on a gray scale image is two fold:
If all the values of the structuring elements are positive than the output image tends to be brighter than the input.
Dark details either are reduced or eliminated, depending on how their values and shape relate to the structuring element used for dilation.
12/25/2017 69
12/25/2017 70
Gray-Scale Morphology: Erosion and Dilation by Nonflat Structuring
( , )
( , )
( , ) min ( , ) ( , )
( , ) max ( , ) ( , )
N Ns t b
N Ns t b
f b x y f x s y t b s t
f b x y f x s y t b s t
► The resulting image will not be bounded by the values of f, which can present problem in interpreting it.
► Also, it is difficult to select meaningful SEs and it increases computational burden.
► Gray-scale SEs are seldom used in practice because of this.
12/25/2017 71
Duality: Erosion and Dilation
( , ) ( , )
where ( , ) and ( , )
c c
c
c c
f b x y f b x y
f f x y b b x y
f b f b
( )c cf b f b
12/25/2017 72
Opening and Closing
f b f b b
f b f b b
c c
c c
f b f b f b
f b f b f b
► In the opening of a gray-scale image, we remove smalllight details, while relatively undisturbed overall gray levelsand larger bright features
► In the closing of a gray-scale image, we remove small darkdetails, while relatively undisturbed overall gray levels andlarger dark features
12/25/2017 73
12/25/2017 74
Properties of Gray-scale Opening
1 2 1 2
( )
( ) if , then
( )
where denotes is a subset of and also
( , ) ( , ).
a f b f
b f f f b f b
c f b b f b
e r e r
e x y r x y
12/25/2017 75
Properties of Gray-scale Closing
1 2 1 2
( )
( ) if , then
( )
a f f b
b f f f b f b
c f b b f b
12/25/2017 76
12/25/2017 77
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.
12/25/2017 78
Morphological Smoothing
Dilation & Erosion & Smoothing
12/25/2017 79
12/25/2017 80
Morphological Gradient
► Dilation and erosion can be used in combination with image subtraction to obtain the morphological gradient of an image, denoted by g,
► The edges are enhanced and the contribution of the homogeneous areas are suppressed, thus producing a “derivative-like” (gradient) effect.
( ) ( )g f b f b
12/25/2017 81
Morphological Gradient
12/25/2017 82
Top-hat and Bottom-hat Transformations
► The top-hat transformation of a grayscale image f is defined as f minus its opening:
► The bottom-hat transformation of a grayscale image f is defined as its closing minus f:
( ) ( )hatT f f f b
( ) ( )hatB f f b f
12/25/2017 83
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
12/25/2017 84
Example of Using Top-hat Transformation in Segmentation
12/25/2017 85
Granulometry
► Granulometry deals with determining the size 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
Granulometry
► In practice, particles seldom are neatly separated, which makes particle counting by identifying individual particles a difficult task.
►Morphology can be used to estimate particle size distribution indirectly, without having to identify and measure every particle in the image.
12/25/2017 86
12/25/2017 87
Example
12/25/2017 88
12/25/2017 89
Textual Segmentation
► Segmentation: the process of subdividing an image into regions.
12/25/2017 90
Textual Segmentation