Back to Adaptive Vision Studio website
You are here: Start » Filter Reference » Image Filtering » cvMorphologyEx
Performs advanced morphological transformations.
| Name | Type | Range | Description | |
|---|---|---|---|---|
![]() |
inSrc | Image | Source image. | |
![]() |
inOp | CvMorphologicalOperation | Type of a morphological operation. | |
![]() |
inElement | Region | Structuring element. | |
![]() |
inAnchor | Location* | Anchor position within the element. The NIL value means that the anchor is at the center. | |
![]() |
inIterations | Integer | 0 - ![]() |
Number of times erosion and dilation are applied. |
![]() |
inBorderType | CvBorderType | Pixel extrapolation method. | |
![]() |
inBorderValue | Pixel* | Border value in case of a constant border. | |
![]() |
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 here: Error Handling
| Error type | Description |
|---|---|
| DomainError | Morphological operation can be MORPH_* except MORPH_ERODE and MORPH_DILATE in cvMorphologyEx. |
| 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.





