开运算:先腐蚀再膨胀的过程 dst = open(src,element) = dilate(erode(src,element))
闭运算:先膨胀再腐蚀的过程 dst = close(src,element) = erode(dilate(src,element))
形态学梯度:膨胀图与腐蚀图之差 dst = morph_grad(src,element) = dilate(src,element) - erode(src,element)
顶帽:原图与开运算之差 dst = tophat(src,element) = src - open(src,element)
黑帽:闭运算与原图之差 dst = blackhat(src,element) = colse(src,element) - src
形态学核心API: morephologyEx函数
void morphologyEx(InputArray src
OutputArray dst,
int op,
InputArray kernel,
Point anchor(-1,-1),
int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar& borderValue = morphologyDefaultBorderValue())
重点参数
参数3 op:形态学运算类型
//! type of morphological operation
enum {
MORPH_ERODE =CV_MOP_ERODE,
MORPH_DILATE =CV_MOP_DILATE,
MORPH_OPEN =CV_MOP_OPEN,
MORPH_CLOSE =CV_MOP_CLOSE,
MORPH_GRADIENT=CV_MOP_GRADIENT,
MORPH_TOPHAT =CV_MOP_TOPHAT,
MORPH_BLACKHAT=CV_MOP_BLACKHAT,
MORPH_HITMISS
};
闭运算:先膨胀再腐蚀的过程 dst = close(src,element) = erode(dilate(src,element))
形态学梯度:膨胀图与腐蚀图之差 dst = morph_grad(src,element) = dilate(src,element) - erode(src,element)
顶帽:原图与开运算之差 dst = tophat(src,element) = src - open(src,element)
黑帽:闭运算与原图之差 dst = blackhat(src,element) = colse(src,element) - src
形态学核心API: morephologyEx函数
void morphologyEx(InputArray src
OutputArray dst,
int op,
InputArray kernel,
Point anchor(-1,-1),
int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar& borderValue = morphologyDefaultBorderValue())
重点参数
参数3 op:形态学运算类型
//! type of morphological operation
enum {
MORPH_ERODE =CV_MOP_ERODE,
MORPH_DILATE =CV_MOP_DILATE,
MORPH_OPEN =CV_MOP_OPEN,
MORPH_CLOSE =CV_MOP_CLOSE,
MORPH_GRADIENT=CV_MOP_GRADIENT,
MORPH_TOPHAT =CV_MOP_TOPHAT,
MORPH_BLACKHAT=CV_MOP_BLACKHAT,
MORPH_HITMISS
};