0% found this document useful (0 votes)
54 views4 pages

Expt 8 Morphssp

This document describes an experiment to apply morphological operations like erosion and dilation on images. It defines morphological operations as affecting the form and structure of objects. Erosion shrinks objects by eroding away pixel boundaries, while dilation expands objects by filling in small holes. The document provides algorithms to perform erosion and dilation on binary images using structuring elements of different shapes. Opening and closing operations, which combine erosion and dilation, are also introduced.

Uploaded by

Shubham
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)
54 views4 pages

Expt 8 Morphssp

This document describes an experiment to apply morphological operations like erosion and dilation on images. It defines morphological operations as affecting the form and structure of objects. Erosion shrinks objects by eroding away pixel boundaries, while dilation expands objects by filling in small holes. The document provides algorithms to perform erosion and dilation on binary images using structuring elements of different shapes. Opening and closing operations, which combine erosion and dilation, are also introduced.

Uploaded by

Shubham
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/ 4

Dr. D. Y.

Patil Group of Institutions’ Technical Campus


Dr. D. Y. PATIL SCHOOL OF ENGINEERING
Dr. D. Y. Patil Knowledge City, Charholi Bk., Via. Lohegaon, Pune – 412 105.
Department of Electronics and Telecommunication Engineering

EXPERIMENT NO.8

To apply morphological operators on an image..

Date of Performance
Date of Checking

Digital Image and Video Processing Lab BE E&TC (2015 course) Sem-I
Dr. D. Y. Patil Group of Institutions’ Technical Campus
Dr. D. Y. PATIL SCHOOL OF ENGINEERING
Dr. D. Y. Patil Knowledge City, Charholi Bk., Via. Lohegaon, Pune – 412 105.
Department of Electronics and Telecommunication Engineering

Title: To apply morphological operators on an image.


Objectives:
1. To study and apply morphological operations
Aim: To perform morphological operation such as erosion & dilation on given image.
Software: MATLAB / Scilab.

Theory:

Morphological operations on binary images


Morphological operations are affecting the form, structure or shape of an object. Applied on
binary images (black & white images -Images with only 2 colors: black and white). They are
used in pre or post processing (filtering, thinning, and pruning) or for getting a
representation or description of the shape of objects/regions (boundaries, skeletons
convex hulls).

Theoretical considerations:
The two principal morphological operations are dilation and erosion. Dilation allows
objects to expand, thus potentially filling in small holes and connecting disjoint objects.
Erosion shrinks objects by etching away (eroding) their boundaries. These operations can
be customized for an application by the proper selection of the structuring element, which
determines exactly how the objects will be dilated or eroded.

Notations:
Black pixel: in grayscale values for a 8 bits/pixel indexed image its value will be 0.
White pixel: in grayscale values for a 8 bits/pixel indexed image its value will be 255.

Dilation:
The dilation process is performed by laying the structuring element B on the image A and
sliding it across the image in a manner similar to convolution. The difference is in the
operation performed. It is best described in a sequence of steps:
1. If the origin of the structuring element coincides with a 'white' pixel in the image, there is
no change; move to the next pixel.
2. If the origin of the structuring element coincides with a 'black ' in the image, make black
all pixels from the image covered by the structuring element.
Notation: A ⊕ B

The structuring element can have any shape. Typical shapes are presented below:

Digital Image and Video Processing Lab BE E&TC (2015 course) Sem-I
Dr. D. Y. Patil Group of Institutions’ Technical Campus
Dr. D. Y. PATIL SCHOOL OF ENGINEERING
Dr. D. Y. Patil Knowledge City, Charholi Bk., Via. Lohegaon, Pune – 412 105.
Department of Electronics and Telecommunication Engineering

Fig. 1 Typical shapes of the structuring elements (B)

Erosion:
The erosion process is similar to dilation, but we turn pixels to 'white ', not ' black '. As
before, slide the structuring element across the image and then follow these steps:
1. If the origin of the structuring element coincides with a 'white' pixel in the image, there is
no change; move to the next pixel.
2. If the origin of the structuring element coincides with a 'black' pixel in the image, and at
least one of the’ black' pixels in the structuring element falls over a white pixel in the image,
then change the 'black' pixel in the image (corresponding to the position on which the
center of the structuring element falls) from ‘black’ to a 'white'.
Notation: AΘB

Opening and Closing


These two basic operations, dilation and erosion, can be combined into more
complex sequences. The most useful of these for morphological filtering are called opening
and closing. Opening consists of an erosion followed by a dilation and can be used to
eliminate all pixels in regions that are too small to contain the structuring element. In this
case the structuring element is often called a probe, because it is probing the image looking
for small objects to filter out of the image.
Notation: A◦B = (AΘB) ⊕ B
Closing consists of a dilation followed by erosion and can be used to fill in holes and
small gaps. The order of operation is important. Closing and opening will generate different
results even though both consist of erosion and dilation
Notation: A•B = (A⊕B) ΘB

Algorithm:
A) Erosion:

Digital Image and Video Processing Lab BE E&TC (2015 course) Sem-I
Dr. D. Y. Patil Group of Institutions’ Technical Campus
Dr. D. Y. PATIL SCHOOL OF ENGINEERING
Dr. D. Y. Patil Knowledge City, Charholi Bk., Via. Lohegaon, Pune – 412 105.
Department of Electronics and Telecommunication Engineering

1) Start
2) Read the image
3) Convert it into black & white
4) Obtain the size of the image.
5) Accept the mask with which u want to perform erosion
6) Find the total weight of the mask using cumulative addition of matrix elements.
7) Using the inbuilt function “imread” get the eroded image.
8) Display the eroded image.
9) Create a matrix of zeros of size of image.
10)Initialize ‘4 nested for’ loops the outer 2 for loop for the image dimensions &
inner 2 for the mask.
11)Check the neighborhood pixel to be in subset of the image if yes then add it to
the subset according to definition.
12) If the neighborhood pixel is not in the subset then do not include that pixel.
13)Display the image.
14)End.
B) Dilation:
1) Start
2) Read the image
3) Convert it into black & white
4) Obtain the size of the image.
5) Input the mask
6) Using inbuilt function ‘immediate’ get the dilated image.
7) Display the dilated image.
8) Create a matrix of zeros of size of image.
9) Initialize ‘4 nested for’ loops the outer 2 for loop for the image dimensions &
inner 2 for the mask.
10) If the pixel is not subset include it in the subset.
11)Display the dilated image & compare it with the one plotted using inbuilt
function.
12)End.
Conclusion:

Digital Image and Video Processing Lab BE E&TC (2015 course) Sem-I

You might also like