Image Processing 5
Image Processing 5
Introduction to
Morphological
Image Processing
Bal Krishna Subedi
CDCSIT, TU
Contents
LogicOperations involving binary images, Dilation and
Erosion, Opening and Closing LH
2
What Is Morphology?
Morphological image processing (or morphology) describes
a range of image processing techniques that deal with the
shape (or morphology) of features in an image
Morphological operations are typically applied to remove
imperfections introduced during segmentation, and so
typically operate on bi-level images
Morphological techniques probe an image with a small shape
or template called a structuring element.
The structuring element is positioned at all possible locations
in the image and it is compared with the corresponding
neighbourhood of pixels. Some operations test whether the
element "fits" within the neighbourhood, while others test
whether it "hits" or intersects the neighbourhood.
The word morphology commonly denotes a branch of
biology that deals with the form and structure of animals
and plants.
Mathematical morphology is a tool that extract image
components that are useful in the representation and
description of region shape.
Set theory is usually used to describe mathematical
morphology.
Sets represent objects in a binary image.
Quick Example
B Structuring Element
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
Fundamental Operations
Fundamentally morphological image
processing is very like spatial filtering.
The structuring element is moved
across every pixel in the original
image to give a pixel in a new
processed image.
The value of this new pixel depends on
the operation performed.
There are two basic morphological
operations: erosion and dilation
Dilation
Dilation: Algorithm
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
Dilation Example
Original Image Processed Image
Structuring Element
Dilation Example
Original Image Processed Image With Dilated Pixels
Structuring Element
Dilation Example 1
Structuring element
What Is Dilation For?
Dilation can repair breaks
1 if s fits f
g ( x, y )
0 otherwise
Erosion Example
Original Image Processed Image With Eroded Pixels
Structuring Element
Erosion Example
Original Image Processed Image
Structuring Element
Erosion Example 1
After erosion
Original
with a disc of
image
radius 10
After
Image
Image
Original
Opening
Opening Example
Opening Example
Original Image Processed Image
Structuring Element
Opening Example
Original Image Processed Image
Structuring Element
Opening
Similar to Erosion
◦ Spot and noise removal
◦ Less destructive
Erosion next dilation
the same structuring element for both
operations.
Input:
◦ Binary Image
◦ Structuring Element, containing only 1s!
Original shape
After erosion
After dilation (closing)
After
Image
Image
Original
Closing
Closing Example
Closing Example
Original Image Processed Image
Structuring Element
Closing Example
Original Image Processed Image
Structuring Element
Closing
Similar to Dilation
◦ Removal of holes
◦ Tends to enlarge regions, shrink
background
Closing is defined as a Dilatation,
followed by an Erosion using the same
structuring element for both
operations.
Dilation next erosion!
Input:
◦ Binary Image
◦ Structuring Element, containing only 1s!
Feb 11, 2025 46
Closing
Take the structuring element (SE) and
slide it around outside each
foreground region.
◦ All background pixels which can be
covered by the SE with the SE being
entirely within the background region will
be preserved.
◦ All background pixels which can not be
reached by the structuring element without
lapping over the edge of the foreground
object will be turned into a foreground.
–Binary Image
–Structuring Element, containing 0s and
1s!!
Example for a Hit-and-miss Structuring Element
Contains 0s, 1s and don’t care’s.
Usually a “1” at the origin!
Hit and Miss Transform
If foreground and background pixels in the
structuring element exactly match foreground
and background pixels in the image, then the
pixel underneath the origin of the structuring
element is set to the foreground color.
The Hit-or-Miss transformation is useful to find
patterns in binary images.
In particular, it finds those pixels whose
neighbourhood matches the shape of a first
structuring element B1 while not matching the
shape of a second structuring element B2 at the
same time.
Mathematically, the operation applied to an
image A can be expressed as follows:
Hit and Miss Transform