Professional Documents
Culture Documents
1
DIGITAL IMAGE PROCESSING - 2
• Dilation
• Erosion
• Opening
• Closing
• Hit-or-Miss transform
5
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion
• Dilation
• Erosion
6
of morphological filters in Sections 9.4 and 9.8.
DIGITAL IMAGE PROCESSING - 2
Dilation
2
s sets in Z
• With A, the
and dilation
B as setsofinAZ2by B, denoted
, Dilation as A {byBstructuring
of a set , is defined as
element B:
{
A { B = z P( Bˆ ) z ¨ A ¹ Æ } (9-6)
• Grow the object (Does the structuring element hit the set?)
7
DIGITAL IMAGE PROCESSING - 2
Dilation
8
DIGITAL IMAGE PROCESSING - 2
Example of Dilation
• Dilation of A by B is
9
DIGITAL IMAGE PROCESSING - 2
Example of Dilation
• Dilation of A by B is
10
DIGITAL IMAGE PROCESSING - 2
Example of Dilation : Bridging Gaps
11
DIGITAL IMAGE PROCESSING - 2
Example of Dilation : Bridging Gaps
12
DIGITAL IMAGE PROCESSING - 2
✓Dilation
• Erosion
• Opening
• Closing
• Hit-or-Miss transform
5
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion
• Dilation
• Erosion
6
DIGITAL IMAGE PROCESSING - 2
Erosion
8
DIGITAL IMAGE PROCESSING - 2
Erosion
9
DIGITAL IMAGE PROCESSING - 2
Examples of Erosion
10
DIGITAL IMAGE PROCESSING - 2
Examples of Erosion
13
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion
and
14
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion
15
DIGITAL IMAGE PROCESSING - 2
Application
• Dilation
• Filling of holes of certain shape and size, given by SE
• Erosion
• Removal of structures of certain shape and size, given by SE
16
DIGITAL IMAGE PROCESSING - 2
Example 1
17
DIGITAL IMAGE PROCESSING - 2
Example 1
18
DIGITAL IMAGE PROCESSING - 2
Example 1
19
DIGITAL IMAGE PROCESSING - 2
Process
20
DIGITAL IMAGE PROCESSING - 2
Example 2
21
DIGITAL IMAGE PROCESSING - 2
and
5
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion
6
DIGITAL IMAGE PROCESSING - 2
Application
• Dilation
• Filling of holes of certain shape and size, given by SE
• Erosion
• Removal of structures of certain shape and size, given by SE
7
DIGITAL IMAGE PROCESSING - 2
Example 2
8
DIGITAL IMAGE PROCESSING - 2
Example 2
9
DIGITAL IMAGE PROCESSING - 2
Example 1
Reflected SE
10
DIGITAL IMAGE PROCESSING - 2
Example 1
11
DIGITAL IMAGE PROCESSING - 2
Example 1
12
DIGITAL IMAGE PROCESSING - 2
Example 1
13
DIGITAL IMAGE PROCESSING - 2
Example 3
• Using input image and structuring element as given below find
the eroded version of the input image
14
DIGITAL IMAGE PROCESSING - 2
Example 3
15
DIGITAL IMAGE PROCESSING - 2
Example 3
Eroded Image
16
DIGITAL IMAGE PROCESSING - 2
Example 4
17
DIGITAL IMAGE PROCESSING - 2
Combining Erosion and Dilation
• Requirement:
• Remove structures / fill holes without affecting remaining
parts
• Solution:
• Combine erosion and dilation (using same SE)
• Results in two operations:
• Opening
• Closing
18
DIGITAL IMAGE PROCESSING - 2
Opening
• Eliminates protrusions
• Breaks necks
• Smoothes contour
• The opening of A by B is the union of all the
translations of B so that B fits entirely in A.
19
DIGITAL IMAGE PROCESSING - 2
Opening
20
DIGITAL IMAGE PROCESSING - 2
• Requirement:
• Remove structures / fill holes without affecting remaining
parts
• Solution:
• Combine erosion and dilation (using same SE)
• Results in two operations:
• Opening
• Closing
5
DIGITAL IMAGE PROCESSING - 2
Opening
• Eliminates protrusions
• Breaks necks
• Smoothes contour
6
DIGITAL IMAGE PROCESSING - 2
Opening
7
DIGITAL IMAGE PROCESSING - 2
Opening
• Observe that, in this case, the opening is a set composed of
two disjoint subsets, resulting from the fact that B could
not fit in the narrow segment in the center of A.
• So the opening of A by B is also given by the union of all the
translations of B so that B fits entirely in A.
• The ability to eliminate regions narrower than the
structuring element is one of the key features of
morphological opening
• The interpretation that the opening of A by B is the union
of all the translations of B such that B fits entirely within A
can be written in equation form as
8
Where ́ denotes the union of the sets inside the braces.
DIGITAL IMAGE PROCESSING - 2
Opening
9
DIGITAL IMAGE PROCESSING - 2
Opening
10
DIGITAL IMAGE PROCESSING - 2
Closing
• Smoothes contour
• Fuse narrow breaks and long thin gulfs
• Eliminate small holes
• Fill gaps in the contour
11
DIGITAL IMAGE PROCESSING - 2
Closing
12
DIGITAL IMAGE PROCESSING - 2
Closing
13
DIGITAL IMAGE PROCESSING - 2
Closing
14
DIGITAL IMAGE PROCESSING - 2
Example 2
15
DIGITAL IMAGE PROCESSING - 2
Example 2
Opening
Morphological opening removes
regions that cannot contain the
structuring element, smoothens
object contours, breaks thin
connections, and removes thin
protrusions.
17
The final result of opening
DIGITAL IMAGE PROCESSING - 2
Example
Closing
• As with opening, closing also
smoothens the contours of objects.
• However, unlike opening, closing
tends to join narrow breaks, fills
long thin gulfs, and fills objects
smaller than the structuring
element.
• In this example, the principal result
of closing was that it filled the
small gulf on the left of set A.
18
DIGITAL IMAGE PROCESSING - 2
Use of Open and Close
19
DIGITAL IMAGE PROCESSING - 2
Properties
• Opening
1. A°B is a subset (subimage) of A
2. If C is a subset of D, then C °B is a subset of D °B
3. (A °B) °B = A °B
• Closing
1. A is a subset (subimage) of A•B
2. If C is a subset of D, then C •B is a subset of D •B
3. (A •B) •B = A •B
20
DIGITAL IMAGE PROCESSING - 2
Duality
21
DIGITAL IMAGE PROCESSING - 2
Binary Morphological Operations
• Hit-or-Miss transform
22
DIGITAL IMAGE PROCESSING - 2
Hit or Miss Transformation ⊛ (HMT)
• Hit-or-Miss transform
4
DIGITAL IMAGE PROCESSING - 2
Hit or Miss Transformation ⊛ (HMT)
6
DIGITAL IMAGE PROCESSING - 2
HMT Cont…
• The word “miss” in the HMT arises from the fact that B2 finding a
match in Ac is the same as B2 not finding (missing) a match in A.
7
DIGITAL IMAGE PROCESSING - 2
Example 1
8
DIGITAL IMAGE PROCESSING - 2
Example 1
9
DIGITAL IMAGE PROCESSING - 2
Example 1
10
DIGITAL IMAGE PROCESSING - 2
HMT
11
DIGITAL IMAGE PROCESSING - 2
Example 2
12
DIGITAL IMAGE PROCESSING - 2
Example 2
13
DIGITAL IMAGE PROCESSING - 2
Example 2
Image with
its foreground defined as Ac . Structuring elements designed to detect object D. 16
Element B1 is equal to D itself
DIGITAL IMAGE PROCESSING - 2
Next Session
• HMT Cont…
• Morphological Algorithms
17
THANK YOU
shruthimlj@pes.edu
+91 9482219115
18
DIGITAL IMAGE PROCESSING – 2
1
DIGITAL IMAGE PROCESSING - 2
Morphological Algorithms
3
DIGITAL IMAGE PROCESSING - 2
This Session
4
DIGITAL IMAGE PROCESSING - 2
HMT Cont…
5
DIGITAL IMAGE PROCESSING - 2
Example 3
8
DIGITAL IMAGE PROCESSING - 2
Example 3
9
Erosion of A by B1.
DIGITAL IMAGE PROCESSING - 2
Example 3
Structuring element
designed to detect object D
Image with its foreground defined as Ac
Erosion of Ac by B2 10
DIGITAL IMAGE PROCESSING - 2
Example 3
Erosion of Ac by B2 11
Erosion of A by B1. Intersection of the 2 erosions
DIGITAL IMAGE PROCESSING - 2
Using single SE
12
DIGITAL IMAGE PROCESSING - 2
Using single SE
• We can use the structuring element formed in such a way to
restate the HMT as
13
DIGITAL IMAGE PROCESSING - 2
Example 3 (using single SE)
• So using a single SE
14
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms
15
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
16
DIGITAL IMAGE PROCESSING - 2
Morphological Algorithms
Structuring element
designed to detect object D
Image with its foreground defined as Ac
Erosion of Ac by B2 4
DIGITAL IMAGE PROCESSING - 2
Example 3
Erosion of Ac by B2 5
Erosion of A by B1. Intersection of the 2 erosions
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms
6
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
7
DIGITAL IMAGE PROCESSING - 2
Boundary Extraction
8
DIGITAL IMAGE PROCESSING - 2
Boundary Extraction
Structuring
Set, A, of foreground pixels. element. A eroded by B.
Boundary of A.
9
DIGITAL IMAGE PROCESSING - 2
Boundary Extraction
Structuring
element.
A binary image
Boundary of A.
10
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
11
DIGITAL IMAGE PROCESSING - 2
Region / Hole Filling
12
DIGITAL IMAGE PROCESSING - 2
n image. Let A denote a set whose elements are 8-connected bound-
The Algorithm
boundary enclosing a background region (i.e., a hole). Given a point
objective
• Step 1:is to fill all the holes with foreground elements (1’ s).
orming
• Formananarray, X0 0of, 0’s
array , X 0’s (the
of (same size same
as I, thesize ascontaining
image I , the image
A) containing
ationsexcept
in Xat0locations in X0 that correspond
that correspond to pixels to pixels
thatthat
areareknown to be holes,
known to be holes, which we set to 1. Then following
1. Then, the following procedure fills all the holes with 1’ s:
procedure fills all the holes with 1’s
X k = ( X k -1 { B ) ¨ I c
k = 1, 2, 3, … (9-19)
• B is symmetric
ymmetric SE
structuring element in Fig. 9.17(c) . The algorithm termi-
• The
n step k if X k = terminates
algorithm at iteration
X k -1. Then, step k if Xall
X k contains k=X the
k-1 filled holes. The set
• Union ofall
I contains original image Iholes
the filled with Xkand
results in region
their filling
boundaries.
n Eq. (9-19) would fill the entire area if left unchecked, but the
ach step with I c limits the result to inside the region of interest. This is 13
DIGITAL IMAGEfilling holes in an image. Let A denote a set whose elements are 8-connected bound-
PROCESSING -2
aries, with each boundary enclosing a background region (i.e., a hole). Given a point
Example 1 in each hole, the objective is to fill all the holes with foreground elements (1’ s).
We begin by forming an array, X 0 , of 0’s (the same size as I , the image containing
A), except at locations in X 0 that correspond to pixels that are known to be holes,
• The input image
whichand
we structuring the following
element
set to 1. Then, procedure
are shown fills all the holes with 1’ s:
below.
Remember, the dila-
Perform region filling operation
X k = ( X k -1 { B ) ¨ I c
tion of image X by B
is the dilation of the k = 1, 2, 3, … (9-19)
foreground
elements of X by B.
where B is the symmetric structuring element in Fig. 9.17(c) . The algorithm termi-
nates at iteration step k if X k = X k -1. Then, X k contains all the filled holes. The set
union of X k and I contains all the filled holes and their boundaries.
The dilation in Eq. (9-19) would fill the entire area if left unchecked, but the
intersection at each step with I c limits the result to inside the region of interest. This is
our first example of how a morphological process can be conditioned to meet a desired
property. In the current application, the process is appropriately called conditional
Input Image Structuring
dilation. The restElement
of Fig. 9.17 illustrates furtherof
Complement the mechanics
Input Imageof Eq. (9-19). This exam-
ple only has one hole, but the concept applies to any finite number of holes, assuming
that a point inside each hole is given (we remove this requirement in Section 9.6).
14
E
XAMPE9.6: M
L orph
ologic
al h
olefillin
g.
by forming an array, X 0 , of 0’s (the same size as I , the image containing
DIGITAL IMAGE
locations in X 0PROCESSING -2
that correspond to pixels that are known to be holes,
Then,1the
Example
to 1. following procedure fills all the holes with 1’ s:
: Solution
X k = ( X k -1 { B ) ¨ I c
k = 1, 2, 3, … (9-19)
• Step 1: Initially take X0 as shown below.
e symmetric
• Perform dilationstructuring
of X with SE B.
0
element in Fig. 9.17(c) . The algorithm termi-
tion •• step k if X k = X k -1. Then, X k contains all the filled holes. The set
The resultant image is then intersected with complement of input image, I.
This completes first iteration.
and I contains all the filled holes and their boundaries.
on in Eq. (9-19) would fill the entire area if left unchecked, but the
t each step with I c limits the result to inside the region of interest. This is
ple of how a morphological process can be conditioned to meet a desired
he current application, the process is appropriately called conditional
est of Fig. 9.17 illustrates further the mechanics of Eq. (9-19). This exam-
one hole, but the concept applies to any finite number of holes, assuming
15
nside each hole is given (we remove this requirement in Section 9.6).
DIGITAL IMAGE PROCESSING - 2
Example 1 : Solution
16
DIGITAL IMAGE PROCESSING - 2
Example 1 : Solution
17
DIGITAL IMAGE PROCESSING - 2
Example 1 : Solution
• Step 6:
18
by forming an array, X 0 , of 0’s (the same size as I , the image containing
DIGITAL IMAGE PROCESSING - 2
locations in X 0 that correspond to pixels that are known to be holes,
Example
to 1. Then,2the following procedure fills all the holes with 1’ s:
X k = ( X k -1 { B ) ¨ I c k = 1, 2, 3, … (9-19)
✓Boundary Extraction
✓Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
20
DIGITAL IMAGE PROCESSING - 2
✓Boundary Extraction
✓Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
4
DIGITAL IMAGE PROCESSING - 2
Extraction of Connected Componenets
5
DIGITAL IMAGE PROCESSING - 2
Extraction of Connected Components
6
DIGITAL IMAGE PROCESSING - 2
Example
7
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
8
DIGITAL IMAGE PROCESSING - 2
Convex Hull
9
DIGITAL IMAGE PROCESSING - 2
Convex Hull
with
When procedure converges using ith SE (when we let
10
DIGITAL IMAGE PROCESSING - 2
Convex Hull
11
DIGITAL IMAGE PROCESSING - 2
Example 1
Structuring elements.
12
DIGITAL IMAGE PROCESSING - 2
Example 1
Structuring elements.
13
DIGITAL IMAGE PROCESSING - 2
Example 1
Structuring elements.
14
DIGITAL IMAGE PROCESSING - 2
Example 1
Structuring elements.
15
DIGITAL IMAGE PROCESSING - 2
Example 1
Structuring elements.
16
DIGITAL IMAGE PROCESSING - 2
Example 1
Structuring elements.
17
DIGITAL IMAGE PROCESSING - 2
Example 1
18
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
19
DIGITAL IMAGE PROCESSING - 2
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull Cont..
• Thinning
• Thickening
• Skeletons
• Pruning
4
DIGITAL IMAGE PROCESSING - 2
Convex Hull
Convex Set
7
DIGITAL IMAGE PROCESSING - 2
Algorithm to determine Convex Hull
with
When procedure converges using ith SE
8
DIGITAL IMAGE PROCESSING - 2
Convex Hull
9
DIGITAL IMAGE PROCESSING - 2
Example
Structuring elements.
10
DIGITAL IMAGE PROCESSING - 2
Example: First ISE, i=1
Structuring element
X1 1 X1 2
11
X1 X1 4
DIGITAL IMAGE PROCESSING - 2
Example: Second SE, i=2
Structuring element
X2 0 X2 1 X2 2
12
DIGITAL IMAGE PROCESSING - 2
Example: Third SE, i=3
Structuring element
13
DIGITAL IMAGE PROCESSING - 2
Example: Fourth SE, i=4
Structuring element
X4 1
14
DIGITAL IMAGE PROCESSING - 2
Example 1
Structuring elements.
15
DIGITAL IMAGE PROCESSING - 2
Example 1
16
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
17
DIGITAL IMAGE PROCESSING - 2
Thinning
18
DIGITAL IMAGE PROCESSING - 2
Example
• Then thin the result with one pass of B2, and so on, until A is
thinned with one pass of Bn.
19
DIGITAL IMAGE PROCESSING - 2
Example
20
DIGITAL IMAGE PROCESSING - 2
Example
21
DIGITAL IMAGE PROCESSING - 2
Example
22
DIGITAL IMAGE PROCESSING - 2
Example
23
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
24
ADVANCED DIGITAL IMAGE PROCESSING
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
5
ADVANCED DIGITAL IMAGE PROCESSING
Thickening
• Morphological operation used to grow selected regions of
foreground pixels
• Thickening is the morphological dual of thinning and is defined
by the expression
6
ADVANCED DIGITAL IMAGE PROCESSING
Thickening
• The structuring elements used for thickening have the same form as
those shown in thinning but with all 1’s and 0’s interchanged
8
ADVANCED DIGITAL IMAGE PROCESSING
Example of Thickening using Thinning
Perform
Using
Analysis
10
ADVANCED DIGITAL IMAGE PROCESSING
Some Basic Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
11
ADVANCED DIGITAL IMAGE PROCESSING
Skeletons
12
ADVANCED DIGITAL IMAGE PROCESSING
Skeletons
With where
14
ADVANCED DIGITAL IMAGE PROCESSING
Example
Consider Set A.
15
ADVANCED DIGITAL IMAGE PROCESSING
Some Basic Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
16
ADVANCED DIGITAL IMAGE PROCESSING
Pruning
• Complement to thinning and skeletonizing algorithms
19
ADVANCED DIGITAL IMAGE PROCESSING
Example
Step 2: The next step is to “restore” the character to its original form, but
with the parasitic branches removed.
This requires that we first form a set X2 containing all end points in X1
21
ADVANCED DIGITAL IMAGE PROCESSING
Example
23
ADVANCED DIGITAL IMAGE PROCESSING
Example
X 1 = A Ä{B} ;Thinning
25
ADVANCED DIGITAL IMAGE PROCESSING
Summary of
binary
morpho
logical
operations
and
their
properties.
26
DIGITAL IMAGE PROCESSING - 2
Grayscale Morphology
5
DIGITAL IMAGE PROCESSING - 2
Structuring Elements
7
DIGITAL IMAGE PROCESSING - 2
Grayscale Morphological Operations
• Erosion
• Dilation
• Opening
• Closing
8
DIGITAL IMAGE PROCESSING - 2
Erosion
• The grayscale erosion of f by a flat structuring element b at
location (x, y) is defined as the minimum value of the image in
the region coincident with b(x, y) when the origin of b is at (x, y)
• The erosion at (x, y) of an image f by a structuring element b is
given as
Erosion
• For example, if b is a square structuring element of size 3 × 3,
obtaining the erosion at a point requires finding the minimum of
the nine values of f contained in the 3 × 3 region spanned by b
when its origin is at that point.
• Because grayscale erosion with a flat SE computes the minimum
intensity value of f in every neighborhood of (x, y) coincident
with b, we expect in general
• that an eroded grayscale image will be darker than the
original
• that the sizes (with respect to the size of the SE) of bright
features will be reduced
• and that the sizes of dark features will be increased
10
DIGITAL IMAGE PROCESSING - 2
Erosion Example
Grayscale Dilation
• Grayscale dilation of f by a flat structuring element b at any
location (x,y) is defined as the maximum value of the image in
the window spanned by when the origin of is at (x, y)
Where
Grayscale Dilation
Gray-scale X-ray image of Erosion using a flat disk SE Dilation using the same SE.
size 448 x 425 pixels. with a radius of 2 pixels
• The effects are the opposite of using erosion. The bright features were
thickened and the intensities of the darker features were reduced.
• In particular, the thin black connecting wires in the left, middle, and right
bottom are barely visible
• The sizes of the dark dots were reduced as a result of dilation, but, unlike the
eroded small white dots, they still are easily visible in the dilated image.
• The reason is that the black dots were originally larger than the white dots with
respect to the size of the SE. Finally, observe that the background of the dilated 14
image is slightly lighter than that of (a).
DIGITAL IMAGE PROCESSING - 2
15
DIGITAL IMAGE PROCESSING - 2
16
DIGITAL IMAGE PROCESSING - 2
17
DIGITAL IMAGE PROCESSING - 2
18
DIGITAL IMAGE PROCESSING - 2
• The opening and closing for grayscale images are duals with
respect to complementation and SE reflection:
19
DIGITAL IMAGE PROCESSING - 2
20
DIGITAL IMAGE PROCESSING - 2
Summary of Unit 2
• Basic Morphological operations
• Erosion
• Dilation
• Opening
• Closing
• Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning
• Grayscale Morphology
• Grayscale morphological operations
23