0% found this document useful (0 votes)
8 views45 pages

ImageProcessing11-Morphology

Uploaded by

DK drift king
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views45 pages

ImageProcessing11-Morphology

Uploaded by

DK drift king
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 45

Digital Image Processing

Image Morphology

Dr. Fawad Nasim


[email protected]
Morphology
The word ‘Morphology’ generally represents a
branch of biology that deals with the form and
structure of animals and plants. However, we use
the same term in ‘mathematical morphology’ to
extract image components useful in
representing region shape, boundaries, etc.

c an b e used to
c al o pe rations m at ion on
logi f or
p let e, m orpho an d pr ovide in
ent at io n is com g me nt ed image
Once se
gm
t io n s in the se
ove im perfec of t he image
rem tructur e
m an d s
the for

https://towardsdatascience.com/understanding-morphological-image-processing-and-its-operations-7bcf1ed11756
Contents
In this lecture we will consider
• What is morphology?
• Simple morphological operations
• Compound operations
• Morphological algorithms
1, 0, Black, White?

Throughout all of the following slides whether 0 and 1 refer to white or


black is a little interchangeable

All of the discussion that follows assumes segmentation has


already taken place and that images are made up of 0s for background
pixels and 1s for object pixels
Quick
Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Image after segmentation and


Image after segmentation
morphological processing
Morphology

Morphology is a comprehensive set of image processing


operations that process images based on shapes. Morphological
operations apply a structuring element to an input image,
creating an output image of the same size. In a morphological
operation, the value of each pixel in the output image is based on
a comparison of the corresponding pixel in the input image with
its neighbors.
Morphology
Structuring Element: It is a matrix or a small-
sized template that is used to traverse an image.
The structuring element is positioned at all
possible locations in the image, and it is
compared with the connected pixels. It can be of
any shape.
Structuring elements can be any size and make any shape
However, for simplicity we will use rectangular structuring elements
with their origin at the middle pixel
Structuring Elements

0 0 1 0 0
1 1 1 0 1 0 0 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 1 0 0 1 1 1 0
0 0 1 0 0
Morphology

Fit: When all the pixels in the structuring element cover the pixels
of the object, we call it Fit.
Hit: When at least one of the pixels in the structuring element
cover the pixels of the object, we call it Hit.
Miss: When no pixel in the structuring element cover the pixels of
the object, we call it miss.
Structuring Elements,
Hits & Fits
B Structuring Element

A: FIT
B: HIT
A C: Miss
C

All morphological processing operations are based


on these simple ideas
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
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
Erosion
 Erosion shrinks the image pixels, or
erosion removes pixels on object
boundaries.
First, we traverse the structuring element over the image object to
perform an erosion operation f  s. The output pixel values are
calculated using the following equation.
Pixel (output) = 1 {if FIT}
Pixel (output) = 0 {otherwise}
Erosion Example
Original Image Processed Image With Eroded Pixels

Structuring Element
Erosion Example
Original Image Processed Image

Structuring Element
Erosion Example 1

Original image Erosion by 3*3 Erosion by 5*5


square structuring square structuring
element element
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
What Is Erosion For?
Erosion can split apart joined objects

Erosion canErosion
stripcan
away extrusions
split apart

Watch out: Erosion shrinks objects


Dilation
Dilationbyf s expands the image pixels, or it adds pixels
on object boundaries. First, we traverse the structuring
element over the image object to perform an dilation
operation,. The output pixel values are calculated using the
following equation.
Pixel (output) = 1 {if HIT}
Pixel (output) = 0 {otherwise}
Dilation Example
Original Image Processed Image

Structuring Element
Dilation Example
Original Image Processed Image With Dilated Pixels

Structuring Element
Dilation Example

Dilation by 3*3 Dilation by 5*5


Original image square structuring square structuring
element element
Dilation Example
What Is Dilation For?

Dilation can repair breaks

Dilation can repair intrusions

Watch out: Dilation enlarges objects


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original image

Structuring element
Dilation Example
After dilation
Compound Operations
Most morphological operations are not performed using
either dilation or erosion; instead, they are performed
by using both. Two most widely used compound
operations are:
(a)Closing (by first performing dilation and then
erosion)
(b)Opening (by first performing erosion and then
dilation).

Figure shows both compound operations on a single


object.
Opening
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

The opening of image f by structuring element s, 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


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

After
Image
Image
Original

Opening
Opening Example
Opening Example
Original Image Processed Image

Structuring Element
Opening Example
Original Image Processed Image

Structuring Element
Closing
The closing of image f by structuring
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

element s, 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


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

After
Image
Image
Original

Closing
Closing Example
Closing Example
Original Image Processed Image

Structuring Element
Closing Example
Original Image Processed Image

Structuring Element
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Morphological Processing Example


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
There are lots of others as well though:
Extraction of connected components
Thinning/thickening
Skeletonisation
Boundary Extraction
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Boundary extraction, also known as edge detection, is a


fundamental technique in image processing that involves
identifying the edges or boundaries of objects within an
image. These boundaries define the shape and structure
of objects, making them essential for various image
analysis tasks.

If A is an image and structuring element is B then Boundary


Extraction can be given as,

Boundary (A) = A - (A Ɵ B)

Hence, it would give a pixel difference.


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Boundary (A) = A - (A Ɵ B)
Boundary Extraction
Why is Boundary Extraction
Important?
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Boundary extraction plays a crucial role in numerous


applications, including:
•Image Segmentation: Dividing an image into
meaningful regions.
•Object Recognition: Identifying and classifying
objects within an image.
•Image Analysis: Extracting features and analyzing
image content.
•Computer Vision: Enabling machines to understand
and interpret visual information.
Boundary Extraction
Example
A simple image and the result of
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

performing boundary extraction


using a square 3*3 structuring
element

Original Image Extracted Boundary


Region Filling
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Given a pixel inside a boundary,


region filling attempts to fill that
boundary with object pixels (1s)

Given a point inside


here, can we fill the
whole circle?
Region Filling (cont…)
The key equation for region filling is
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

c
X k ( X k  1  B )  A 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
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Region Filling Step By Step


Region Filling Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original Image One Region All Regions


Filled Filled
Summary

The purpose of morphological processing is primarily to remove


imperfections added during segmentation
The basic operations are erosion and dilation
Using the basic operations we can perform opening and closing
More advanced morphological operation can then be
implemented using combinations of all of these

You might also like