7: Morphological Operations

Similar to Spatial filters, Morphological operations use neighboring pixels to transform pixel intensities that reduce/increase the size of the focus in a “filter” or structuring element. These operations are useful for cleaning images. There are different functions under this operation such as erosion (chipping off), dilation (adding pixels), closing (dilation and then erosion), opening (opposite of closing), area_closing/opening, skeletonize, etc.


Using a cross structuring element to erode a circular image looks for the structuring element (selem) and removes middle point of the structuring element overlapped on the image. Dilation can be used to recreate the original image from the morphed image. Running the operation iteratively and multiple times leads to a more eroded or dilated image.


Above is an example of dilation where additional points are added to the original image to create another one.

Different Morphological Operations

Morphological Operations can be used to close images with lines with gaps, extract only the horizontal/vertical lines or circles.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nisarg Nigam

Nisarg Nigam

MS Data Science student at Asian Institute of Management