Morphological Image Processing - ELE – PUC RIOraul/ImageAnalysis/Morphology.pdf · 9/3/2019...
Transcript of Morphological Image Processing - ELE – PUC RIOraul/ImageAnalysis/Morphology.pdf · 9/3/2019...
Morphological Image Processing
Raul Queiroz Feitosa
9/3/2019 Morphological Image Processing 2
Objetive
To introduce basic morphological tools that are
useful :
in the representation and description of region shape
In pre- and post-processing to improve the
segmentation outcome .
9/3/2019 Morphological Image Processing 3
Introduction
In mathematical morphology Objects in the image are represented by sets.
In binary images sets Z2, where each element is a tuple (x,y)
with the coordinates of the black (or white) pixels.
In gray-scale digital images sets Z3, where each element is a
tuple (x,y,f) with the coordinates and the discrete gray level of the
pixels.
pre-
processing
segmen-
tation
feature
extraction
feature
selection
classifi-
cation
post-
processing data label
9/3/2019 Morphological Image Processing 4
Basic Concepts
Let A be a set in Z2. If a=(a1,a2) is an element of A then
we write
a A
Similarly if a is not an element of A, we write
a A
The set with no elements is called null or empty set,
denoted with .
The elements we are concerned are the coordinates of a
pixel belonging to objects or features of interest.
9/3/2019 Morphological Image Processing 5
Basic Concepts
If every element of a set A is also an element of another set B, then we write
A B
The union of two sets A and B, is denoted as
C=AB
The intersection of two sets A and B, is denoted as
D = A B
Two sets A and B, are said to be disjoint if
A B =
9/3/2019 Morphological Image Processing 6
Basic Concepts
A complement of a set A, is the set of elements not contained in A
Ac={w | w A}
The difference of two sets A and B, the set of elements of A that do not belong to B
A-B={ w | w A, w B }= ABc
9/3/2019 Morphological Image Processing 7
Basic Concepts
9/3/2019 Morphological Image Processing 8
Basic Concepts
A reflection of a set B, denoted is defined as
The translation of a set A by point z=(z1,z2), denoted (A)z is
defined as
BbbwwB para,ˆ
B̂
AazaccA z for ,
9/3/2019 Morphological Image Processing 9
Logic Operations
Some logic operations
A B NOT(A)
A OR B A AND B A XOR B
9/3/2019 Morphological Image Processing 10
Dilation
Definition:
Examples:
A B
ABxBA x ˆ|
A BAStructuring
Element
(SE)
B
B
.
B̂
B̂
A
9/3/2019 Morphological Image Processing 11
Dilation
Example:
9/3/2019 Morphological Image Processing 12
Dilation
Application Example:
SE
9/3/2019 Morphological Image Processing 13
Erosion
Definition:
Examples:
B
A BA
BAA
B
ABxBA x |
Example:
9/3/2019 Morphological Image Processing 14
Erosion
9/3/2019 Morphological Image Processing 15
Erosion
Application example: eliminating irrelevant details
image of squares of
size 1, 3, 5 ,7, 9 e 15
after with dilation with
13 13 square SE
after erosion with
13 13 square SE
9/3/2019 Morphological Image Processing 16
Erosion
Application example: eliminating lines using square SE
15×15 45×45
input image
486×486
11×11
9/3/2019 Morphological Image Processing 17
Erosion-Dilation Duality
Erosion and Dilation are duals, formally
and
in other words, the erosion of A by B is the complement of
the dilation of A by , and vice-versa.
BABA c ˆ)(
BABA cc ˆ)(
B̂
9/3/2019 Morphological Image Processing 18
Opening and Closing
Opening
Closing
BBABA )()(
BBABA )()(
)( BA BBABA )()(
BBABA )()()( BA
original image SE
Geometric Interpretation of Opening
The “rolling ball” rolls around the inside of A’s boundary.
The points covered by B is A○B
9/3/2019 Morphological Image Processing 19
Opening and Closing
ABBBA zz
9/3/2019 Morphological Image Processing 20
Opening and Closing
Geometric Interpretation of Closing
The “rolling ball” rolls on the outer boundary of A.
The points covered by B is the complement of AB.
9/3/2019 Morphological Image Processing 21
Opening-Closing Duality
Opening and Closing are duals, formally
and
in other words, the complement of the closing of A by B is
the opening of the complement of A by , and vice-versa.
BABA cc ˆ
BABA cc ˆ
B̂
9/3/2019 Morphological Image Processing 22
Opening and Closing
Application Example
9/3/2019 Morphological Image Processing 23
Hit or Miss
Definition: for
A
Ac
1B
2B
× ×
×
21 BB
A 1B
cA 2B
BA Ο
hit
miss
𝐴⊛𝐵1,2 = 𝐴⊖𝐵1 ⋂ 𝐴𝑐 ⊖𝐵2
Hit or Misssim
9/3/2019 Morphological Image Processing 24
single pixel
detection
upper-right
corner
detection
vertical-right
border
detection
9/3/2019 Morphological Image Processing 25
Basic Morphological Algorithms
Boundary Extraction
)( BAAA
9/3/2019 Morphological Image Processing 26
Basic Morphological Algorithms
Boundary Extraction
)( BAAA
9/3/2019 Morphological Image Processing 27
Basic Morphological Algorithms
Hole Filling
Problem formulation Let A be the set of pixels in the
contour of a region Y
Let p a pixel in the interior of the region Y
Compute Y
Solution
where
X0=p
B is a proper SE
Y=Xk=Xk-1
,...3,2,1,)( 1 kABXX c
kk
9/3/2019 Morphological Image Processing 28
Basic Morphological Algorithms
Hole Filling
Problem formulation Let A be the set of pixels in the
contour of a region Y
Let p a pixel in the interior of the region Y
Compute Y
Solution
where
X0=p
B is a proper SE
Y=Xk=Xk-1
,...3,2,1,)( 1 kABXX c
kk
9/3/2019 Morphological Image Processing 29
Basic Morphological Algorithms
Extracting Connected Components
X- ray of a chicken breast
with bone fragments
Thresholded image
Image eroded with a
5×5 SE
9/3/2019 Morphological Image Processing 30
Basic Morphological Algorithms
Thinning: Reduces binary objects or shapes to strokes that
are a single pixel wide
input image after many thinnings
9/3/2019 Morphological Image Processing 31
Basic Morphological Algorithms
Thickening: thicken objects without joining disconnected 1s
Usual procedure: thin background of image and complement result
input image after many thickenings
9/3/2019 Morphological Image Processing 32
Basic Morphological Algorithms
Skeletons: S(A)
z is a point of S(A) if the largest disk (D)z
centered at z and contained in A, touches
the boundary of A at two or more different
places.
9/3/2019 Morphological Image Processing 33
Basic Morphological Algorithms
Skeletons: example
input image skeleton
9/3/2019 Morphological Image Processing 34
Basic Morphological Algorithms
Pruning: cleans up parasitic components that
remains after thinning or skeletonizing.
input image after pruning
9/3/2019 Morphological Image Processing 35
Morphological Reconstruction
Geodesic dilation
Let F denote a marker image and G a mask image.
GBFFDG )1(
FDDFD n
GG
n
G
)1()1()(
limits the growth
9/3/2019 Morphological Image Processing 36
Morphological Reconstruction
Reconstruction by dilation
Is the geodesic dilation of marker F with respect to
mask G, iterated until stability is achieved, that is
until
FDFR k
G
D
G
)( FDFD k
G
k
G
)1()(
9/3/2019 Morphological Image Processing 37
Morphological Reconstruction
Reconstruction by dilation GBFFDG )1(
FDDFD n
GG
n
G
)1()1()(
FDFR k
G
D
G
)(
FDFD k
G
k
G
)1()(
9/3/2019 Morphological Image Processing 38
Morphological Reconstruction
Reconstruction by dilation GBFFDG )1(
FDDFD n
GG
n
G
)1()1()(
FDFR k
G
D
G
)(
FDFD k
G
k
G
)1()(
If the intersection between
the dilated marker and the
mask is non empty,
reconstruction by
dilation rebuilds the
mask from that!
9/3/2019 Morphological Image Processing 39
Morphological Reconstruction
Opening by reconstruction
Erosion first removes small objects and reconstruction by
dilation is executed from them. Formally
where indicates n erosions of F by B.
Note that:
F is the mask image
is the marker image
Restores exactly the shape of objects in the mask F that
remain after erosion
)][()( nBFRFO D
F
n
R
)( nBF
)( nBF
9/3/2019 Morphological Image Processing 40
Morphological Reconstruction
Opening by reconstruction (example): extract characters
that contain long vertical strokes
Text image (I) 918×2018 pixels
Character height aprox. 50 pixels Erosion with a SE (𝐵1) of 51×1 pixels
Opening of the eroded image Reconstruction of the eroded image
does not
restore the
original
𝐼 ⊖ 𝐵1
𝑂𝑅(1)
𝐼 𝐼 ∘ 𝐵1 SE (𝐵2)
of 3×3
pixels
restores
exactly the
original!
Summary
9/3/2019 Morphological Image Processing 41
Summary
9/3/2019 Morphological Image Processing 42
Summary
9/3/2019 Morphological Image Processing 43
9/3/2019 Morphological Image Processing 44
Structuring Elements
only the form matters used infrequently in
practice
9/3/2019 Morphological Image Processing 45
Dilation and Erosion Dilation
The dilation of a gray scale image f by a flat SE b at any
location (x,y) is the maximum of the image in the region
coincident with b when the origin of b is (x,y).
Erosion
The erosion of a gray scale image f by a flat SE b at any
location (x,y) is the minimum of the image in the region
coincident with b when the origin of b is (x,y).
)},({max),)((),(
tysxfyxbfbts
)},({min)(),(
tysxfbfbts
9/3/2019 Morphological Image Processing 46
Dilation and Erosion
Examples
X-ray image with
448×425 pixels
Erosion using a flat
disk SE with radius
of 2 pixels.
Dilation using the
same SE
9/3/2019 Morphological Image Processing 47
Opening and Closing
Opening (same form)
Closing (same form)
Duality (same form)
bbfbf )(
bbfbf )(
bfbf cc ˆ bfbf cc ˆ
9/3/2019 Morphological Image Processing 48
Opening and Closing
Opening and Closing
Original 1-D signal
Flat structuring element
Opening
Flat SE pushed down along the top of
the signal
Closing
9/3/2019 Morphological Image Processing 49
Opening and Closing
Examples
X-ray image with
448×425 pixels
Opening using a flat
disk SE with radius
of 3 pixels.
Closing using an SE
with radius 5
Eliminates small/thin
bright regions.
Eliminates small/thin
dark regions.
9/3/2019 Morphological Image Processing 50
Gray Scale Morphological Algorithms
Morphological smoothing
566×566 pixels
Cygnus Loop
Supernova, taken in
the X-ray banc by
Hubble telescope
Result of opening
and closing with a
disk SE of radius 1
pixel
Result of opening
and closing with a
disk SE of radius 5
pixels
Result of opening
and closing with a
disk SE of radius 3
pixels
bbf )(
9/3/2019 Morphological Image Processing 51
Gray Scale Morphological Algorithms
Morphological gradient
512×512 image of a
head CT scan
Result of dilation
Gradient result Result of erosion
)()( bfbfg
9/3/2019 Morphological Image Processing 52
Gray Scale Morphological Algorithms
Top-hat transformations
Bottom-hat transformations
One of the principal applications is in removing objects from an
image by using a SE that does not fit the objects to be removed.
Top-hat keeps light objects on a dark background.
Bottom-hat keeps dark object on a light background.
)( bffThat
fbfBhat )(
9/3/2019 Morphological Image Processing 53
Gray Scale Morphological Algorithms
Top-hat application: correction of non-uniform illumination.
Input 600×600 image Thresholded image
Image opened
with a disk SE
of radius 40
Top-hat
transformation
Thresholded top-
hat image
9/3/2019 Morphological Image Processing 54
Gray-scale Morphological Reconstruction
Geodesic dilation
Let f and g denote the marker and mask gray-scale
images, where f g
where denotes the point-wise minimum operator.
gbffDg )()()1(
fDDfD n
gg
n
g
)1()1()( )(
9/3/2019 Morphological Image Processing 55
Gray-scale Morphological Reconstruction
Geodesic erosion
Let f and g denote the marker and mask gray-scale images.
Its defined as
where denotes the point-wise maximum operator.
gbffEg )()()1(
fEEfE n
gg
n
g
)1()1()( )(
9/3/2019 Morphological Image Processing 56
Gray-scale Morphological Reconstruction
Reconstruction by dilation of a gray-scale mask image g
by a gray-scale marker image f, is the geodesic dilation of
f with respect go g iterated until stability is achieved
until
Reconstruction by erosion of g by f is similarly defined as
until
fDfR k
g
D
g
)( fDfD k
g
k
g
)1()(
fEfR k
g
E
g
)( fEfE k
g
k
g
)1()(
9/3/2019 Morphological Image Processing 57
Gray-scale Morphological Reconstruction
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
where indicates n erosions of f by b.
)][()( bnfRfO D
f
n
R
)( bnf
9/3/2019 Morphological Image Processing 58
Gray-scale Morphological Reconstruction
Top-hat by reconstruction consists of subtracting from an
image f its opening by reconstruction
fOffT n
Rhat
)(
9/3/2019 Morphological Image Processing 59
Gray-scale Morphological Reconstruction
Example
a) Input image 1134x1360 pixels
b) Opening by reconstruction of (a) using a horizontal line 71 pixels long in the erosion
c) Opening of (a) using the same line (just for comparison)
d) Top-hat by reconstruction
e) Top-hat (just for comparison)
f) Opening by reconstruction of (d) using a vertical line 11 pixels long
g) Dilation of (f) using a horizontal line 21 pixels long
h) Minimum of (d) and (g)
i) Using (h) as a marker and (g) as the mask and applying reconstruction by dilation with a vertical SE.
9/3/2019 Morphological Image Processing 60
Next Topic
Segmentation