Morphology treats a binary image as a set of foreground pixels. Dilation adds pixels to the boundary wherever the structuring element touches the foreground, so bright regions grow. Erosion removes boundary pixels wherever the element is not fully contained, shrinking bright regions.
Dilation and erosion and their derived operationsOpening is erosion followed by dilation: it removes small bright specks and thin bridges while preserving overall size. Closing is dilation followed by erosion: it fills small holes and gaps while preserving overall size.
Iterations compound
Each iteration repeats the operation with the previous result as input. Two iterations of erosion remove a two-pixel rim, so small features disappear after enough iterations.