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

CVIP Chapter Three

The document discusses morphological image processing and summarizes key concepts. It defines morphological operations like dilation and erosion that are used to extract image components and modify shapes. Dilation expands objects by superimposing a structuring element over an image and setting pixels to foreground values if any overlap. In contrast, erosion shrinks objects. These operations are fundamental to morphological algorithms.

Uploaded by

Bekele Tsanga
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)
70 views

CVIP Chapter Three

The document discusses morphological image processing and summarizes key concepts. It defines morphological operations like dilation and erosion that are used to extract image components and modify shapes. Dilation expands objects by superimposing a structuring element over an image and setting pixels to foreground values if any overlap. In contrast, erosion shrinks objects. These operations are fundamental to morphological algorithms.

Uploaded by

Bekele Tsanga
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/ 66

Computer Vision and Image Processing

CoSc4113

Chapter 3
Morphological Image Processing

1
Contents
Morphological Image processing
▪ Dilation and Erosion
▪ Opening And Closing
▪ Application of Opening And Closing
▪ Gray-scale Morphology
▪ Gray-scale Morphology Applications
▪ Basic Morphological Algorithms

22
Morphological Image processing
The word morphology refers to form and structure of an
object.
“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.
The language of mathematical morphology is – Set theory.
Unified and powerful approach to numerous image processing
problems.
In binary images , the set elements are members of the 2-D
integer space – Z . where each element (x,y) is a coordinate of a
black (or white) pixel in the image.

3
Effect of Some Morphological Processing

Pre-processed Image Image after morphological processing

After the morphological process, some noises are


removed and some disconnections are filled
4
Binary image analysis
Binary image analysis consists of a set of operations that
are used to produce or process binary images, usually
images of 0’s and 1’s where
0 represents the background,
1 represents the foreground.

00010010001000
00011110001000
00010010001000

5
Thresholding
Binary images can be obtained by thresholding.
Assumptions for thresholding:
Object region of interest has intensity distribution different
from background.
Object pixels likely to be identified by intensity alone:
intensity > a
intensity < b
a < intensity < b
Works OK with flat-shaded scenes or engineered scenes.
Does not work well with natural scenes.

6
Mathematic Morphology
Morphological processes on images are 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
Thickening
pruning
7
Basic Concepts in Set Theory
Subset
Union
Intersection
disjoint / mutually exclusive
Complement
Difference
Reflection
Translation
8
Logic Operations
The principal logic operations used in image processing
are:
1. AND,
2. OR,
3. NOT (COMPLEMENT)
Logic operations are preformed on a pixel by pixel basis between
corresponding pixels (bitwise).
Other important logic operations :
1. XOR (exclusive OR),
2. NAND (NOT-AND)
9
Possible Operations

These operators will be


used to perform different
image processing tasks by
manipulate pixels of an
image as required

10
Operations in Image Morphology
Mathematical morphology consists of two basic operations
dilation
erosion
and several composite relations that can be made of the above
opening
closing
conditional dilation

11
Pixels and neighborhoods
In many algorithms, not only the value of a particular pixel, but
also the values of its neighbors are used when processing that
pixel.
The two most common definitions for neighbors are the 4-
neighbors and the 8-neighbors of a pixel.

12
Structuring Element
The two most common structuring elements (given a
Cartesian grid) are the 4-connected and 8-connected sets,
N4 and N8.

13
Structuring Elements, Hits & Fits
B Structuring Element

Fit: All onpixels in the structuring


element cover onpixels in the
A image
Hit: Any onpixel in the
C structuring element covers an on
pixel in the image

All morphological processing operations are based on these


14 simple ideas
Structuring Elements
➢ Morphological operations are mainly defined based on the
structure and intensity ( 0 or 1) of each pixel in the
structure.
➢ Structuring elements can be any size and make any shape
➢ Mostly rectangular structuring elements with their origin at
the middle pixel is used
0 0 1 0 0
1 1 1 0 1 0 0 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 1 0 0 1 1 1 0
15
0 0 1 0 0
Fundamental Operations
➢ Basic morphological algorithms are done based on a
decision whether to extend or shrink part of an image;
➢ These operations are very similar with the process of spatial
filtering
➢ The structuring element is moved across every pixel in the
original image to give a pixel in a new processed image
➢ The value of this new pixel depends on the operation
performed
➢ There are two basic morphological operations:
1. erosion and
2. dilation
16
Definitions – Erosion and Dilation
While either set A or B can be thought of as an "image", A is
usually considered as the image and B is called a
structuring element. The structuring element is to
mathematical morphology what the convolution kernel is to
linear filter theory.

Dilation, in general, causes objects to dilate or grow in size.


In the contrary, erosion causes objects to shrink.
The amount and the way that they grow or shrink depend upon
the choice of the structuring element. Dilating or eroding
without specifying the structural element makes no more sense
than trying to lowpass filter an image without specifying the
17
filter.
Dilation
Dilation is used for expanding an element A by using structuring element B
Dilation of A by Band is defined by the following equation:

This equation is based on obtaining the reflection of B about its origin and
shifting this reflection by z.
The dilation of A by B is the set of all displacements z, such that and A
overlap by at least one element. Based on this interpretation the previous
equation can be rewritten as:

18
Dilation
Dilation expands the connected sets of 1s of a binary image.
It can be used for

growing features

filling holes and gaps

19
Dilation
➢ The basic effect of the operator on a binary image is to gradually
enlarge the boundaries of regions of foreground pixels (i.e.
white in the example).
➢ Thus areas of foreground pixels grow in size while holes within
those regions become smaller.

20
Dilation - How It Works
➢ To compute the dilation of a binary input image by this
structuring element, we consider each of the background pixels in
the input image in turn.
➢ For each background pixel (which we will call the input pixel)
we superimpose the structuring element on top of the input image
so that the origin of the structuring element coincides with the
input pixel position.
➢ If at least one pixel in the structuring element coincides
with a foreground pixel in the image underneath, then the
input pixel is set to the foreground value.
➢ If all the corresponding pixels in the image are
background, however, the input pixel is left at the
background value.

21
Dilation
Dilation of image Aby structuring element Bis given by A B
The structuring element s is positioned with its origin at (x, y)
of image A and the new pixel value of A is determined using the
rule:

1if B hits A
g(x, y) = 
0 otherwise

22
Dilation – With Substitution Example

23
Dilation – With Vector Addition Example
0 1 2 0 1
0 0 1 0 1 1
0
1 1 0 0 0 0
1
2 0 0 0
B
Structural Element
A
➢ Where are 1s of A  A(0,1) and A(1,0)
➢ Where are 1s of B  B(0,0) and B(0,1)
0 1 2
➢ Then Add each one of 1s in Awith all 1s of B
0 0 1 1
➢ A(0,1) + B(0,0)  C(0,1)
1 1 1 0
➢ A(0,1) + B(0,1)  C(0,2)
2 0 0 0
➢ A(1,0) + B(0,0)  C(1,0)
➢ A(1,0) + B(0,1)  C(1,1) C

24 ➢ The four coordinates of the Output image will be 1s and the rest will be 0s.
Dilation Example

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


square structuring square structuring
element element

In these examples a 1 refers to a black pixel!


25
Dilation Example
Text Image Enhancement

26
Purpose of Dilation
Dilation can repair breaks

Dilation can repair intrusions

Dilation enlarges objects


27
Properties of Dilation
Dilation adds pixels to the boundary of an object/part of an
image;
Number of pixels added depends on the size and type of
object and the image;
Dilation can connect parts/area that are disconnected;
In gray level image, dilation increases the brightness of the
image;

28
Erosion
The basic effect of the operator on a binary image is to erode
away the boundaries of regions of foreground pixels (i.e.
white pixels in the example). Thus areas of foreground pixels
shrink in size, and holes within those areas become larger. Effect of
erosion using a 3×3 square structuring element

29
How Erosion Works
➢ To compute the erosion of a binary input image by this
structuring element, we consider each of the foreground pixels
in the input image in turn. For each foreground pixel (which
we will call the input pixel) we superimpose the structuring
element on top of the input image so that the origin of the
structuring element coincides with the input pixel coordinates.
➢ If for every pixel in the structuring element, the
corresponding pixel in the image underneath is a
foreground pixel, then the input pixel is left as it is.
➢ If any of the corresponding pixels in the image are
background, however, the input pixel is also set to
background value.
30
Erosion
Erosion of image Aby structuring element B is given by A B
The structuring element B is positioned with its origin at (x, y)
of the image A and the new pixel value of A is determined using
the rule:

1if Bfits A
g(x, y) = 
0 otherwise

31
Erosion

Erosion is used for shrinking of element Aby using element B


Erosion for Sets Aand Bin Z2, is defined by the following
equation:

This equation indicates that the erosion of Aby Bis the set of
all points z such that B, translated by z, is combined in A.

32
Erosion– With Substitution Example

33
Erosion– With Shifting Example
➢ Slide B over A staring from the first pixel
1 1 1 1 1 1 and :
1 1 0 1 1 0 ➢ Whenever B fully matches with part of
0 1 1 1 A, set the value of A that is aligned to the
B focal point of B to 1 and move on.
0 1 0 0 Structural Element
➢ Whenever B does not fully match with
A part of A, set the value of A that is
aligned to the focal point of B to 0 and
move on.
1 1 1 1
0 1 1 1 0 1 1 1
1 1 0 1
1 1 0 1 1 1 0 1
0 1 1 1 0 1 0 0
0 1 1 1 0 1 1 1
0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0
Step 1
0 1 0 0
Step 2 Step 3
No match match 1 0 0 0 0
No match
0 0
Changing the Structural Element (B) with a different C
34 formation will result in a totally different final image.
Erosion Example

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!


35
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

36
Purpose of Erosion
Erosion can split apart joined objects

Erosion can strip away extrusions

Erosion shrinks objects


37
Properties of Erosion
Generally, erosion is the opposite of dilation
Erosion removes pixels from the boundary of an object/part
of an image;
Number of pixels removed depends on the size and type of
object and the image;
Erosion may separate parts/area that were connected;
In gray level image, erosion decreases the brightness of the
image;

38
Erosion & Dilation: eliminating irrelevant detail

Suppose we want to eliminate all the squares except


largest one.
We can do this by eroding the image with a
structuring element of a size somewhat smaller than
the objects we wish to keep.
After that, we can restore it by dilating them with the
same structuring element we used for erosion.

39
Example: Dilation and Erosion using same
Structuring Element
Original

Dilated Image
SE= 5 X 5

Eroded Image

40
Exercise
➢ Do erosion of A by the different structural elements B1 and B2 separately
and observe the variation in the final result

B1
Structural Element

B2
Structural Element

A
41
Opening And Closing
Opening – smoothes contours , eliminates projection

Closing – smoothes sections of contours, fuses narrow breaks


and long thin gulfs, eliminates small holes and fills gaps in
contours

These operations are can be applied few times, but has effect
only once

42
Opening And Closing
Opening –
First – erode A by B, and then dilate the result by B
In other words, opening is the unification of all B objects
Entirely Contained in A
Opening: roll B around the inside of A.

43
Opening And Closing…cont
Closing –
First – dilate A by B, and then erode the result by B
In other words, closing is the group of points, which the
intersection of object B around them with object A– is not
empty
Closing: roll B around the outside of A.

44
45
46
Useful: open & close

47
47 47
Application of Opening and
Closing: Morphological Filtering
Morphological operations can be used ta construct filters
similar in concept to the spatial filters
Here the noise manifests it-self as light elements on a
dark background and as dark elements on the light
components of the fingerprint.

The objective is to eliminate the noise and its effects on


the print while distorting it as little as possible.
A morphological filters consisting of opening followed
48
48 by closing can be used to accomplish this objective. 48
Filtering by Opening and Closing Operation
(c) shows the result of eroding A with the structuring element.
The background noise was completely eliminated at the erosion stage of opening because
in this case all noise components are physically smaller than the structuring element.
The size of the noise elements (dark spots) contained within the fingerprint actually
increased in size.
The reason is that these elements actually are inner boundaries that should increase in size
as the object is eroded. This enlargement is countered by performing dilation.
The noise components contained in the fingerprint were reduced in size or deleted
completely.
Step by Step Filtering:
(a) Noisy image.
(b) Structuring element.
(c) Eroded image.
(d) Opening of A.
(e) Dilation of the opening.
(f) Closing of the opening.

49
49
Filtering by Opening and Closing Operation
The two operations just described constitute the opening of A by B.
We note In Fig (d) that the net effect of opening was to eliminate
virtually all noise components in both the background and the
Fingerprint itself. However, new gaps between the fingerprint ridges
were created.
To counter this undesirable effect, we perform a dilation on the opening,
as shown in Fig.(e).
Most of the breaks were restored, but the ridges were thickened, a
condition that can be remedied by erosion.
The result, shown in Fig. (f), constitutes the closing of the opening in
Fig. (d).This final result is remarkably clean of noise specks, but it has
the disadvantage that some of the print ridges were not fully repaired,
and thus contain breaks. This is not totally unexpected, because no
conditions were built into the procedure for maintaining connectivity
this can be solved by skeleton concept.
50
50
Use of opening and closing for morphological
filtering

51
51
Gray-scale Morphology
In grayscale morphology is applied to gray scale images, a pixel is compared to those
pixels surrounding it in order to keep the pixels whose values are the smallest (in the
case of an erosion) or the largest (in the case of a dilation).
The basic morphological operations of dilation, erosion, opening and closing can also be
applied to gray images.
Use grayscale morphology functions used to
▪ filter or smooth the pixel intensities of an image. Applications include noise filtering, uneven
background correction, and gray-level feature extraction.
▪ alter the shape of regions by expanding bright areas at the expense of dark areas and vice
versa.
▪ smooth gradually varying patterns and increase the contrast in boundary areas.
The following gray-level morphology functions are applied in image processing:
▪ Erosion
▪ Dilation
▪ Opening
▪ Closing
▪ Proper-opening
▪ Proper-closing Reading Assignment
▪ Auto-median
52
52
Gray-scale Dilation
The gray-scale dilation of a gray-scale image f by a structure element b is defined as:

where Db is the domain of the structuring element b. This process operates in the same way
as the spatial convolution.
The figure below shows the result of dilating a gray image using a 3×3b square
structuring element.
We can see that gray-scale dilation produces the following: 1. Bright and slightly blurred image. 2.
Small, dark details have been reduced.

53
53
(a) Original gray image. (b) Dilated image.
Gray-scale Erosion
The gray-scale erosion of a gray-scale image f by a structure element b is defined as:

The next figure shows the result of eroding a gray image using a 3×3 square structuring
element.
We can see that gray-scale erosion produces the following:1. Dark image. 2. Small, bright details
were reduced.

54
54
((a) Original gray image. (b) Eroded image.
Gray-scale Opening
The opening and closing of gray-scale images have the same form as in
the binary images:
▪ Opening :
▪ Closing:
The figure below shows the result of opening a gray image.
Note the decreased sizes of the small, bright details, with no appreciable effect on the
darker gray levels.

55
55
(a) Original gray image. (b) Opened image.
Gray-scale Closing
The opening and closing of gray-scale images have the same form as in
the binary images:
▪ Opening :
▪ Closing:
The figure below shows the result of closing a gray image.
Note the decreased sizes of the small, dark details, with relatively little effect on the
bright features.

56
56
(a) Original gray image. (b) Closed image.
Gray-Scale Morphology Applications
Morphological smoothing
Smoothing is obtained by performing a morphological opening
followed by a closing as shown in the figure below.

(a) Original gray image. (b) Morphological smoothed image.

57
57
Gray-Scale Morphology Applications..cont
Morphological gradient
is produced from subtracting an eroded image from its dilated version.
It is defined as:
The resulted image has edge-enhancement characteristics, thus morphological gradient
can be used for edge detection as shown in the figure below.

58
58
(a) Original gray image. (b) Morphological gradient.
Basic Morphological Algorithms
1. Boundary Extraction
2. Region Filling
3. Extraction of Connected Components
4. Convex Hull
5. Thinning
Reading Assignment
6. Thickening
7. Skeletons

59
Boundary Extraction
First, erode Aby B, then make set difference between A and
the erosion
The thickness of the contour depends on the size of
constructing object – B

60
Boundary Extraction

61
Region Filling
This algorithm is based on a set of dilations,
complementation and intersections
p is the point inside the boundary, with the value of 1
X(k) = (X(k-1) xor B) conjunction with complemented A
The process stops when X(k) = X(k-1)
The result that given by union of Aand X(k), is a set contains
the filled set and the boundary

62
Region Filling

63
Extraction of Connected Components

This algorithm extracts a component by selecting a point on a


binary object A
Works similar to region filling, but this time we use in the
conjunction the object A, instead of it’s complement

64
Extraction of Connected Components

65
End of Chapter 3

66

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