Digital Image Processing
Morphological Image Processing
Contents
In this lecture we will consider
– What is morphology?
– Simple morphological operations
– Compound operations
– Morphological algorithms
2
What Is Morphology?
Morphological image processing describes a range
of image processing techniques that deal with the
shape (or morphology) of features in an image.
The term morphology is also used in meaning of
morphological processing.
Morphological operations are typically applied to
remove imperfections introduced during
segmentation, and so typically operate on binary
images.
3
Quick Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Image after segmentation Image after segmentation and
morphological processing
4
Structuring Elements, Hits & Fits
B Structuring Element
Fit: All on pixels in the
structuring element cover
on pixels in the image
A
Hit: Any on pixel in the
C structuring element covers
an on pixel in the image
All morphological processing operations are based
on these simple ideas
5
Structuring Elements
Structuring elements can be any size and form any
shape.
However, for simplicity rectangular structuring
elements with their origin at the middle pixel are
preferred.
0 0 1 0 0
0 1 1 1 0
1 1 1 0 1 0
1 1 1 1 1
1 1 1 1 1 1
0 1 1 1 0
1 1 1 0 1 0 0 0 1 0 0
6
Fitting & Hitting
0 0 0 0 0 0 0 0 0 0 0 0
1 1 1
0 0 0 1 1 0 0 0 0 0 0 0
1 1 1
0 0 1 B
1 1 1 1 0 C
0 0 0 0
1 1 1
0 1 1 1 1 1 1 1 0 0 0 0 Structuring
0 1 1 1 1 1 1 1 0 0 0 0 Element 1
0 0 1 1 1 1 1 1 0 0 0 0 0 1 0
0 0 1 1 1 1 1 1 1 0 0 0 1 1 1
0 0 1 1 1 1 1 A
1 1 1 1 0 0 1 0
0 0 0 0 0 1 1 1 1 1 1 0 Structuring
Element 2
0 0 0 0 0 0 0 0 0 0 0 0
7
Fundamental Operations
Fundamentally morphological image processing is
very like spatial filtering.
The structuring element is moved across every
pixel in the original image to generate a pixel in
new processed image.
The value of this new pixel depends on the
operation performed.
There are two basic morphological operations:
erosion and dilation.
8
Erosion
Erosion of image f by structuring element s is
given by:
fs
The structuring element s is positioned with its
origin at (x, y) and the new pixel value is
determined using the rule:
1 if s fits f
g ( x, y )
0 otherwise
9
Erosion Example
Original Image Processed Image
Structuring Element
11
Erosion Example 1
Original image Erosion by 3*3 Erosion by 5*5
square structuring square structuring
element element
Watch out: In these examples a 1 refers to a black pixel!
12
Erosion Example 2
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
After erosion
Original
with a disc of
image
radius 10
After erosion After erosion
with a disc of with a disc of
radius 5 radius 20
13
What Is Erosion For?
Erosion can split apart joined objects
Erosion can strip away extrusions
Watch out: Erosion shrinks objects
14
Dilation
Dilation of image f by structuring element s is
given by
f s
The structuring element s is positioned with its
origin at (x, y) and the new pixel value is
determined using the rule:
1 if s hits f
g ( x, y )
0 otherwise
15
Dilation Example
Original Image Processed Image With Dilated Pixels
Structuring Element
17
Dilation Example 1
Original image Dilation by 3*3 Dilation by 5*5
square structuring square structuring
element element
18
Dilation Example 2
Original image After dilation
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Structuring element 19
What Is Dilation For?
Dilation can repair breaks
Dilation can repair intrusions
Watch out: Dilation enlarges objects
20
Compound Operations
More interesting morphological operations can be
performed by combining erosions and dilations.
The most widely used types of these compound
operations are:
– Opening
– Closing
21
Opening
The opening of image f by structuring element s,
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
denoted f ○ s is simply an erosion followed by a
dilation:
f ○ s = (f s) s
Original shape After erosion After dilation
(opening)
Note: A disc shaped structuring element is used.
22
Opening
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Original Image Image After Opening
Opening
- breaks narrow links
- eliminate thin protrusions
- smooths the surface (depends on structuring element)
23
Opening Example
Original Image Processed Image
Structuring Element
25
Closing
The closing of image f by structuring element s,
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
denoted f • s is simply a dilation followed by an
erosion
f • s = (f s)s
Original shape After dilation After erosion
(closing)
Note: A disc shaped structuring element is used
26
Closing Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Original Image Image After Closing
Closing
- fuses narrow breaks (merges close elements)
- eliminate thin gulfs and small holes
- smooths the surface (depends on structuring element)
27
Closing Example
Original Image Processed Image
Structuring Element
29
Morphological Processing Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Some of the
gaps were
removed.
Noise is eliminated,
but gaps occured
on the fingerprint
30
Morphological Algorithms
Using the simple technique we have looked at so
far we can begin to consider some more
interesting morphological algorithms.
We will look at:
– Boundary extraction
– Region filling
– Extraction of connected components
– Skeleton extraction
31
Boundary Extraction
Extracting the boundary (or outline) of an object is
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
often extremely useful.
The boundary can be given simply as
β(A) = A – (AB)
32
Boundary Extraction Example
A simple image and the result of performing boundary
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
extraction using a square 3x3 structuring element.
Original Image Extracted Boundary
33
Region Filling
Given a pixel inside a boundary, region filling
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
attempts to fill inside the boundary with object
pixels (whites).
Given a point inside
here, can we fill the
whole circle?
34
Region Filling (cont…)
The key equation for region filling is
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
X k ( X k 1 B) Ac
k 1,2,3.....
where X0 is simply the starting point inside the
boundary, B is a simple structuring element and
Ac is the complement of A.
This equation is applied repeatedly until Xk is
equal to Xk-1.
Finally the result is unioned with the original
boundary.
35
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Region Filling Step By Step
36
Region Filling Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Original Image One Region All Regions
Filled Filled
37
Extraction of Connected
Components
Equation for connected component extraction is
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
X k ( X k 1 B) A k 1,2,3.....
where X0 is simply a starting point inside the object,
B is the structuring element.
This equation is applied repeatedly until Xk is
equal to Xk-1.
38
Extraction of Connected
Components
Original Image (A) X0
Structuring X k ( X k 1 B) A
Element (B)
39
Extraction of Connected
Components
X1 X4 (final for object 1)
Structuring X k ( X k 1 B) A
Element (B)
40
Extraction of Connected
Components
After an object is labeled,
procedure continues with
other unlabeled pixels. Final result.
41
Skeleton Extraction
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Original Image Structuring Extracted
element passed Skeleton
Structuring along the image
Element
42
Summary
The purpose of morphological processing is
primarily to remove imperfections and to extract
certain properties from objects.
The basic operations are erosion and dilation.
Using the basic operations we can perform
opening and closing.
More advanced morphological operations can then
be implemented using combinations of these.
43