# Mathematical Morphology Mathematical Morphology in image processing is used to extract image components for representation and description of region shape, such as boundaries, skeletons, and the convex hull. A _structuring element_ is a shape mask (box, hexagon, disk etc) used in the basic morphological operations. They can be any shape and size that is digitally representable, and each has an origin. ## Dilation Dilation expands the connected sets of 1 s of a binary image. It can be used for 1. growing features ![[dilation1.jpg]] 2. filling holes and gaps ![[dilation2.jpg]] Example: Edge Detection 1. Dilate input image 2. Subtract input image from dilated image 3. Edges remain! ![[dilation-edge.jpg]] ## Erosion Erosion shrinks the connected sets of 1 s of a binary image. It can be used for 1. shrinking features 2. Removing bridges, branches and small protrusions Example: Erosion with Structuring Element of 3x3 matrix of ones. ![[erosion.jpg]] ## Opening and Closing - Closing (the background) is the compound operation of dilation followed by erosion (with the same structuring element) - Opening (the background) is the compound operation of erosion followed by dilation (with the same structuring element) - Usually applied to binary images, with structuring element containing only ones. Example: Opening with 11 pixel diameter disc ![[opening-disc.jpg]] Example: Closing with 22 pixel disc, closes small holes in the foreground ![[closing.jpg]] --- ## References