# Contents

Dilation - grow image regions

Erosion - shrink image regions

Opening - structured removal of image region boundary pixels

Closing - structured filling in of image region boundary pixels

Hit and Miss Transform - image pattern matching and marking

Thinning - structured erosion using image pattern matching

Thickening - structured dilation using image pattern matching

Skeletonization/Medial Axis Transform - finding skeletons of binary regions

Morphological operators often take a binary image and a structuring element as input and combine them using a set operator (intersection, union, inclusion, complement). They process objects in the input image based on characteristics of its shape, which are encoded in the structuring element. The mathematical details are explained in Mathematical Morphology.

Usually, the structuring element is sized 3×3 and has its origin at the center pixel. It is shifted over the image and at each pixel of the image its elements are compared with the set of the underlying pixels. If the two sets of elements match the condition defined by the set operator (e.g. if the set of pixels in the structuring element is a subset of the underlying image pixels), the pixel underneath the origin of the structuring element is set to a pre-defined value (0 or 1 for binary images). A morphological operator is therefore defined by its structuring element and the applied set operator.

For the basic morphological operators the structuring element contains only foreground pixels (i.e. ones) and `don't care's'. These operators, which are all a combination of erosion and dilation, are often used to select or suppress features of a certain shape, e.g. removing noise from images or selecting objects with a particular direction.

The more sophisticated operators take zeros as well as ones and `don't care's' in the structuring element. The most general operator is the hit and miss, in fact, all the other morphological operators can be deduced from it. Its variations are often used to simplify the representation of objects in a (binary) image while preserving their structure, e.g. producing a skeleton of an object using skeletonization and tidying up the result using thinning.

Morphological operators can also be applied to graylevel images, e.g. to reduce noise or to brighten the image. However, for many applications, other methods like a more general spatial filter produces better results.