You are on page 1of 197

DIGITAL IMAGE PROCESSING - 2

Lecture 13: Morphological


Image Processing
Dr. Shruthi M.L.J.
Department of Electronics &
Communication Engineering

1
DIGITAL IMAGE PROCESSING - 2

Unit 2: Morphological Image Processing

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Binary Morphological Operations

• Dilation
• Erosion
• Opening
• Closing
• Hit-or-Miss transform

5
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion

Two fundamental morphological operations:

• Dilation

• Erosion

• Many of the morphological algorithms are based on these two


primitive operations.

6
of morphological filters in Sections 9.4 and 9.8.
DIGITAL IMAGE PROCESSING - 2
Dilation
2
s sets in Z
• With A, the
and dilation
B as setsofinAZ2by B, denoted
, Dilation as A {byBstructuring
of a set , is defined as
element B:
{
A { B = z P( Bˆ ) z ¨ A ¹ Æ } (9-6)

• Reflection of B about origin and shifting this reflection by z


• Dilation of A by B is set of all displacements, z, such
that B̂ and A overlap by at least one element

• Grow the object (Does the structuring element hit the set?)

7
DIGITAL IMAGE PROCESSING - 2
Dilation

• When an image X is dilated by structuring element B, the


outcome image z would be such that there will be at least one
element in B that intersects with an element in X

• If this is the case, the position where structuring element is


being centered on the image will be set to ‘1’(black).

8
DIGITAL IMAGE PROCESSING - 2
Example of Dilation

• Consider Image I, composed of set (object) A and background


and square SE B (the dot is the origin)

• Perform the dilation operation using

• Dilation of A by B is

9
DIGITAL IMAGE PROCESSING - 2
Example of Dilation

• Consider Image I, composed of set (object) A and background


and square SE B (the dot is the origin)

• Perform the dilation operation using

• Dilation of A by B is

10
DIGITAL IMAGE PROCESSING - 2
Example of Dilation : Bridging Gaps

• Consider a low-resolution text showing broken characters


(see magnified view) ‘A’ . The maximum length of the breaks
is known to be two pixels
• And the Structuring element ‘B’
• Use white (1) to denote the foreground and black (0) for the
background
• Dilation of ‘A’ by ‘B’

• Broken segments were joined

11
DIGITAL IMAGE PROCESSING - 2
Example of Dilation : Bridging Gaps

• The same could have been done using filtering


• One important advantage of the morphological
approach over the lowpass filtering method used to
bridge the gaps is that the morphological method
resulted directly in a binary image
• Lowpass filtering, on the other hand, starts with a
binary image and produces a grayscale image that
would require thresholding to convert it back to
binary form

12
DIGITAL IMAGE PROCESSING - 2

Morphological Image Processing: Erosion

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Binary Morphological Operations

✓Dilation
• Erosion
• Opening
• Closing
• Hit-or-Miss transform

5
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion

Two fundamental morphological operations:

• Dilation

• Erosion

• Many of the morphological algorithms are based on these two


primitive operations.

6
DIGITAL IMAGE PROCESSING - 2
Erosion

• With A and B as sets in Z 2 , the erosion of A by B, denoted as ,


is defined as

where A is a set of foreground pixels, B is a structuring element,


and the z’s are foreground values (1’s)
• The erosion of A by structuring element B is the set of all
points z such that B, translated by z, is contained in A

• Does the structuring element fit the set?

• Shrink the object


7
DIGITAL IMAGE PROCESSING - 2
Erosion

• We work with sets of foreground pixels embedded in a set of


background pixels to form a complete image, I.
• Thus, inputs and outputs of morphological procedures are
images, not individual sets
• Hence the erosion equation can also be written as

• We use the notation when a morphological operation


uses only foreground elements, and
when the operation uses foreground and background
elements.

8
DIGITAL IMAGE PROCESSING - 2
Erosion

• It is counter process of dilation


• Shrinking is determined by the structuring element
• Normally smaller than the image (3x3) to ensure faster
computation time
• Structuring element moves from left to right and top to bottom
• At centre position indicated by centre of the structuring
element, the process will look for complete overlap with image
• If not the centre pixel indicated by centre of structuring
element will be set to ‘0’(white)

9
DIGITAL IMAGE PROCESSING - 2
Examples of Erosion

• Consider an Image I, consisting of a set (object) A, and


background.
• Consider square SE, B (the dot is the origin).
• Erosion of A by B

shaded region in the resulting image

10
DIGITAL IMAGE PROCESSING - 2
Examples of Erosion

• Consider an Image I, consisting of a set (object) A, and


background.
• Consider elongated SE, B (the dot is the origin).
• Erosion of A by B

shaded region in the resulting image


11
DIGITAL IMAGE PROCESSING - 2
Examples of Erosion

• Using erosion remove image components.


• Consider a 486 × 486 binary image of a wire-bond mask in
which foreground pixels are shown in white.
• Erode the Image using square structuring elements of sizes
11×11, 15×15, and 45 × 45 elements, respectively, all valued
1(white).

• Increasing the size of the structuring element eliminates larger


components.
12
DIGITAL IMAGE PROCESSING - 2
Erosion Cont..

• Erosion shrinks or thins objects in a binary image.

• Erosion can be viewed as a morphological filtering operation


in which image details smaller than the structuring element
are filtered (removed) from the image.

13
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion

• Dilation and Erosion are dual of each other w.r.t. set


complementation and reflection

and

• Erosion of A by B is the complement of the dilation of


Ac by and vice versa.

14
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion

• The duality property is useful when the structuring element


values are symmetric with respect to its origin so that B =
• Then, we can obtain the erosion of A simply by dilating its
background (i.e., dilating Ac ) with the same structuring
element and complementing the result

15
DIGITAL IMAGE PROCESSING - 2
Application

• Dilation
• Filling of holes of certain shape and size, given by SE

• Erosion
• Removal of structures of certain shape and size, given by SE

16
DIGITAL IMAGE PROCESSING - 2
Example 1

• Eliminate irrelevant detail from binary image


• Consider binary image with squares of sizes 1,3,5,7,9 and 15
pixels

• We want to eliminate all squares except largest ones

17
DIGITAL IMAGE PROCESSING - 2
Example 1

• Can be done by eroding the image with a structuring element


of size somewhat smaller than the object we wish to keep.
• Lets choose SE of size 13 x 13
• Result of eroding is (only portion of largest square remains)

18
DIGITAL IMAGE PROCESSING - 2
Example 1

• The squares are shrunk


• We can restore to original size 15 x 15 by dilating them with
same structuring element used for erosion

19
DIGITAL IMAGE PROCESSING - 2
Process

structuring element B = 13x13 pixels of gray level 1(white)

20
DIGITAL IMAGE PROCESSING - 2
Example 2

• Using input image and structuring element as given below find


the dilated version of the input image

 Initially structuring element is aligned


with centre at *

21
DIGITAL IMAGE PROCESSING - 2

Morphological Image Processing:


Dilation and Erosion

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion

• Dilation and Erosion are dual of each other w.r.t. set


complementation and reflection

and

• Erosion of A by B is the complement of the dilation of


Ac by and vice versa.

5
DIGITAL IMAGE PROCESSING - 2
Dilation and Erosion

• The duality property is useful when the structuring element


values are symmetric with respect to its origin so that B =

• Then, we can obtain the erosion of A simply by dilating its


background (i.e., dilating Ac ) with the same structuring
element and complementing the result

6
DIGITAL IMAGE PROCESSING - 2
Application

• Dilation
• Filling of holes of certain shape and size, given by SE

• Erosion
• Removal of structures of certain shape and size, given by SE

7
DIGITAL IMAGE PROCESSING - 2
Example 2

• Using input image and structuring element as given below find


the dilated version of the input image

 Initially structuring element is aligned


with centre at *

8
DIGITAL IMAGE PROCESSING - 2
Example 2

• The dilated image is

9
DIGITAL IMAGE PROCESSING - 2
Example 1

• Using input image and structuring element as given below find


the dilated version of the input image

Reflected SE
10
DIGITAL IMAGE PROCESSING - 2
Example 1

• Step 1:First Row operation

• Step 2: Translate SE to right by one pixel and repeat

11
DIGITAL IMAGE PROCESSING - 2
Example 1

• Step 3:Translate SE to right by one pixel and repeat

• Step 4:Translate SE to right by one pixel and repeat

12
DIGITAL IMAGE PROCESSING - 2
Example 1

• Step 5: Resultant Image

Shift structuring element from top to bottom


and move from left to right again
• Step 6: Dilated Image

13
DIGITAL IMAGE PROCESSING - 2
Example 3
• Using input image and structuring element as given below find
the eroded version of the input image

14
DIGITAL IMAGE PROCESSING - 2
Example 3

• Step 1: First Row operation

• Step 2: Second Row operation

15
DIGITAL IMAGE PROCESSING - 2
Example 3

• Last Step: Last Row operation

Eroded Image

16
DIGITAL IMAGE PROCESSING - 2
Example 4

• Using input image and structuring element as given below find


the eroded version of the input image

17
DIGITAL IMAGE PROCESSING - 2
Combining Erosion and Dilation

• Requirement:
• Remove structures / fill holes without affecting remaining
parts
• Solution:
• Combine erosion and dilation (using same SE)
• Results in two operations:
• Opening
• Closing

18
DIGITAL IMAGE PROCESSING - 2
Opening

• Erosion followed by dilation, denoted by

• Eliminates protrusions
• Breaks necks
• Smoothes contour
• The opening of A by B is the union of all the
translations of B so that B fits entirely in A.

19
DIGITAL IMAGE PROCESSING - 2
Opening

• Consider an image containing a set (object) A and


background
• and a solid, circular structuring element, B.
• Some of the translations of B such that it is contained
within A is as below:

• And the union of all such possible translations is set


shown shaded

20
DIGITAL IMAGE PROCESSING - 2

Opening and Closing Operations

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Combining Erosion and Dilation

• Requirement:
• Remove structures / fill holes without affecting remaining
parts
• Solution:
• Combine erosion and dilation (using same SE)
• Results in two operations:
• Opening
• Closing

5
DIGITAL IMAGE PROCESSING - 2
Opening

• Erosion followed by dilation, denoted by

• Eliminates protrusions
• Breaks necks
• Smoothes contour

6
DIGITAL IMAGE PROCESSING - 2
Opening

• Consider an image containing a set (object) A and


background
• And a solid, circular structuring element, B.
• Some of the translations of B such that it is contained
within A (Opening) is as below:

7
DIGITAL IMAGE PROCESSING - 2
Opening
• Observe that, in this case, the opening is a set composed of
two disjoint subsets, resulting from the fact that B could
not fit in the narrow segment in the center of A.
• So the opening of A by B is also given by the union of all the
translations of B so that B fits entirely in A.
• The ability to eliminate regions narrower than the
structuring element is one of the key features of
morphological opening
• The interpretation that the opening of A by B is the union
of all the translations of B such that B fits entirely within A
can be written in equation form as

8
Where ́ denotes the union of the sets inside the braces.
DIGITAL IMAGE PROCESSING - 2
Opening

9
DIGITAL IMAGE PROCESSING - 2
Opening

10
DIGITAL IMAGE PROCESSING - 2
Closing

• Dilation followed by erosion, denoted by

• Smoothes contour
• Fuse narrow breaks and long thin gulfs
• Eliminate small holes
• Fill gaps in the contour

11
DIGITAL IMAGE PROCESSING - 2
Closing

• Closing has a similar geometric interpretation an opening,


except that now we translate B outside A.
• The closing is then the complement of the union of all
translations of B that do not overlap A.

12
DIGITAL IMAGE PROCESSING - 2
Closing

13
DIGITAL IMAGE PROCESSING - 2
Closing

• Note that the boundary of the closing is determined by the


furthest points B could reach without going inside any part of
A.
• Based on this interpretation, we can write the closing of A by B
as

14
DIGITAL IMAGE PROCESSING - 2
Example 2

• Consider an image containing a single object (set) A, and a disk


structuring element

• Various positions of the structuring element during erosion

15
DIGITAL IMAGE PROCESSING - 2
Example 2

• This process resulted in the disjoint set

• The bridge between the two main sections was eliminated


• Its width was thin in relation to the diameter of the structuring
element, which could not be completely contained in this part
of the set, thus violating the definition of erosion
• The same was true of the two rightmost members of the
object. Protruding elements where the disk did not fit were
eliminated. 16
DIGITAL IMAGE PROCESSING - 2
Example 2

Opening
Morphological opening removes
regions that cannot contain the
structuring element, smoothens
object contours, breaks thin
connections, and removes thin
protrusions.

17
The final result of opening
DIGITAL IMAGE PROCESSING - 2
Example

Closing
• As with opening, closing also
smoothens the contours of objects.
• However, unlike opening, closing
tends to join narrow breaks, fills
long thin gulfs, and fills objects
smaller than the structuring
element.
• In this example, the principal result
of closing was that it filled the
small gulf on the left of set A.

18
DIGITAL IMAGE PROCESSING - 2
Use of Open and Close

19
DIGITAL IMAGE PROCESSING - 2
Properties

• Opening
1. A°B is a subset (subimage) of A
2. If C is a subset of D, then C °B is a subset of D °B
3. (A °B) °B = A °B
• Closing
1. A is a subset (subimage) of A•B
2. If C is a subset of D, then C •B is a subset of D •B
3. (A •B) •B = A •B

• Note: repeated openings/closings has no effect!

20
DIGITAL IMAGE PROCESSING - 2
Duality

• Dilation and Erosion are dual with respect to


set complementation and reflection • Then, we can obtain the erosion of A simply
by dilating its background (i.e., dilating Ac )
with the same structuring element and
complementing the result

• Opening and closing are also dual with respect


to set complementation and reflection

21
DIGITAL IMAGE PROCESSING - 2
Binary Morphological Operations

✓Dilation: Grow the object


:Does SE hit the set?
✓Erosion: Shrink the object
✓ : :Does SE fit the set?
✓Opening: Breaks necks

✓Closing: Fill gaps/Fuse narrow breaks

• Hit-or-Miss transform

22
DIGITAL IMAGE PROCESSING - 2
Hit or Miss Transformation ⊛ (HMT)

• Basic tool for shape detection


• Find location of one shape among a set of shapes “template
matching”

• Utilizes two Structuring Elements:


• B1: for detecting object part/ shapes in foreground and

• B2 : for detecting shapes in background

• Does B1 fit the object while, simultaneously, B2 misses the


object, i.e., fits the background? 23
DIGITAL IMAGE PROCESSING - 2

Hit or Miss Transformations (HMT)

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Binary Morphological Operations

✓Dilation: Grow the object


:Does SE hit the set?
✓Erosion: Shrink the object
✓ : :Does SE fit the set?
✓Opening: Breaks necks

✓Closing: Fill gaps/Fuse narrow breaks

• Hit-or-Miss transform

4
DIGITAL IMAGE PROCESSING - 2
Hit or Miss Transformation ⊛ (HMT)

• Basic tool for shape detection


• Find location of one shape among a set of shapes “template
matching”

• Utilizes two Structuring Elements:


• B1: for detecting object part/ shapes in foreground and

• B2 : for detecting shapes in background

• Does B1 fit the object while, simultaneously, B2 misses the


object, i.e., fits the background? 5
DIGITAL IMAGE PROCESSING - 2
HMT Cont…

• Let I be a binary image composed of foreground (A) and


background pixels, respectively
• The HMT of image I is defined as

; (Follows from definition of erosion)

• The morphological HMT is the set of translations, z, of


structuring elements B1 and B2 such that, simultaneously, B1
found a match in the foreground (i.e., B1 is contained in A) and
B2 found a match in the background (i.e., B2 is contained in Ac )

6
DIGITAL IMAGE PROCESSING - 2
HMT Cont…

• The word “simultaneous” implies that z is the same translation of


both structuring elements.

• The word “miss” in the HMT arises from the fact that B2 finding a
match in Ac is the same as B2 not finding (missing) a match in A.

7
DIGITAL IMAGE PROCESSING - 2
Example 1

• Find the hit or miss transformation(HMT) of the input image


whose Structuring Elements B1 and B2 are as given below

8
DIGITAL IMAGE PROCESSING - 2
Example 1

• Step 1: Find erosion of input image with B1

• Find erosion of complement of input image with B2

9
DIGITAL IMAGE PROCESSING - 2
Example 1

• Step 3: Find intersection of results of steps 1 and 2

10
DIGITAL IMAGE PROCESSING - 2
HMT

• If we use foreground and background pixels in one SE we


need not use 2 SEs.
• Then HMT is then defined as

• Similar to erosion definition with difference that we now


check if the (B)z is subset of image I, which is composed
of both foreground and background pixels
• This formulation is general and B can be structured to
detect any arrangement of pixels in image I

11
DIGITAL IMAGE PROCESSING - 2
Example 2

Examples of using a single structuring element


using following equation to detect specific
features

• Ex 2.1 : detection B of single-pixel holes

12
DIGITAL IMAGE PROCESSING - 2
Example 2

Ex 2.2 : detection of an upper-right corner

Ex 2.3 : detection of multiple features

13
DIGITAL IMAGE PROCESSING - 2
Example 2

• The example 2.3 has structuring element composed of foreground,


background, and “don’t care” elements denoted by ×’s
• The value of a don’t care elements can be thought of as always matching
its corresponding pixel in an image.
• In this example, when the SE is centered on the top, right corner pixel, the
don’t care elements in the top of the SE can be considered to be
background, and the don’t care elements on the bottom row as
foreground, producing a correct match
• When the SE is centered on the bottom, right corner pixel, the role of the
don’t care elements is reversed, again resulting in a correct match.
• The other border pixels between the two corners were similarly detected
by considering all don’t care elements as foreground.
• Thus, using don’t care elements increases the flexibility of structuring
elements to perform multiple roles. 14
DIGITAL IMAGE PROCESSING - 2
Example 3

• Find the location of the origin of object (set) D in image I.

Image consisting of a foreground


(1’s) equal to the union, A, of set of
objects, and a background of 0’s.

• Here, A is the union of all object sets, so D is a subset of A.


15
DIGITAL IMAGE PROCESSING - 2
Example 3

• All three objects are composed of foreground pixels


• One way of explaining why they appear as different shapes is
because each occupies a different area of the background.
• In other words, the nature of a shape is determined by the
geometrical arrangement of both foreground and background
pixels.

Image with
its foreground defined as Ac . Structuring elements designed to detect object D. 16
Element B1 is equal to D itself
DIGITAL IMAGE PROCESSING - 2
Next Session

• HMT Cont…
• Morphological Algorithms

17
THANK YOU

Dr. Shruthi M.L.J.


Department of Electronics &
Communication Engineering

shruthimlj@pes.edu
+91 9482219115

18
DIGITAL IMAGE PROCESSING – 2

Lecture 18: Morphological


Image Processing
Dr. Shruthi M.L.J.
Department of Electronics &
Communication Engineering

1
DIGITAL IMAGE PROCESSING - 2

Morphological Algorithms

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Last Session

• Hit or Miss Transform

3
DIGITAL IMAGE PROCESSING - 2
This Session

• Hit or Miss Transform Cont..


• Morphological Algorithms

4
DIGITAL IMAGE PROCESSING - 2
HMT Cont…

• Let I be a binary image composed of foreground (A) and


background pixels, respectively
• The HMT of image I is defined as

; (Follows from definition of erosion)

• The morphological HMT is the set of translations, z, of


structuring elements B1 and B2 such that, simultaneously, B1
found a match in the foreground (i.e., B1 is contained in A) and
B2 found a match in the background (i.e., B2 is contained in Ac )

5
DIGITAL IMAGE PROCESSING - 2
Example 3

• Find the location of the origin of object (set) D in image I.

Image consisting of a foreground


(1’s) equal to the union, A, of set of
objects, and a background of 0’s.

• Here, A is the union of all object sets, so D is a subset of A.


6
DIGITAL IMAGE PROCESSING - 2
Example 3

• All three objects are composed of foreground pixels

Image I with A as foreground Image with its foreground defined as Ac


7
DIGITAL IMAGE PROCESSING - 2
Example 3

• We need two structuring elements


• Structuring element B1 is equal to D itself

• Structuring element B2 is designed to detect D in Ic .


• Because D is composed of background elements in Ic, and
erosion works with foreground elements, B2 has to be
designed to detect the border of D, which is composed of
foreground pixels in Ic
• It consists of a rectangle of foreground elements one pixel
thick. The size of the rectangle is such that it encloses the size
of D

8
DIGITAL IMAGE PROCESSING - 2
Example 3

Structuring elements designed


Image with its foreground
to detect object D.
defined as Ac . Image with its foreground defined as Ac

Erosion of A by B1 contains a single


point: the origin of D, as desired, but
it also contains parts of object C

9
Erosion of A by B1.
DIGITAL IMAGE PROCESSING - 2
Example 3

*Erosion works with foreground elements

Structuring element
designed to detect object D
Image with its foreground defined as Ac

• The erosion of the foreground of Ic by


B2 is the shaded region .
• It contains the origin of D, but is also
contains parts of sets Ac and C

Erosion of Ac by B2 10
DIGITAL IMAGE PROCESSING - 2
Example 3

Image with its foreground Structuring elements designed


to detect object D. Image with its foreground defined as Ac
defined as A

Shows the location of the origin


of D, as desired.

Erosion of Ac by B2 11
Erosion of A by B1. Intersection of the 2 erosions
DIGITAL IMAGE PROCESSING - 2
Using single SE

• Why not try to detect D directly in image I using a single


structuring element, instead of going thorough such a
laborious process
• In order to detect D directly in image I, we should be able to
process foreground and background pixels simultaneously,
rather than processing just foreground pixels, as required by
the definition of erosion.
• We achieve this by defining a structuring element, B, identical
to D, but having in addition a border of background elements
with a width of one pixel.

12
DIGITAL IMAGE PROCESSING - 2
Using single SE
• We can use the structuring element formed in such a way to
restate the HMT as

• Here we test to see if (B)z is a subset of image I, which is


composed of both foreground and background pixels. Image with its foreground
• For example 3, Design a single structuring element to detect defined as A
D(border of D)

13
DIGITAL IMAGE PROCESSING - 2
Example 3 (using single SE)

• So using a single SE

14
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• After basic morphological operations, we are now ready to


consider some practical uses of morphology.
• One of the principal applications of morphology (dealing with
binary images) is in extracting image components that are useful in
the representation and description of shape
• In particular, we consider morphological algorithms for extracting
boundaries, connected components, the convex hull, and the
skeleton of a region.
• We also develop several methods (for region filling, thinning,
thickening, and pruning) that are used frequently for pre- or post-
processing.

15
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

16
DIGITAL IMAGE PROCESSING - 2

Morphological Algorithms

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Example 3

*Erosion works with foreground elements

Structuring element
designed to detect object D
Image with its foreground defined as Ac

• The erosion of the foreground of Ic by


B2 is the shaded region .
• It contains the origin of D, but is also
contains parts of sets Ac and C

Erosion of Ac by B2 4
DIGITAL IMAGE PROCESSING - 2
Example 3

Image with its foreground Structuring elements designed


to detect object D. Image with its foreground defined as Ac
defined as A

Shows the location of the origin


of D, as desired.

Erosion of Ac by B2 5
Erosion of A by B1. Intersection of the 2 erosions
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• After basic morphological operations, we are now ready to


consider some practical uses of morphology.
• One of the principal applications of morphology (dealing with
binary images) is in extracting image components that are useful in
the representation and description of shape
• In particular, we consider morphological algorithms for extracting
boundaries, connected components, the convex hull, and the
skeleton of a region.
• We also develop several methods (for region filling, thinning,
thickening, and pruning) that are used frequently for pre- or post-
processing.

6
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

7
DIGITAL IMAGE PROCESSING - 2
Boundary Extraction

• The boundary of set A of foreground pixels is obtained by first


eroding A by a suitable SE B, and then performing the set
difference between A and its erosion

8
DIGITAL IMAGE PROCESSING - 2
Boundary Extraction

Example 1: Consider a simple binary object and a structuring


element B

Structuring
Set, A, of foreground pixels. element. A eroded by B.

Boundary of A.

9
DIGITAL IMAGE PROCESSING - 2
Boundary Extraction

Example 2: Consider a simple binary object and a structuring


element B

Structuring
element.

A binary image

Boundary of A.

10
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

11
DIGITAL IMAGE PROCESSING - 2
Region / Hole Filling

• Hole: defined as background region surrounded by connected border


of foreground pixels

• Region/hole filling: The process of ‘coloring in’ a definite image area


or region

• Algorithm is based on set dilation, complementation and intersection


for filling holes/regions in an image

12
DIGITAL IMAGE PROCESSING - 2
n image. Let A denote a set whose elements are 8-connected bound-
The Algorithm
boundary enclosing a background region (i.e., a hole). Given a point
objective
• Step 1:is to fill all the holes with foreground elements (1’ s).
orming
• Formananarray, X0 0of, 0’s
array , X 0’s (the
of (same size same
as I, thesize ascontaining
image I , the image
A) containing
ationsexcept
in Xat0locations in X0 that correspond
that correspond to pixels to pixels
thatthat
areareknown to be holes,
known to be holes, which we set to 1. Then following
1. Then, the following procedure fills all the holes with 1’ s:
procedure fills all the holes with 1’s

X k = ( X k -1 { B ) ¨ I c
k = 1, 2, 3, … (9-19)
• B is symmetric
ymmetric SE
structuring element in Fig. 9.17(c) . The algorithm termi-
• The
n step k if X k = terminates
algorithm at iteration
X k -1. Then, step k if Xall
X k contains k=X the
k-1 filled holes. The set
• Union ofall
I contains original image Iholes
the filled with Xkand
results in region
their filling
boundaries.
n Eq. (9-19) would fill the entire area if left unchecked, but the
ach step with I c limits the result to inside the region of interest. This is 13
DIGITAL IMAGEfilling holes in an image. Let A denote a set whose elements are 8-connected bound-
PROCESSING -2
aries, with each boundary enclosing a background region (i.e., a hole). Given a point
Example 1 in each hole, the objective is to fill all the holes with foreground elements (1’ s).
We begin by forming an array, X 0 , of 0’s (the same size as I , the image containing
A), except at locations in X 0 that correspond to pixels that are known to be holes,
• The input image
whichand
we structuring the following
element
set to 1. Then, procedure
are shown fills all the holes with 1’ s:
below.
Remember, the dila-
Perform region filling operation
X k = ( X k -1 { B ) ¨ I c
tion of image X by B
is the dilation of the k = 1, 2, 3, … (9-19)
foreground
elements of X by B.
where B is the symmetric structuring element in Fig. 9.17(c) . The algorithm termi-
nates at iteration step k if X k = X k -1. Then, X k contains all the filled holes. The set
union of X k and I contains all the filled holes and their boundaries.
The dilation in Eq. (9-19) would fill the entire area if left unchecked, but the
intersection at each step with I c limits the result to inside the region of interest. This is
our first example of how a morphological process can be conditioned to meet a desired
property. In the current application, the process is appropriately called conditional
Input Image Structuring
dilation. The restElement
of Fig. 9.17 illustrates furtherof
Complement the mechanics
Input Imageof Eq. (9-19). This exam-
ple only has one hole, but the concept applies to any finite number of holes, assuming
that a point inside each hole is given (we remove this requirement in Section 9.6).

14
E
XAMPE9.6: M
L orph
ologic
al h
olefillin
g.
by forming an array, X 0 , of 0’s (the same size as I , the image containing
DIGITAL IMAGE
locations in X 0PROCESSING -2
that correspond to pixels that are known to be holes,
Then,1the
Example
to 1. following procedure fills all the holes with 1’ s:
: Solution

X k = ( X k -1 { B ) ¨ I c
k = 1, 2, 3, … (9-19)
• Step 1: Initially take X0 as shown below.
e symmetric
• Perform dilationstructuring
of X with SE B.
0
element in Fig. 9.17(c) . The algorithm termi-
tion •• step k if X k = X k -1. Then, X k contains all the filled holes. The set
The resultant image is then intersected with complement of input image, I.
This completes first iteration.
and I contains all the filled holes and their boundaries.
on in Eq. (9-19) would fill the entire area if left unchecked, but the
t each step with I c limits the result to inside the region of interest. This is
ple of how a morphological process can be conditioned to meet a desired
he current application, the process is appropriately called conditional
est of Fig. 9.17 illustrates further the mechanics of Eq. (9-19). This exam-
one hole, but the concept applies to any finite number of holes, assuming
15
nside each hole is given (we remove this requirement in Section 9.6).
DIGITAL IMAGE PROCESSING - 2
Example 1 : Solution

• Step 2: Repeat Step 1 with input as output of step 1

• Step 3: Repeat same process till no change

16
DIGITAL IMAGE PROCESSING - 2
Example 1 : Solution

• Step 4 and Step 5:

17
DIGITAL IMAGE PROCESSING - 2
Example 1 : Solution

• Step 6:

• Step 7: Perform union of result of Step 6 and original image to


get region filled image

18
by forming an array, X 0 , of 0’s (the same size as I , the image containing
DIGITAL IMAGE PROCESSING - 2
locations in X 0 that correspond to pixels that are known to be holes,
Example
to 1. Then,2the following procedure fills all the holes with 1’ s:

X k = ( X k -1 { B ) ¨ I c k = 1, 2, 3, … (9-19)

he symmetric structuring element in Fig. 9.17(c) . The algorithm termi-


ation step k if X k = X k -1. Then, X k contains all the filled holes. The set
and I contains all the filled holes and their boundaries.
on in Eq. (9-19) would fill the entire area if left unchecked, but the
at each step with I c limits the result to inside the region of interest. This is
mple of how a morphological process can be conditioned to meet a desired
the current application, the process is appropriately called conditional
rest of Fig. 9.17 illustrates further the mechanics of Eq. (9-19). This exam-
one hole, but the concept applies to any finite number of holes, assuming
nside each hole is given (we remove this requirement in Section 9.6).
19
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

✓Boundary Extraction
✓Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

20
DIGITAL IMAGE PROCESSING - 2

Morphological Algorithms Cont..

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

✓Boundary Extraction
✓Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

4
DIGITAL IMAGE PROCESSING - 2
Extraction of Connected Componenets

• Extraction of connected components from binary image is


required in many automated image analysis applications
• Step 1: Initially take X0 (of same size as I, the image containing
A) whose elements are 0’s, except at each location known to
correspond to a point in each connected component in A,
which is to be set to 1
• Objective is to start with X0 and find all connected components
in I

5
DIGITAL IMAGE PROCESSING - 2
Extraction of Connected Components

• The procedure terminates when Xk = Xk-1

• Xk contains all connected components of foreground pixels in


the image

• Here we intersect with I instead of Ic (as in region filling), as we


are looking for foreground points, while in hole filling objective
is to find background points

6
DIGITAL IMAGE PROCESSING - 2
Example

7
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

8
DIGITAL IMAGE PROCESSING - 2
Convex Hull

• A set ‘A’ is said to be convex if the straight line segment


joining any two points in ‘A’ lie entirely within A.
• Convex hull, H, is the smallest convex set containing A
• Let denote 4 structuring elements as below

9
DIGITAL IMAGE PROCESSING - 2
Convex Hull

• The procedure consists of implementing the morphological


equation

with
When procedure converges using ith SE (when we let

• Then convex hull of A is union of all 4 results

10
DIGITAL IMAGE PROCESSING - 2
Convex Hull

• This method consists of iteratively applying hit or miss


transform to I with Bi until convergence, then letting Di=Xki,
where k is the step where convergence occurred

• Procedure is repeated with B2 (applied to I) until no further


changes occur and so on

• Union of 4 resulting Di constitutes the convex hull of A

• Initialize with k=0 and X0i = I every time SE changes

11
DIGITAL IMAGE PROCESSING - 2
Example 1

Determine the Convex hull, H, of the given image I

Structuring elements.

Convex hull, H, is the smallest convex set containing A

12
DIGITAL IMAGE PROCESSING - 2
Example 1

Structuring elements.

13
DIGITAL IMAGE PROCESSING - 2
Example 1

Structuring elements.

14
DIGITAL IMAGE PROCESSING - 2
Example 1

Structuring elements.

15
DIGITAL IMAGE PROCESSING - 2
Example 1

Structuring elements.

16
DIGITAL IMAGE PROCESSING - 2
Example 1

Structuring elements.

17
DIGITAL IMAGE PROCESSING - 2
Example 1

18
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

19
DIGITAL IMAGE PROCESSING - 2

Morphological Algorithms Cont..

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull Cont..
• Thinning
• Thickening
• Skeletons
• Pruning

4
DIGITAL IMAGE PROCESSING - 2
Convex Hull

• A set, S, of points in the Euclidean plane is said to be convex if and


only if a straight line segment joining any two points in S lies
entirely within S.
• The convex hull, H, of S is the smallest convex set containing S.

Convex Set

Not a Convex Set


5
DIGITAL IMAGE PROCESSING - 2
Convex Hull

• The digital image plane only allows points at discrete


coordinates.
• Thus, the sets with which we work are digital sets.
• The same concepts of convexity are applicable to digital sets,
but the definition of a convex digital set is slightly different.
• A digital set, A, is said to be convex if and only if its Euclidean
convex hull only contains digital points belonging to A.
• A simple way to visualize if a digital set of foreground points is
convex is to join its boundary points by straight (continuous)
Euclidean line segments.
• If only foreground points are contained within the set formed
by the line segments, then the set is convex; otherwise it is
not.
6
DIGITAL IMAGE PROCESSING - 2
Algorithm to determine Convex Hull

• Obtain an approximation of the convex hull of a set


A of foreground pixels, embedded in a binary image, I.

• Let denote 4 structuring elements as below

7
DIGITAL IMAGE PROCESSING - 2
Algorithm to determine Convex Hull

• The procedure consists of implementing the morphological


equation

with
When procedure converges using ith SE

• Then convex hull of A is union of all 4 results

8
DIGITAL IMAGE PROCESSING - 2
Convex Hull

• This method consists of iteratively applying hit or miss


transform to I with Bi until convergence, then letting Di=Xki,
where k is the step where convergence occurred

• Procedure is repeated with B2 (applied to I) until no further


changes occur and so on

• Union of 4 resulting Di constitutes the convex hull of A

• Initialize with k=0 and X0i = I every time SE changes

9
DIGITAL IMAGE PROCESSING - 2
Example

Determine the Convex hull, H, of the given image I

Structuring elements.

Convex hull, H, is the smallest convex set containing A

10
DIGITAL IMAGE PROCESSING - 2
Example: First ISE, i=1
Structuring element

X1 1 X1 2

11
X1 X1 4
DIGITAL IMAGE PROCESSING - 2
Example: Second SE, i=2

Structuring element

X2 0 X2 1 X2 2

12
DIGITAL IMAGE PROCESSING - 2
Example: Third SE, i=3

Structuring element

13
DIGITAL IMAGE PROCESSING - 2
Example: Fourth SE, i=4

Structuring element

X4 1

14
DIGITAL IMAGE PROCESSING - 2
Example 1

Structuring elements.

15
DIGITAL IMAGE PROCESSING - 2
Example 1

*This method does


not yield the smallest
possible Hull

16
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

17
DIGITAL IMAGE PROCESSING - 2
Thinning

• The thinning of a set A by a structuring element B, is defined as

• A more useful expression for thinning A symmetrically is based


on a sequence of structuring elements:

• where Bi is rotated version of Bi-2


• The thinning by a sequence of structuring element {B}

18
DIGITAL IMAGE PROCESSING - 2
Example

• The process is to thin A by one pass with B1

• Then thin the result with one pass of B2, and so on, until A is
thinned with one pass of Bn.

• The entire process is repeated until no further changes occur


after one complete pass through all structuring elements.

• Each individual thinning pass is performed using the given


equation

19
DIGITAL IMAGE PROCESSING - 2
Example

• Consider a set of structuring elements used routinely for thinning

(Bi is equal to Bi−1 rotated clockwise by 45° )

20
DIGITAL IMAGE PROCESSING - 2
Example

21
DIGITAL IMAGE PROCESSING - 2
Example

22
DIGITAL IMAGE PROCESSING - 2
Example

23
DIGITAL IMAGE PROCESSING - 2
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

24
ADVANCED DIGITAL IMAGE PROCESSING

Morphological Algorithms Cont..

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
ADVANCED DIGITAL IMAGE PROCESSING
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

5
ADVANCED DIGITAL IMAGE PROCESSING

Thickening
• Morphological operation used to grow selected regions of
foreground pixels
• Thickening is the morphological dual of thinning and is defined
by the expression

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


operation:

6
ADVANCED DIGITAL IMAGE PROCESSING

Thickening

• The structuring elements used for thickening have the same form as
those shown in thinning but with all 1’s and 0’s interchanged

• However, a separate algorithm for thickening is seldom used in practice.

• Instead, the usual procedure is to thin the background of the set in


question, then complement the result.

• In other words, to thicken a set A we form Ac , thin Ac , and then


complement the thinned set to obtain the thickening of A.

• Remove all disconnected components


7
ADVANCED DIGITAL IMAGE PROCESSING
Example of Thickening using Thinning
Perform
Using

(a) Set A. (b) Complement of A (c) Thinning of Ac by B1


Ac B1

8
ADVANCED DIGITAL IMAGE PROCESSING
Example of Thickening using Thinning
Perform
Using

(a) Set A. (b) Complement of A (c) Result of thinning the complement.

(d) Thickened set obtained by 9


(e) Final result, with no disconnected points.
ADVANCED DIGITAL IMAGE PROCESSING

Analysis

• Depending on the structure of A, this procedure can result in


disconnected points
• Hence thickening by this method usually is followed by post-
processing to remove disconnected points.
• Note from (c) that the thinned background forms a boundary
for the thickening process.
• This useful feature is not present in the direct
implementation of thickening using the Eq., and it is one of
the principal reasons for using background thinning to
accomplish thickening.

10
ADVANCED DIGITAL IMAGE PROCESSING
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

11
ADVANCED DIGITAL IMAGE PROCESSING
Skeletons

• Consider the figures below:

• Condition: If z is a point in S(A), and (D)z is the largest disk


centered at z and contained in A, one can’t find a larger disk
containing (D)z and simultaneously included in A.
• A disk satisfying these conditions is called a maximum disk

12
ADVANCED DIGITAL IMAGE PROCESSING
Skeletons

• If (D)z is a maximum disk, it touches the boundary of A at two


or more different places
• The skeleton of A can be expressed in terms of erosions and
openings

With where

indicates k successive erosions starting with ‘A’ k times

K is the last iterative step before A erodes to an empty set.


13
ADVANCED DIGITAL IMAGE PROCESSING
Example
Consider Set A. Determine its skeleton

denotes k successive dilations, starting with Sk (A)

14
ADVANCED DIGITAL IMAGE PROCESSING
Example
Consider Set A.

Various positions of maximum disks Another maximum disk, whose center


whose centers partially define the defines a different segment of the
skeleton of A. skeleton of A.

Complete skeleton (dashed).

15
ADVANCED DIGITAL IMAGE PROCESSING
Some Basic Morphological Algorithms

• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

16
ADVANCED DIGITAL IMAGE PROCESSING
Pruning
• Complement to thinning and skeletonizing algorithms

• Generally required in post processing to clean up

• Consider automated recognition of hand written characters. Here


shape of skeleton of character is analyzed

• These skeletons often contain spurs, due to noise and non


uniformity in character strokes

• Remove these using morphological technique with the assumption


that the length of a parasitic component does not exceed a specified
number of pixels.
17
ADVANCED DIGITAL IMAGE PROCESSING
Pruning

• Consider the alphabet ‘a’. It has spurs that need to be removed

• Assumption is any branch with 3 or less pixels is to be


eliminated
• Thinning of set A with a sequence of SE designed to detect
only end points achieves the desired result

where {B} denotes the structuring element sequence


18
ADVANCED DIGITAL IMAGE PROCESSING
Pruning

• The sequence of structuring elements consists of two


different structures, each of which is rotated 90° for a
total of eight elements.

• Each SE is a detector for an end point in a particular


orientation

19
ADVANCED DIGITAL IMAGE PROCESSING
Example

• Perform pruning on the following image

Step 1: Perform thinning using the given SEs using

SEs used for deleting end points.

(c) X1 : Result of three cycles


of thinning.
20
ADVANCED DIGITAL IMAGE PROCESSING
Example

Step 2: The next step is to “restore” the character to its original form, but
with the parasitic branches removed.
This requires that we first form a set X2 containing all end points in X1

where the Bk are the end-point detectors

SEs used for deleting end points.

(d) X2 : End points of (c).

21
ADVANCED DIGITAL IMAGE PROCESSING
Example

Step 3: The next step is dilation of the end points.


Typically, the number of dilations is less than the number of end- point
removals to reduce the probability of “growing” back some of the spurs.

Here we dilate the end points three times using A as a delimiter.


This is the same number of thinning passes:

where H is a 3 X 3 structuring element of 1’s, and the intersection with A


is applied after each step

As in the case of region filling, this type of conditional


dilation prevents the creation of 1-valued elements outside
the region of interest,

X3 : Dilation of end points conditioned on (a)


22
ADVANCED DIGITAL IMAGE PROCESSING
Example

Step 4:Finally, take the union of X1 and X3 ,

X1 : Result of three cycles (f) Pruned image


X3 : Dilation of end points
of thinning.
conditioned on (a)

23
ADVANCED DIGITAL IMAGE PROCESSING
Example

(a) Set A of foreground


(c) Result of three cycles
pixels (shaded) (d) End points of (c).
of thinning.

SEs used for detecting end points.

(f) Pruned image


(e) Dilation of end points
conditioned on (a) 24
ADVANCED DIGITAL IMAGE PROCESSING
Steps involved in Pruning

• Steps for pruning

X 1 = A Ä{B} ;Thinning

where the Bk are the end-point detectors

25
ADVANCED DIGITAL IMAGE PROCESSING

Summary of
binary
morpho
logical
operations
and
their
properties.

26
DIGITAL IMAGE PROCESSING - 2

Grayscale Morphology

Dr. Shruthi M.L.J.


Department of Electronics & Communication Engineering
2
DIGITAL IMAGE PROCESSING - 2
Morphological Operations on Grayscale Images

• Basic operations of dilation, erosion, opening, and closing of


binary images can be extended to grayscale images
• These operations can be used to develop several basic
grayscale morphological algorithms
• Consider f(x,y) and b(x,y), where f(x,y) is a grayscale image and
b(x, y) is a structuring element
• The assumption is that these functions are discrete
• That is, if Z denotes the set of real integers, then the coordinates (x, y)
are integers from the Cartesian product Z2, and f(x,y) and b(x,y) are
functions that assign an intensity value (a real number from the set of
real numbers, R) to each distinct pair of coordinates (x, y). If the
intensity levels are integers also, then Z replaces R.

5
DIGITAL IMAGE PROCESSING - 2
Structuring Elements

• Structuring elements in grayscale morphology perform the


same basic functions as their binary counterparts
• They are used as “probes” to examine a given image for
specific properties.
• Structuring elements in grayscale morphology belong to one of
two categories: nonflat and flat.
Here 0(0): Black and 1(255): White

Horizontal intensity profiles 6


through their centers
DIGITAL IMAGE PROCESSING - 2
Structuring Elements

• As in the binary case, the origin of grayscale structuring


elements must be clearly identified

• Unless mentioned otherwise, all the examples in this section


are based on symmetrical, flat structuring elements of unit
height whose origins are at the center.

• The reflection of an SE in grayscale morphology is defined as

7
DIGITAL IMAGE PROCESSING - 2
Grayscale Morphological Operations

• Erosion
• Dilation
• Opening
• Closing

8
DIGITAL IMAGE PROCESSING - 2

Erosion
• The grayscale erosion of f by a flat structuring element b at
location (x, y) is defined as the minimum value of the image in
the region coincident with b(x, y) when the origin of b is at (x, y)
• The erosion at (x, y) of an image f by a structuring element b is
given as

where, in a manner similar to spatial correlation, x and y are


incremented through all values required so that the origin of b
visits every pixel in f.
• That is, to find the erosion of f by b, we place the origin of the
structuring element at every pixel location in the image. The
erosion at any location is determined by selecting the minimum
value of f in the region coincident with b.
9
DIGITAL IMAGE PROCESSING - 2

Erosion
• For example, if b is a square structuring element of size 3 × 3,
obtaining the erosion at a point requires finding the minimum of
the nine values of f contained in the 3 × 3 region spanned by b
when its origin is at that point.
• Because grayscale erosion with a flat SE computes the minimum
intensity value of f in every neighborhood of (x, y) coincident
with b, we expect in general
• that an eroded grayscale image will be darker than the
original
• that the sizes (with respect to the size of the SE) of bright
features will be reduced
• and that the sizes of dark features will be increased

10
DIGITAL IMAGE PROCESSING - 2

Erosion Example

Gray-scale X-ray image of Erosion using a flat disk SE


size 448 x 425 pixels. with a radius of 2 pixels

• The intensities of the small bright dots were reduced, making


them barely visible, while the dark features grew in thickness.
• The general background of the eroded image is slightly darker
than the background of the original image
11
DIGITAL IMAGE PROCESSING - 2

Erosion with Nonflat SE


• Nonflat SEs have grayscale values that vary over their domain of
definition. The erosion of image f by nonflat structuring element,
bN , is defined as

• Here, we subtract values from f to determine the erosion at any


point
• Unlike flat SE, erosion using a nonflat SE is not bounded in
general by the values of f, which can be problematic in
interpreting results.
• Grayscale SEs are seldom used in practice because of this, the
potential difficulties in selecting meaningful elements for bN ,
and the added computational burden
12
DIGITAL IMAGE PROCESSING - 2

Grayscale Dilation
• Grayscale dilation of f by a flat structuring element b at any
location (x,y) is defined as the maximum value of the image in
the window spanned by when the origin of is at (x, y)

Where

• Use the maximum, rather than the minimum operation, and


keep in mind that the structuring element is reflected about its
origin, taken into account by using (−s, −t) in the argument of the
function.
• This is analogous to spatial convolution
13
DIGITAL IMAGE PROCESSING - 2

Grayscale Dilation

Gray-scale X-ray image of Erosion using a flat disk SE Dilation using the same SE.
size 448 x 425 pixels. with a radius of 2 pixels
• The effects are the opposite of using erosion. The bright features were
thickened and the intensities of the darker features were reduced.
• In particular, the thin black connecting wires in the left, middle, and right
bottom are barely visible
• The sizes of the dark dots were reduced as a result of dilation, but, unlike the
eroded small white dots, they still are easily visible in the dilated image.
• The reason is that the black dots were originally larger than the white dots with
respect to the size of the SE. Finally, observe that the background of the dilated 14
image is slightly lighter than that of (a).
DIGITAL IMAGE PROCESSING - 2

Dilation with Non flat SE

• The dilation of image f by nonflat structuring element, bN , is


defined as

• This also has same issues as erosion

15
DIGITAL IMAGE PROCESSING - 2

Grayscale Erosion and Dilation


• As in the binary case, grayscale erosion and dilation are duals
with respect complementation and reflection

• The same expression holds for nonflat structuring elements


• The notation can be simplified by suppressing the arguments of
all functions, in which case the preceding equation is written as

16
DIGITAL IMAGE PROCESSING - 2

Grayscale Erosion and Dilation

• Erosion and dilation by themselves are not particularly useful in


grayscale image processing.

• As with their binary counterparts, these operations become


powerful when used in combination to derive higher-level
algorithms.

17
DIGITAL IMAGE PROCESSING - 2

Grayscale Opening and Closing


• The expressions for opening and closing grayscale images have the
same form as their binary counterparts.
• The grayscale opening of image f by structuring element b, denoted as
is

• Opening is simply the erosion of f by b, followed by a dilation of the


result by b.
• Similarly, the grayscale closing of f by b, denoted as is

18
DIGITAL IMAGE PROCESSING - 2

Grayscale Opening and Closing

• The opening and closing for grayscale images are duals with
respect to complementation and SE reflection:

• Because f c = −f, we can write

19
DIGITAL IMAGE PROCESSING - 2

Grayscale Opening and Closing


• Opening and closing of grayscale images have a simple geometric
interpretation.
• Suppose that an image function f ( x, y) is viewed as a 3-D surface; that
is, its intensity values are interpreted as height values over the xy-plane
• Then the opening of f by b can be interpreted geometrically as pushing
the structuring element up from below against the undersurface of f.
• At each location of the origin of b, the opening is the highest value
reached by any part of b as it pushes up against the undersurface of f.
• The complete opening is then the set of all such values obtained by the
origin of b visiting every (x, y) coordinate of f.

20
DIGITAL IMAGE PROCESSING - 2

Grayscale Opening with flat SE


• Consider the curve in figure below is the intensity profile along a single row of
an image.

• Now consider a flat structuring element in several positions, pushed up


against the bottom of the curve.

• Complete opening is shown by heavy curve


• Because the structuring element is too large to fit completely inside the
upward peaks of the curve, the tops of the peaks are clipped by the opening,
with the amount removed being proportional to how far the structuring
element was able to reach into the peak.
• In general, openings are used to remove small, bright details, while leaving the
overall intensity levels and larger bright features relatively undisturbed.
21
DIGITAL IMAGE PROCESSING - 2

Grayscale Closing with flat SE


• Consider the curve in figure below is the intensity profile along a single
row of an image.

• Here the structuring element is pushed down on top of the curve


while being translated to all locations.

• The closing, is constructed by finding the lowest points reached by any


part of the structuring element as it slides against the upper side of the
curve

• The properties of grayscale opening and closing remain same as their


binary counterparts
22
DIGITAL IMAGE PROCESSING - 2

Summary of Unit 2
• Basic Morphological operations
• Erosion
• Dilation
• Opening
• Closing
• Morphological Algorithms
• Boundary Extraction
• Region Filling
• Extraction of connected components
• Convex hull
• Thinning
• Thickening
• Skeletons
• Pruning

• Grayscale Morphology
• Grayscale morphological operations
23

You might also like