Applying morphological transformations to images
Morphological operations are mathematical in nature and they change the shape of an image. These operations can best be demonstrated visually with binary images. We can apply morphological operations to eliminate a lot of unnecessary information, such as noise, in an image. A morphological operation accepts an image and a kernel as inputs. We will create a custom binary image as a binary image since this is the most suitable way to visually demonstrate morphological operations.
The mathematical morphological operation of erosion contracts the boundaries in an image. In a binary image, the white part is considered the foreground and the black part is considered the background. The erosion operation sets all the pixels on the boundary of the background part that is white to black, thus effectively shrinking the white region. Morphological dilation is the exact opposite of the erosion operation. It adds the white pixels near the boundary...