Expt 8 Morphssp
Expt 8 Morphssp
EXPERIMENT NO.8
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
Theory:
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
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
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