函数原型
CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst,
int op, InputArray kernel,
Point anchor = Point(-1,-1), int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar& borderValue = morphologyDefaultBorderValue() );
/** @brief Performs advanced morphological transformations.
The function morphologyEx can perform advanced morphological transformations using an erosion and dilation as
basic operations.
Any of the operations can be done in-place. In case of multi-channel images, each channel is
processed independently.
@param src Source image. The number of channels can be arbitrary. The depth should be one of
CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
@param dst Destination image of the same size and type as source image.
@param op Type of a morphological operation, see cv::MorphTypes
@param kernel Structuring element. It can be created using cv::getStructuringElement.
@param anchor Anchor position with the kernel. Negative values mean that the anchor is at the
kernel center.
@param iterations Number of times erosion and dilation are applied.
@param borderType Pixel extrapolation method, see cv::BorderTypes
@param borderValue Border value in case of a constant border. The default value has a special
meaning.
@sa dilate, erode, getStructuringElement
*/
参数解释
代号 |
含义 |
作用 |
0 |
MORPH_ERODE |
腐蚀运算(Erode operation) |
1 |
MORPH_DILATE |
膨胀运算(Dilate operation) |
2 |
MORPH_OPEN |
开运算(Opening operation) |
3 |
MORPH_CLOSE |
闭运算(Closing operation) |
4 |
MORPH_GRADIENT |
形态学梯度(Morphological gradient) |
5 |
MORPH_TOPHAT |
“顶帽”(Top hat) |
6 |
MORPH_BLACKHAT |
“黑帽”(Black hat) |
7 |
MORPH_HITMISS |
|
- kernel:核(用于膨胀操作的结构元素),可使用getStructuringElement()方法创建
- anchor:锚点坐标,为负代表核的中心坐标
- iterations:迭代次数
- borderType:像素外推方法,具有默认值 BORDER_CONSTANT
- borderValue:边界为常数时的边界值,有默认值morphologyDefaultBorderValue()
例子
opencv形态学操作函数morphologyEx
morphologyEx(形态学操作)
相关函数
opencv getStructuringElement函数 图形学运算前获得kernel元素
参考博客