Performs advanced morphological transformations
dst = cv.morphologyEx(src, op)
dst = cv.morphologyEx(src, op, 'OptionName',optionValue, ...)
Input
- src Source image. The number of channels can be arbitrary. The depth
should be one of
uint8
, uint16
, int16
, single
or double
.
- op Type of a morphological operation that can be one of the following:
- Erode see cv.erode
- Dilate see cv.dilate
- Open an opening operation
dst = open(src,element) = dilate(erode(src,element))
- Close a closing operation
dst = close(src,element) = erode(dilate(src,element))
- Gradient a morphological gradient
dst = morph_grad(src,element) = dilate(src,element) - erode(src,element)
- Tophat "top hat"
dst = tophat(src,element) = src - open(src,element)
- Blackhat "black hat"
dst = blackhat(src,element) = close(src,element) - src
- HitMiss "hit and miss". Only supported for
uint8
1-channel
binary images. Tutorial can be found in this page
http://opencv-code.com/tutorials/hit-or-miss-transform-in-opencv/
Output
- dst Destination image of the same size and type as source image.
Options
- Element Structuring element kernel. It can be created using
cv.getStructuringElement. Empty by default, which uses a 3x3
rectangular structuring element by default.
- Anchor Position of the anchor within the element. The default value
[-1,-1] means that the anchor is at the element center.
- Iterations Number of times erosion and dilation are applied. default 1
- BorderType Pixel extrapolation method. default 'Constant'
- BorderValue Border value in case of a constant border. The default
value has a special meaning. See cv.dilate and cv.erode for details.
The function cv.morphologyEx can perform advanced morphological
transformations using an erosion and dilation as basic operations.
In case of multi-channel images, each channel is processed independently.