Dilation and erosion are two fundamental morphological operators. Erosion removes a pixel layer from the foreground (white) objects' boundaries and thereby shrinks the foreground in a binary image. The small-scale details get removed and the size of the regions of interest gets reduced by erosion in a binary image. On the other hand, dilation adds a pixel layer to the foreground objects' boundaries thereby expanding the foreground. The holes contained inside a single foreground object and gaps in between foreground objects (and boundaries) are reduced.
Many morphological operations can be obtained as combinations of erosion, dilation, and basic set operations (for example, complement). Morphological opening, closing, and hit-or-miss transform are the most popular ones. Opening is an idempotent operation (implemented...