# Morphological Operations

Grey-scale morphology is the process of applying a simple operator to successive neighborhoods of pixels within an image. The operators supplied with the Blob tool allow you to substitute for each pixel in an image either the minimum pixel value or the maximum pixel value within a specific neighborhood of that pixel. Each of the neighborhoods and operators is listed in the following table, along with the typical use for the operation, and an idealized representation of the effect of the operation on an image.

Note: Keep in mind that the morphological operators consider object and background pixels. Which image pixels become object pixels and which become background pixels depends on the segmentation parameters that you specify. The morphological operations always interpret white pixels as object and black pixels as background.

Name | Neighborhood and Operator | Used To | Example
--- | --- | --- | ---
Horizontal dilation (eMaxH) | Replace each pixel in the image with the maximum value of the pixel and each of its two horizontal neighbors: | Reduce or eliminate vertically shaped holes within objects, increasing the thickness of vertically shaped object features. |
Horizontal erosion (eMinH) | Replace each pixel in the image with the minimum value of the pixel and each of its two horizontal neighbors: | Reduce or eliminate vertically shaped object features, increasing the thickness of vertically shaped holes within objects. |
Vertical dilation (eMaxV) | Replace each pixel in the image with the maximum value of the pixel and each of its two vertical neighbors: | Reduce or eliminate horizontally shaped holes within objects, increasing the thickness of horizontally shaped object features. |
Vertical erosion (eMinV) | Replace each pixel in the image with the minimum value of the pixel and each of its two vertical neighbors: | Reduce or eliminate horizontally shaped object features, increasing the thickness of horizontally shaped holes within objects. |
Square dilation (eMaxS) | Replace each pixel in the image with the maximum value of the pixel and each of its eight vertical and horizontal neighbors: | Reduce or eliminate holes within objects, increasing the thickness of object features. |
Square erosion (eMinS) | Replace each pixel in the image with the minimum value of the pixel and each of its eight vertical and horizontal neighbors: | Reduce or eliminate object features, increasing the thickness of holes within objects. |
Horizontal opening (eMaxMinH) | A horizontal erosion is applied to the image, followed by a horizontal dilation. | Preserve vertically shaped holes within objects, while eliminating vertically shaped object features. |
Horizontal closing (eMinMaxH) | A horizontal dilation is applied to the image, followed by a horizontal erosion. | Preserve vertically shaped features within objects, while eliminating vertically shaped holes within objects. |
Vertical opening (eMaxMinV) | A vertical erosion is applied to the image, followed by a vertical dilation. | Preserve horizontally shaped holes within objects, while eliminating horizontally shaped object features. |
Vertical closing (eMinMaxV) | A vertical dilation is applied to the image, followed by a vertical erosion. | Preserve horizontally shaped features within objects, while eliminating horizontally shaped holes within objects. |
Square opening (eMaxMinS) | A square erosion is applied to the image, followed by a square dilation. | Preserve holes within objects, while eliminating small object features. |
Square closing (eMinMaxS) | A square dilation is applied to the image, followed by a square erosion. | Preserve small features within objects, while eliminating holes within objects. |