Start » Filter Reference » OpenCV » Image Filtering » cvMorphologyEx

cvMorphologyEx


Module: OpenCV

Performs advanced morphological transformations.

Name Type Range Description
Input value
inSrc Image Source image.
Input value
inOp CvMorphologicalOperation Type of a morphological operation.
Input value
inElement Region Structuring element.
Input value
inAnchor Location* Anchor position within the element. The NIL value means that the anchor is at the center.
Input value
inIterations Integer 0 - Number of times erosion and dilation are applied.
Input value
inBorderType CvBorderType Pixel extrapolation method.
Input value
inBorderValue Pixel* Border value in case of a constant border.
Output value
outDst Image Output image.

Description

Operation can perform advanced morphological transformations on image using an erosion and dilation as basic operations.

Opening operation:

Closing operation:

Morphological gradient:

"Top hat":

"Black hat":

Examples

cvMorphologyEx performed on sample image with inOp = MORPH_GRADIENT, inIterations = 1, inBorderType = BORDER_REPLICATE.

Errors

This filter can throw an exception to report error. Read how to deal with errors in Error Handling.

List of possible exceptions:

Error type Description
DomainError Input image must have pixel type different from Int8 and Int32 in cvMorphologyEx.
DomainError Input image must not be empty in cvMorphologyEx.

Complexity Level

This filter is available on Basic Complexity Level.