0% found this document useful (0 votes)
34 views93 pages

Group 4

The document presents an overview of Morphological Image Processing, focusing on techniques that manipulate the shape and structure of objects within images using mathematical morphology. Key operations discussed include erosion, dilation, opening, closing, boundary extraction, and thinning, along with their applications in areas such as medical imaging and object recognition. The document also includes examples, definitions, and links to implementations for practical understanding.

Uploaded by

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

Group 4

The document presents an overview of Morphological Image Processing, focusing on techniques that manipulate the shape and structure of objects within images using mathematical morphology. Key operations discussed include erosion, dilation, opening, closing, boundary extraction, and thinning, along with their applications in areas such as medical imaging and object recognition. The document also includes examples, definitions, and links to implementations for practical understanding.

Uploaded by

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

Morphological Image

Processing
Group-04
Presented By -
1. Sourav Saha (19CSE029)
2. Priyanka Kundu (19CSE012)
3.Md. Moonaz
Rahman(19CSE023)
4.Md Masud Rana(19CSE045)
5.Faysal Mia(19CSE038)
Introduction

❏ A tool for extracting image components that are useful


in the representation and description of image.
❏ It deals with the shape (or morphology) of objects in
an image
❏ The language of mathematical morphology of an
image is Set Theory.
Representation of individual pixels as 0 or 1, convention:

Foreground, object = 1 (white)

Background = 0 (black)
Basic Set Theory

❖ The set space of binary image is Z2


❏ Each element of the set is a 2D vector whose coordinates
are the (x,y) of a black (or white, depending on the
convention) pixel in the image

❖ The set space of gray level image is Z3


❏ Each element of the set is a 3D vector: (x,y,z)
Basic Set Theory

❏ On the concepts of sets in Z2, where each element


denotes the coordinates of an object pixel.
❏ If a=(a1, a2), we write if a is an element in A.
❏ if a is not an element in A.
❏ The null or empty set is denoted by .
❏ We use braces, {·}, to specify the content of a set. For
example, C={w|w=-d, for }.
Basic Set Theory

Subset: if every element of A is also an element of another


set B, the A is said to be a subset of B.

Union: The set of all elements belonging either to A, B or both.

Intersection: The set of all elements belonging to both Aand


B
Basic Set Theory

Disjoint : Two sets A and B are said to be disjoint or mutually


exclusive if they have no common element.

Complement: The set of elements not contained in A

Difference : Difference of two sets A and B, denoted by A-B,


is defined as
Example Of some Logic Operations
Extra
Extra
Structuring Element
A small image/template that helps to produce new image from the old
one i.e. a small binary array.
Structuring Element
For simplicity we will use rectangular structuring elements with their
origin at the middle pixel
Structuring Element: Hits & Fits

Fit: All "1" pixels in the structuring


element cover "1" pixels in the image

Hit: Any "1" pixel in the structuring


element covers an "1" pixel in the image
Morphological operations

–Erosion: To shrink an object into a smaller size.

–Dilation: To enlarge an object along its boundary.


Erosion
Definition

Erosion of image f by structuring element s is given by f Ꮎ s

The structuring elements is positioned with its origin at (x, y)


and the new pixel value is determined using the rule:
Example Of 2D Erosion
Solution
Implementation

Co-lab Link:

https://colab.research.google.com/drive/1jngt_GsTr2Pd
kC3fnn73yhWLc0xXLtnk#scrollTo=KVpECbPWKSqo
Assignment-1
Dilation
Definition

Dilation of image f by structuring element s is given by f s

The structuring elements is positioned with its origin at (x, y)


and the new pixel value is determined using the rule:
Example Of 2D Dilation
Solution
Implementation

Co-lab Link:

https://colab.research.google.com/drive/1oOcCZtQlkiQ
O78d1BcxW07OyE8OqqrLu
Assignment-2
Opening and Closing

The combination of Opening and Closing is generally used to clean up artifacts in the
segmented image before using the image for digital analysis.
Opening

Opening is an operation that removes small objects from the foreground of an image (usually
considered as white pixels) while preserving the shape and size of larger objects. It is achieved by
applying erosion followed by dilation using a structuring element.

The morphological opening is an erosion followed by a dilation.

An example of the opening operation is shown in the diagram in next slide.


Opening
An Example for Better Understanding
Closing

Closing is an operation that fills small holes and gaps in the foreground of an image while
preserving the shape and size of objects. It is achieved by applying dilation followed by
erosion using a structuring element

Closing tends to close gaps in the image.

An example of the closing operation is shown in the diagram in next slide.


Closing
An Example for Better Understanding
Hit-or-Miss transformation
The hit-or-miss transform is a morphological operation that uses a structuring element to identify specific
configurations of pixels in a binary image. It is a combination of erosion operations that separately match
the foreground (object) and the background.

Let's see an example:

Structuring elements (kernels). Left: kernel to 'hit'. Middle: kernel to 'miss'. Right: final
combined kernel
An Example for Better Understanding
Assignment of Hit or Miss Transformation
Moonaz

BASIC MORPHOLOGICAL ALGORITHMS


BOUNDARY EXTRACTION

● Process of identifying the edges or outlines of objects within an


image.
● Highlight object contours for further analysis, such as shape
recognition or object segmentation
BOUNDARY EXTRACTION

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


B
(Structuring
element)

A
BOUNDARY EXTRACTION

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

A AƟB B (A) = A - (A Ɵ B).


BOUNDARY EXTRACTION

Applications:

● Object Detection and Recognition


● Image Segmentation
● Medical Image Analysis
● Robotics and Autonomous Systems
BOUNDARY EXTRACTION

Which of the following statements is true about boundary extraction?


A. It is used to smooth the edges of objects in an image.

B. It identifies the lines or curves where there is a significant change in intensity.

C. It enhances the brightness of the image.

D. It blurs the image to reduce noise


REGION FILLING | HOLE FILLING

● Process of filling the interior regions (holes) of binary objects in an


image.
● Enhance object representation, improve morphological operations,
and prepare for further image analysis.
REGION FILLING | HOLE FILLING
REGION FILLING | HOLE FILLING

● The algorithm terminates at iteration step k if Xk=Xk-1


● The result is obtained from the union of Xk and the boundary in A
REGION FILLING | HOLE FILLING
REGION FILLING | HOLE FILLING
REGION FILLING | HOLE FILLING

Applications:

● Image Preprocessing
● Object Recognition
● Texture Synthesis
● 3D Printing
REGION FILLING | HOLE FILLING

In the context of region filling, what does the term "seed point" refer to?
A. A point used to start the region filling process
B. A point used to end the region filling process
C. A point used to measure image intensity
D. A point used to smooth the image
EXTRACTION OF CONNECTED COMPONENT

● Connected component extraction involves identifying and labeling


connected regions (components) in a binary image.
● Separate distinct objects for analysis, counting, and measurement.
EXTRACTION OF CONNECTED COMPONENT
EXTRACTION OF CONNECTED COMPONENT
EXTRACTION OF CONNECTED COMPONENT

Applications:

● Object Counting
● Image Segmentation
● Character Recognition (OCR)
● Medical Image Analysis
● Shape Analysis
EXTRACTION OF CONNECTED COMPONENT

What is the primary goal of extracting connected components in image


processing?

● A. To enhance image contrast


● B. To detect edges and contours
● C. To identify and label distinct regions
● D. To reduce image noise
CONVEX HULL

● Convex hull is the smallest convex polygon that can contain all the
points of an object in an image.
● Simplify shape analysis, remove concavities, and provide a tight-fitting
boundary around objects.
CONVEX HULL

● Let a binary image A.


● Let Bi, i = 1,2,3,4 represent the four structuring elements in Fig. (a)
● Implementing the equation:
CONVEX HULL

Structuring elements
Convex Hull
CONVEX HULL
IMPROVING CONVEX HULL ALGORITHM

● The algorithm can be improved by limiting the growth of the


algorithm beyond the maximum dimensions of the original
set.
IMPROVING CONVEX HULL ALGORITHM

A Output
Improved
IMPROVING CONVEX HULL ALGORITHM

Applications:

● Computer Graphics: Simplifying shapes and collision detection.


● Pattern Recognition: Shape analysis and pattern matching.
● Robotics: Path planning and obstacle avoidance.
● Geometric: Basis for many computational geometry algorithms.
● Data Mining: Identifying the boundary of data points in
clustering.
● Computer Vision: Object detection and image segmentation.
CONVEX HULL

What is the convex hull of a set of points in a plane?

● A. The smallest circle that encloses all the points


● B. The largest circle that encloses all the points
● C. The smallest convex polygon that encloses all the points
● D. The largest convex polygon that encloses all the points
ASSIGNMENT

Extract the boundary from image A.


IMPLEMENTATIONS

LINK:

https://colab.research.google.com/drive/1WaeX59inH4426gwl9om2fXPH8Jy
VLimV?authuser=0#scrollTo=k6mUwSndIP5h
Thinning

1. Used to remove selected foreground pixels from binary images


2. After edge detection, lines are often thicker than one pixel.
3. Thinning can be used to thin those line to one pixel width.
Definition of Thinning

1.The thinning of a set A by a structuring element B:


=> A⊗B=A - (A⊛
B) = A ∩ (A⊛ B)c
2.Symmetric thinning: sequence of structuring elements
{B} = {B1, B2, B3‚...‚ ,Bn}, where B is a rotated version of B i-1
.If foreground and background fit the structuring element exactly,
then the pixel at the origin of the SE is set to 0
Symmetric Thinning
❖ sequence of structuring elements
{B} = {B1, B2, B3‚...‚ ,Bn}, where B is a rotated version of Bi-1.
Clockwise Rotated . Total Sequence=Number Of Neighbor.

0 0 0 1 0 0 0 1 0 1 0 1
B 1= 1 1 1 B 2= 0 1 0
B03= 1 0
0 1 0
B= 4
0 1 0 1 0 1 0 1 0 1 0 0

0 1 0 1 0 1 0 1 0 0 0 1

0 1
B5= 1 1 1
B 60= 0 1 1
B07= 1 0

0 0 0 B8= 0 0 1 0 1 0 1 0 1
Thinning Illustration

.
Applications of Thinning

1.Fingerprint Analysis: Enhances fingerprint features by reducing ridge


patterns to a skeletal form, making it easier to extract and match minutiae
points.

2.Medical Imaging: Extracts and analyzes the structure of biological tissues,


such as blood vessels or neural pathways, by reducing them to their skeletal
forms.

3.Shape Analysis: Helps in the recognition and classification of shapes by


reducing objects to a form that retains essential geometric properties.
Thickening

❖ Used to grow selected regions of foreground pixels


Definition Thickening

1.Thickening is the morphological dual of thinning and is defined by =>


A⊙B=A∪(A⊛ B)
where B is a structuring element Similar to thinning...
{B} = {B1, B2, B3‚...‚ ,Bn}, where
B is a rotated version of Bi-1
2. If foreground and background match exactly the SE, then set the pixel at
its origin to 1!
Thickening Process

.
Applications of Thickening

1. Text Enhancement: Improves the visibility of characters in degraded


or low-resolution images by thickening the strokes.
● Example: Enhancing text in scanned historical documents for better
readability.

2. Medical Imaging: Enhances the visibility of certain structures,


such as bones or tumors, making them more prominent for diagnosis.

● Example: Thickening the edges of bone structures in X-ray images


for fracture detection.
Assignments

Perform Thinning and Thickening process.


0 0 0
Structure elements B1=x 1 x

1 1 1
1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 0 0

1 1 1 1 1 1 1 1 1 0 0

1 Image
Original 1 1, A 1 = 1 1 1 1 1 0 0

1 1 1 0 0 1 1 1 1 0 0
Code

Implementation Code
Here:https://github.com/Schukuratsu/Python-cv2-fast-
thinning-algorithm
Morphological Reconstruction

● Extract and reconstruct specific features or structures from an image based


on morphological operations
● Focuses on selectively highlighting certain parts of an image while
suppressing others

Required Elements for Morphological Reconstruction:

● Marker Image: An initial image or subset that serves as the seed for reconstruction.
It can be created based on specific criteria or thresholds applied to the original
image.
● Mask Image: The original image or a processed version of the original image that
guides and constrains the reconstruction process.
● Structuring Element: The neighborhood used for dilation or erosion. Common
structuring elements include simple shapes like squares, disks, or more complex
configurations.
[Extracts the
particles
connected
to a
rectangle
boundary]

[Extracts the
particles
based on
morphologic
al
properties]
Geodesic Dilation

The geodesic dilation is an iterative morphological transformation requiring:

F = Marker image

G = Mask image

B = Structuring element

n = Number of time of
geodesic dilation
Geodesic Dilation graphical illustration
Geodesic Erosion

The geodesic erosion is an iterative morphological transformation which is restricted by


mask image

: Geodesic erosion of size n of F with respect to G


Geodesic Erosion graphical illustration
Quiz

In which scenario would geodesic erosion be particularly useful in image processing

A) To sharpen the edges of objects in a grayscale image.

B) To iteratively erode an image until all the pixels are removed.

C) To control the erosion process using a reference image, ensuring that erosion does not go
beyond certain boundaries.

D) To perform edge detection by computing the gradient of the image intensity.


Morphological reconstruction by Dilation & Erosion

The reconstruction through the geodesic operations are defined as the result of such
operation at the stability:

Morphological reconstruction by dilation:

with k such

Morphological reconstruction by erosion:

with k such
How morphological reconstruction by dilation works
Sample application of morphological reconstruction

Opening by reconstruction:
Opening Through Reconstruction Of Size n:

● Erosion for eliminating the details (n times)


● Reconstruction through the geodesic dilation
Opening by reconstruction
from skimage import morphology as morph

# Load image & process

im = load_spots()

bw_low = im > im.mean() + im.std()

bw_high = im > im.mean() + 3 * im.std()

bw_hist = morph.reconstruction(bw_high, bw_low)

# Show original concatenated with the filtered images

fig = create_figure(figsize=(8, 8))

show_image(im, clip_percentile=0.5, title="(A) Grayscale image", pos=221)

show_image(bw_low, title="(B) Mask image (low threshold)", pos=222)

show_image(bw_high, title=f"(C) Marker image (high threshold)", pos=223)

show_image(bw_hist, title=f"(D) Reconstruction result (hysteresis threshold)", pos=224)

plt.tight_layout()

glue_fig('fig_hysteresis_threshold_spots', fig)
Filling holes
Filling holes

(a)Text image
(b)Compliment
of (a) for use as
a mask image
(c)Marker
image (d)
Result of hole
filling
THANK YOU

You might also like