Morphological transformations are operations that are normally performed on binary images and based on the image shape. The exact operation is determined by a kernel-structuring element, which decides the nature of the operation. Dilation and erosion are the two basic operators in the area of morphological transformations. Additionally, opening and closing are two important operations, which are derived from the two aforementioned operations (dilation and erosion). Finally, there are three other operations that based on the difference between some of these previous operations.
All of these morphological transformations are described in the following subsections, and the morphological_operations.py script shows the output when applying these transformations to some test images. The key points will also be commented on.