Morphology is known as the broad set of image processing operations that process images based on the shapes. It is also known as a tool used for extracting image components that are useful in representation and description of region shape.
The basic morphological operations are:
- Dilation expands the image pixels i.e. it is used for expanding an element A by using structuring element B.
- Dilation adds pixels to object boundaries.
- The value of the output pixel is the maximum value of all the pixels in the neighborhood. A pixel is set to 1 if any of the neighboring pixels have the value 1.
- Read the RGB image.
- Using function im2bw(), convert the RGB image to binary image.
- Create a structuring element or you can use any predefined mask eg. fspecial(‘sobel’).
- Store the number of rows and columns in and array and loop through it.
- Create a zero matrix of the size same as of the size of our image.
- Leaving the boundary pixels start moving the structuring element on the image and start comparing the pixel with the pixels present in neighborhood.
- If the value of neighborhood pixel is 1, then change the value of that pixel to 1.
Below is the Matlab code for Dilation :
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.