Experiment 5: Digital
Experiment 5: Digital
Experiment 5
Title: Digital Image Processing and Analysis using MATLAB
MATLAB.
Theory:
This lab experiment consists of five parts. Write in short on Part 1, 2 3 and 5.
Read fourth part and implement on suitable image.
Morphological operations: including erosion, dilation, opening, closing and Users can arbitrarily
choose one of the morphological operations
Structuring Element (SE):
SE size: users can dynamically change the SE size through moving the slider.
SE type: there are 3 types of SE which are implemented in the program, including diamond,
square and octagon. Users can dynamically change SE type through the pop-up menu.
User-defined SE: users can arbitrarily change the SE through pressing the mouse button. When
users press the specific radio button, MorphPic will show the corresponding resultant
morphological operations on the original picture.
Erosion:
The basic idea of erosion is just like soil erosion only, it erodes away the boundaries of
foreground object (Always try to keep foreground in white). The kernel slides through the image
(as in 2D convolution). A pixel in the original image (either 1 or 0) will be considered 1 only if
all the pixels under the kernel is 1, otherwise it is eroded (made to zero).All the pixels near
boundary will be discarded depending upon the size of kernel. So the thickness or size of the
foreground object decreases or simply white region decreases in the image. It is useful for
removing small white noises detach two connected objects.
Erosion Algorithm:
‘A’ is the original picture, ‘B’ is the structural element, and ‘C’ is the resultant picture of the
erosion of A with B. In Matlab, erosion can be implemented by a function, called ‘imerode’.
Dilation:
It is just opposite of erosion. Here, a pixel element is ‘1’ if at least one pixel under the kernel is
‘1’. So it increases the white region in the image or size of foreground object increases.
Normally, in cases like noise removal, erosion is followed by dilation. Because, erosion removes
white noises, but it also shrinks our object. So we dilate it. Since noise is gone, they won’t come
back, but our object area increases. It is also useful in joining broken parts of an object.
Dilation Algorithm:
‘C’, is the resultant picture of the dilation of ‘A’ with ‘B’. In Matlab, dilation can be
implemented by a function, called ‘imdilate’.
Opening is just another name of erosion followed by dilation. It is useful in removing noise,
as we explained above.
Opening Algorithm:
‘C’, is the resultant picture of the opening of A with B. The opening is to do erosion on A by B,
and then do dilation on A by B. In Matlab, opening can be implemented by a function, called
‘imopen’.
Closing is reverse of Opening, Dilation followed by Erosion. It is useful in closing small holes
inside the foreground objects, or small black points on the object. In Matlab, closing can be
implemented by a function, called ‘imclose’.
Closing Algorithm:
‘C’ is the resultant picture of the closing of A with B. The closing is to do dilation on A by B,
and then do erosion on A by B.
Algorithm:
1. Read the input image
2. Apply structure element on input image
3. Use the function for dilation, erosion, opening and closing.
4. Display the original image & output images.
Results:
Conclusion: