0% found this document useful (0 votes)
17 views

Morphological Image Processing

Uploaded by

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

Morphological Image Processing

Uploaded by

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

Morphological

Image Processing

Dr. Navjot Singh


Image and Video Processing
Acknowledgements
⚫ Gonzalez, Rafael C. Digital image processing. Pearson, 4th
edition, 2018.
⚫ Jain, Anil K. Fundamentals of digital image processing. Prentice-
Hall, Inc., 1989.
⚫ Digital Image Processing course by Brian Mac Namee, Dublin
Institute of Technology
⚫ Digital Image Processing course by Christophoros Nikou,
University of Ioannina

2
Introduction
⚫ Morphology: a branch of biology that deals with the form and
structure of animals and plants
⚫ It is used to extract image components that are useful in the
representation and description of region shape, such as
⚫ boundaries extraction
⚫ skeletons
⚫ convex hull
⚫ morphological filtering
⚫ thinning
⚫ pruning

3
Basic Set Theory

4
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Reflection and Translation

Bˆ = {w | w  −b, for b  B}
( A) z = {c | c  a + z, for a  A}

5
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Example

6
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Structuring element (SE)

▪ small set to probe the image under study


▪ for each SE, define origin
▪ shape and size must be adapted to geometric properties for the
objects

7
Examples: Structuring Elements (1)

origin

8
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Examples: Structuring Elements (contd.)
Accommodate the
entire structuring
elements when its Origin of B visits
origin is on the every element of A
border of the
original set A
At each location of
the origin of B, if B
is completely
contained in A,
then the location is
a member of the
new set, otherwise
it is not a member
of the new set.

9
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Erosion
⚫ Does the structuring element fit the set?
⚫ Erosion of a set A by structuring element B: all z in A such that B is in A
when origin of B is z
⚫ Portion of A where B is contained in A

A − B = {z|(B)z  A}
A − B = {z|(B) z  A = } C

shrink the object


10
Example
0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0
0 1 1 0 0 1 1 0
0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0 What is ?
0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0

Original Image A

1 1 1
1 1 1
1 1 1
11
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Output

1 1 1
1 1 1
1 1 1
12
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Output

1 1 1
1 1 1
1 1 1
13
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Output

1 1 1
1 1 1
1 1 1
14
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0
0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Output

1 1 1
1 1 1
1 1 1
15
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Output

1 1 1
1 1 1
1 1 1
16
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Final Output

1 1 1 0 1 0
1 1 1 1 1 1
1 1 1 0 1 0
17
Structuring Element B Try with this SE
Example of
Erosion

18
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Example of
Erosion (contd.)

19
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Dilation

⚫ Does the structuring element hit the set?


⚫ dilation of a set A by structuring element B: all z in A such that
B hits A when origin of B=z

A  B = {z|( Bˆ )z  A  Φ}
⚫ grow the object

20
Example
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 1 1 1 1 0 0
0 0 1 0 0 1 0 0
0 0 1 1 1 1 0 0
ˆ )  A  Φ}
What is A  B ?= {z|( B
0 0 1 1 1 1 0 0 z

0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

Original Image A

1 1 1
1 1 1
1 1 1
21
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Output

1 1 1
1 1 1
1 1 1
22
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Output

1 1 1
1 1 1
1 1 1
23
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Output

1 1 1 Guess the final output


1 1 1
1 1 1
24
Structuring Element B
Example (contd.)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0
0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 0
0 0 1 0 0 1 0 0 0 1 1 1 1 1 1 0
0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 0
0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Original Image A Final Output

1 1 1 0 1 0
1 1 1 1 1 1
1 1 1 0 1 0
25
Structuring Element B Try with this SE
Examples of Dilation

26
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Examples of Dilation (contd.)

27
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Erosion : eliminating irrelevant detail

structuring element B = 13x13 pixels of gray level 1


28
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Advantages
⚫ Erosion
⚫ removal of structures of certain shape and size, given by SE
⚫ Dilation
⚫ filling of holes of certain shape and size, given by SE

29
Combining erosion and dilation
⚫ WANTED:
⚫ remove structures / fill holes
⚫ without affecting remaining parts

⚫ SOLUTION:
⚫ combine erosion and dilation
⚫ (using same SE)

30
Duality
⚫ Erosion and dilation are duals of each other with respect to
set complementation and reflection.

and

31
Duality (contd.)
⚫ Starting with the definition of erosion, it follows that

⚫ If set (B)z is contained in A, then it follows that , in which case


the preceding expression becomes

⚫ But the complement of the set of z’s that satisfy is the set of z’s
such that . Therefore,

32
Opening
Erosion followed by dilation, denoted ∘

A  B = ( A − B)  B
⚫ eliminates protrusions (a thing that sticks out from a place or
surface)
⚫ breaks necks
⚫ smoothes contour

33
Image adapted from https://www.americansouthwest.net/utah/goblin_valley/goblins5_l.html
Opening

A  B = ( A − B)  B
A  B = {( B) z | ( B) z  A} 34
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Closing
Dilation followed by erosion, denoted •

A • B = ( A  B) − B
⚫ smooth contour
⚫ fuse narrow breaks and long thin gulfs
⚫ eliminate small holes
⚫ fill gaps in the contour

35
Closing
A • B = ( A  B) − B

36
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
37
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Properties
Opening
(i) AB is a subset (subimage) of A
(ii) If C is a subset of D, then C  B is a subset of D  B
(iii) (A B)  B = A  B
Closing
(i) A is a subset (subimage) of A • B
(ii) If C is a subset of D, then C • B is a subset of D • B
(iii) (A • B) • B = A • B

Note: repeated openings/closings has no effect!


38
39
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Duality
⚫ As with erosion and dilation, opening and closing are duals of
each other with respect to set complementation and
reflection.

and

40
Hit-or-Miss Transformation ⊛ (HMT)

⚫ find location of one shape among a set of shapes “template


matching”

⚫ composite SE: object part (B1) and background part (B2)


⚫ does B1 fits the object while, simultaneously, B2 misses
the object, i.e., fits the background?
41
The Hit-or-Miss
Transformation
if B denotes the set composed of
D and its background,the match
(or set of matches) of B in A,
denoted A  B,
A * B = ( A − D )   Ac − (W − D ) 

B = ( B1 , B2 )
B1 : object
B2 : background
A  B = ( A − B1 )  ( Ac − B2 )
42

Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Boundary Extraction

43
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Boundary Extraction

 ( A) = A − ( A − B) 44
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Region Filling/Hole Filling
A hole may be defined as a background region surrounded by a connected border
of foreground pixels.

45
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Region Filling/Hole Filling (contd.)
⚫ Let A denote a set whose elements are 8-connected boundaries, each
boundary enclosing a background region (i.e., a hole). Given a point in each
hole, the objective is to fill all the holes with 1s.
⚫ Algorithm
1. Forming an array X0 of 0s (the same size as the array containing A),
except the locations in X0 corresponding to the given point in each hole, which
we set to 1.
2. X k = ( X k −1  B)  A k = 1,2,3,...
c

3. Stop the iteration if Xk = Xk-1

46
Region Filling/Hole Filling (contd.)
X k = ( X k −1  B)  A k = 1,2,3,...
c

47
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Extraction of connected components

48
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Extraction of connected components
(contd.)
Let A be a set containing one or more connected components, and
form an array X0 (of the same size as the array containing A) whose
elements are 0s, except at each location known to correspond to a
point in each connected component in A, which is set to 1.

X k = ( X k −1 + B )  A
B : structuring element

until X k = X k -1 49
Extraction of connected components
(contd.)

X k = ( X k −1 + B )  A 50
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Convex Hull

• A set A is said to be convex if the straight line segment joining any


two points in A lies entirely within A.

• The convex hull H of an arbitrary set S is the smallest convex set


containing S.

51
Convex Hull (contd.)
Let B i , i = 1, 2, 3, 4, represent the four structuring elements.
The procedure consists of implementing the equation:
X ki = ( X k −1 * B i )  A
i = 1, 2,3, 4 and k = 1, 2,3,...
with X 0i = A.
When the procedure converges, or X ki = X ki −1 , let D i = X ki ,
the convex hull of A is
4
C ( A) =  D i
i =1

52
53

Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Thinning
• Thinning of a set A of foreground pixels by a structuring element B,
denoted , can be defined in terms of the hit-or-miss transform.

• A more useful expression for thinning A symmetrically is based on a


sequence of structuring elements

• Using this concept, we now define thinning by a sequence of


structuring elements as
54
Thickening
• Thickening is the morphological dual of thinning and is defined by
the expression

where B is a structuring element suitable for thickening.


• As in thinning, thickening can be defined as a sequential operation

55
56

Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
57

Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Skeletons
• Skeleton S(A):
• If z is a point of S(A), and (D)z is the largest disk centered at z
and contained in A, one cannot find a larger disk (not necessarily
centered at z) containing (D)z and simultaneously included in A. A
disk (D)z satisfying these conditions is called a maximum disk.
• If (D)z is a maximum disk, it touches the boundary of A at two or
more different places.

58
Skeletons
(contd.)

59
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Skeletons (contd.)
• The skeleton of A can be expressed in terms of erosions and
openings.

• with

• where B is a structuring element, and indicates k successive


erosions starting with A; that is, A is first eroded by B, the result is
eroded by B, and so on k times.
60
Skeletons (contd.)
• K is the last iterative step before A erodes to an empty set.

• S(A) can be obtained as the union of the skeleton subsets Sk(A),


k = 0, 1, 2,…, K.
• It can be shown that A can be reconstructed from these subsets.

• where denotes k successive dilations, starting with


Sk(A); that is,
61
62

Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Pruning
• Pruning methods are an essential complement to thinning and
skeletonizing algorithms.
• These procedures tend to leave spurs (“parasitic” components)
that need to be “cleaned up” by postprocessing.
• A common approach in the automated recognition of hand-printed
characters is to analyze the shape of the skeleton of a character.
These skeletons often contain spurs, caused during erosion by
noise and non-uniformities in the character strokes.
• A morphological technique for handling this problem can be seen,
starting with the assumption that the length of a parasitic
component does not exceed a specified number of pixels. 63
Pruning (contd.)
• Figure shows the skeleton of a hand-printed letter “a.”
• The spur on the leftmost part of the character exemplifies what we
are interested in removing.
• The solution is based on suppressing a spur branch by
successively eliminating its end point.
• Of course, this also shortens (or eliminates)
other branches in the character but, in the
absence of other structural information, the
assumption in this example is that any branch
with three or less pixels is to be eliminated.
64
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
Pruning (contd.)
• Thinning of a set A, with a sequence of structuring elements
designed to detect only end points, achieves the desired result.
That is, let

• where {B} denotes the structuring element sequence and H is


3×3 structuring element of 1’s.

65
Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
66

Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.
67

Adapted from Gonzalez, Rafael C. Digital image processing. Pearson education India, 2009.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy