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:
In this article, we will be discussing Erosion.
- Erosion shrink-ens the image pixels i.e. it is used for shrinking of element A by using element B.
- Erosion removes pixels on object boundaries.:
- The value of the output pixel is the minimum value of all the pixels in the neighborhood. A pixel is set to 0 if any of the neighboring pixels have the value 0.
- 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 an 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 the neighborhood.
- If the value of neighborhood pixel is 0, then change the value of that pixel to 0.
Below is the Matlab code for Erosion:
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.
- Erosion and Dilation of images using OpenCV in python
- Difference between Dilation and Erosion
- MATLAB | RGB image to grayscale image conversion
- MATLAB | Converting a Grayscale Image to Binary Image using Thresholding
- Extract bit planes from an Image in Matlab
- Image Processing in MATLAB | Fundamental Operations
- MATLAB | RGB image representation
- MATLAB | Complement colors in a Binary image
- MATLAB | Complement colors in RGB Image
- MATLAB | Complement colors in a Grayscale Image
- MATLAB | Display histogram of a grayscale Image
- LSB based Image steganography using MATLAB
- Display the red, green and blue color planes of a color image in MATLAB
- Image Complement in Matlab
- Image Resizing in Matlab
- Flip image across Secondary Diagonal in MATLAB
- Matlab | Edge Detection of an image without using in-built function
- Matlab | Dilation of an Image
- Create Mirror Image using MATLAB
- How to vertically flip an Image using MATLAB
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.