0% found this document useful (0 votes)
49 views47 pages

Morphological Image Processing - 12thmarch2023

The document discusses morphological image processing techniques. It defines morphological operations like dilation, erosion, opening and closing. Dilation expands objects in an image while erosion shrinks them. Opening performs erosion followed by dilation to eliminate small objects. Closing performs dilation followed by erosion to fill small holes.

Uploaded by

Jovial O'Brian
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)
49 views47 pages

Morphological Image Processing - 12thmarch2023

The document discusses morphological image processing techniques. It defines morphological operations like dilation, erosion, opening and closing. Dilation expands objects in an image while erosion shrinks them. Opening performs erosion followed by dilation to eliminate small objects. Closing performs dilation followed by erosion to fill small holes.

Uploaded by

Jovial O'Brian
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/ 47

Image Analysis

• Morphological operations
• Segmentation
– Thresholding
– Edge detection
• Representation of objects
Morphological Image Processing

• “Morphology “ – a branch in biology


that deals with the form and structure
of animals and plants.
• “Mathematical Morphology” – as a tool
for extracting image components, that
are useful in the representation and
description of region shape
Introduction
binary
1. Morphological operators often take a binary image image
and a structuring element as input and combine
them using a set operator (intersection, union,
inclusion, complement).
2. The structuring element is shifted over the image
and at each pixel of the image its elements are
compared with the set of the underlying pixels.
3. If the two sets of elements match the condition
defined by the set operator (e.g. if set of pixels in
the structuring element is a subset of the
underlying image pixels), the pixel underneath the
origin of the structuring element is set to a pre-
defined value (0 or 1 for binary images).
4. A morphological operator is therefore defined by structuring
element
its structuring element and the applied set operator.
Applications of These can be grouped into:
1) Pre-processing e.g.
Morphological noise filtering,
image filtering shape simplification
2) Enhance object structure
convex hull,
– boundaries extraction skeletonization,
– skeletons Thinning,
– convex hull Object marking
– morphological filtering 3) Quantitative description
– thinning area, perimeter,
– Pruning projection, Euler-
Poincaré characteristics
4) Segmentation of the object
from the background
Basic Concepts in Set Theory
• Subset
• Union
• Intersection
disjoint / mutually exclusive
• Complement
• Difference
• Reflection
• Translation
Reflection and Translation

• Reflection
The reflection of a set B, denoted B, is defined as
B  {w | w  b, for b  B}

• Translation
The translation of a set B by point z  ( z1 , z2 ), denoted ( B) Z ,
is defined as
( B) Z  {c | c  b  z, for b  B}
Example: Reflection and Translation

CP-7008: Digital Image Processing Lecture # 9 7


Logic Operations Involving Binary
Pixels and Images
• The principal logic operations used in image processing
are: AND, OR, NOT (COMPLEMENT).
• These operations are functionally complete.
• Logic operations are performed on a pixel by pixel basis
between corresponding pixels (bitwise).
• Other important logic operations :
XOR (exclusive OR), NAND (NOT-AND)
• Logic operations are just a private case for a binary set
operations, such :
AND – Intersection ,
OR – Union,
NOT-Complement.
Structure elements (SE)
Small sets or sub-images used to probe an image under study for
properties of interest

origin
Examples: Structuring Elements (2)
At each location of
the origin of B, if B is
Accommodate the completely
entire structuring contained in A, then
elements when its the location is a
origin is on the member of the new
border of the set, otherwise it is
original set A not a member of the
new set.

Origin of B visits
every element of A

CP-7008: Digital Image Processing Lecture # 9 11


Morphological Image Processing

Dilation and Erosion


• Dilation and erosion are the two fundamental operations used in
morphological image processing. Almost all morphological algorithms depend on
these two operations:

• Dilation: Given A and B sets in Z2, the dilation of A by B, is defined by:


A  B  z ( Bˆ ) z A 
^
•The dilation of A and B is a set of all displacements, z , such that B and A
overlap by at least one element. The definition can also be written as:


A  B  z ( Bˆ ) z A  A 
•Set B is referred to as the structuring element and used in dilation as well as in
other morphological operations. Dilation expands/dilutes a given image.
• Dilation: Given the structuring element B and set A.

Shaded area is the dilation


of A by B
origin

•The structuring element B


enlarges the size of A at its
boundaries. Dilation simply
expands a given image.

•The structuring element B enlarges the size of


A at its boundaries, in relation to the distance
from the origin of the structuring element .
Dilation

• Dilation: Given the following distorted text image where the maximum length
of the broken characters are 2 pixels. The image can be enhanced by bridging the
gaps by using the structuring element given below:

B
3x3 structuring
element

A A B
•Note that the broken characters are joined.
Dilation Example
Original Image Processed Image With Dilated Pixels

Structuring Element
Dilation Example 2

Original image Dilation by 3*3 Dilation by 5*5


square structuring square structuring
element element
Watch out: In these examples a 1 refers to a black pixel!

Dilation can repair breaks


Dilation can repair intrusions
Watch out: Dilation enlarges objects
Erosion

• Erosion: Given A and B sets in Z2, the erosion of A by structuring element B, is


defined by:

A B   z ( B ) z  A
•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.

Shaded area is the erosion


of A by B

structuring
element

•Note that in erosion the structuring element B erodes the input image A at its boundaries.
Erosion shrinks a given image.
• Erosion: Given the structuring element B and set A.

Shaded line is what is left


from the erosion of A by B

structuring
element
Erosion Example
Original Image Processed Image

Structuring Element
Erosion Example 2

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
Erosion Example 3

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


square structuring square structuring
element element

Watch out: In these examples a 1 refers to a black pixel!

Erosion can split apart joined objects


Erosion can strip away extrusions
Watch out: Erosion shrinks objects
Erosion and Dilation summary

•Structuring element is a square shape of size 13x13 pixels.


NB: erosion followed by dilation helps to perform filtering
Opening and closing

Opening: The process of erosion followed by dilation is called opening.


•It has the effect of eliminating small and thin objects, breaking the objects at
thin points and smoothing the boundaries/contours of the objects.

• Given set A and the structuring element B. Opening of A by structuring element B


is defined by:
A  B  ( A  B)  B

• Closing: The process of dilation followed by erosion is called closing.


•It has the effect of filling small and thin holes, connecting nearby objects and smoothing
the boundaries/contours of the objects.

•Given set A and the structuring element B. Closing of A by structuring element B is defined
by:
A  B  ( A  B)  B
Opening

• Opening: The opening of A by the structuring element B is obtained by taking


the union of all translates of B that fit into A.
•The opening operation can also be expressed by the following formula:

A  B  Bz ( Bz )  A

Outer boundary of A

Origin of B
Circular structuring element Shaded area: complete opening

Possible translations of B in A
Closing

• Closing: The closing has a similar geometric interpretation except that we roll
B on the outside of the boundary.
•The opening operation can also be expressed by the following formula:

A  B  ( Bz ) ( Bz )  A  
Outer boundary of A

Outer boundaries of closing


Shaded area: complete closing

Possible translations of B on the outer boundaries of A


Opening Example Closing example

Original image

Image after opening Image after closing


Opening and closing

B
circular structuring
element

result of erosion of A by B

result of opening of A by B

result of dilation of A by B

result of closing of A by B
Impulsive noise within the background and th
fingerprints is removed.
The Hit-or-Miss Transformation
 The Hit-or-Miss Transformation is a method to find
the location of a shape (defined by structuring
element) in an image
 it is an operation that detects a given pattern in a
binary image using a structuring element containing
1’s, 0’’s and blanks for don’t cares
 Used to thin and skeletonize a shape in a binary image
Hit-or-Miss exp:
The Hit-or-Miss Transformation
 A basic morphological tool for shape detection.
 Let the origin of each shape be located at its center of
gravity.
 If we want to find the location of a shape , say – X ,
at (larger) image, say – A :
 Let X be enclosed by a small window, say – W.
 The local background of X with respect to W is defined as
the set difference (W - X).
 Apply erosion operator of A by X, will get us the set of
locations of the origin of X, such that X is completely
contained in A.
 It may also be viewed geometrically as the set of all locations
of the origin of X at which X found a match (hit) in A.
The Hit-or-Miss Transformation
Cont.
 Apply erosion operator on the complement of A by the local
background set (W – X).
 Notice, that the set of locations for which X exactly fits inside
A is the intersection of these two last operators above.
This intersection is precisely the location sought.
Formally:
If B denotes the set composed of X and it’s background –
B = (B1,B2) ; B1 = X , B2 = (W-X).
The match (or set of matches) of B in A, denoted is:
The Hit-or-Miss Transformation
 The reason for using these kind of structuring element –
B = (B1,B2) is based on an assumed definition that,
two or more objects are distinct only if they are
disjoint (disconnected) sets.
 In some applications, we may interested in detecting
certain patterns (combinations) of 1’s and 0’s and
not detecting individual objects.
In this case a background is not required.
the hit-or-miss transform reduces to simple erosion.
 This simplified pattern detection scheme is used in
some of the algorithms for – identifying characters
within a text.
Boundary Extraction
• First, erode A by B, then make set difference
between A and the erosion
• The thickness of the contour depends on the
size of constructing object – B

Ex 1: 3x3 Square structuring element is used for boundary extraction.


Ex 2: The same structuring element in Ex1 is used.
Note that thicker boundaries can be obtained by increasing the size of structuring element.
Region Filling

• Region Filling: Region filling can be performed by using the following


definition:
Given a symmetric structuring element B, one of the non-boundary pixels (Xk) is
consecutively diluted and its intersection with the complement of A is taken as
follows:
k  1,2,3,...
X k  ( X k 1  B )  A c
terminates when X k  X k 1
X 0  1 (inner pixel)

•Following consecutive dilations and their intersection with the complement of A,


finally resulting set is the filled inner boundary region and its union with A gives
the filled region F(A).

F ( A)  X k  A
• Region Filling Example

A non-boundary pixel

Ex 1: X0=1 (Assume that the shaded boundary points are


1 and the white pixels are 0)
This region is filled first.

Filling of all the other regions


Connected Component Extraction

• Connected Component Extraction: The following iterative expression can be


used to determine all the pixels in component Y which is in A.
k  1,2,3,...
X k  ( X k 1  B)  A
terminateswhen X k  X k 1
X 0  1(boundary pixel)

• X0=1 corresponds to one of the pixels on the


component Y. Note that one of the pixel
locations on the component must be known.
Result of first iteration
Known pixel, p • Consecutive dilations and their intersection
with A, yields all elements of component Y.

Result of second iteration Result of last iteration


Connected Component Extraction Example

nput image
Chicken fillet)

Thresholded
image

15 connected
components
with different
number of
pixels
After erosion
by 5x5 square
structuring
element of 1’s
Thinning

• Thinning: Thinning of A by the structuring element B is defined by:

A B  A (A
* B) hit-or-miss transform/template matching

• Note that we are only interested in pattern matching of B in A, so no background operation


is required of the hit-miss-transform.

{B}  {B1 , B 2 , B3 ,..., B n }


•The structuring element B consists of a sequence of structuring elements, where Bi is the
rotated version of Bi-1. Each structuring elements helps thinning in one direction. If there
are 4 structuring elements thinning is performed from 4 directions separated by 90o. If 8
structuring elements are used the thinning is performed in 8 directions separated by 45o.

•The process is to thin A by one pass with B1, then the result with one pass of B2, and
continue until A is thinned with one pass of Bn.
A {B}  ((...(( A  B1 )  B 2 )...)  B n )
Thinning Example

• Thinning: The following set of structuring elements are used for thinning operation.

...

If there is no change any


more. Declared to be the
thinned object
Thickening example
Convex Hull
• A is said to be convex if a straight line segment
joining any two points in A lies entirely within A
• The convex hull H of set S is the smallest convex set
containing S
• Convex deficiency is the set difference H-S
• Useful for object description
• This algorithm iteratively applying the hit-or-miss
transform to A with the first of B element, unions it
with A, and repeated with second element of B
1

You might also like