dilate函数
函数的调用形式:
void
dilate
(
InputArray
src
, OutputArray
dst
, InputArray
kernel
, Point
anchor
=Point(-1,-1), int
iterations
=1, int
borderType
=BORDER_CONSTANT, const Scalar&
borderValue
=morphologyDefaultBorderValue()
)
函数参数的详解:
src:原图像。
dst:目标图像。
element:腐蚀操作的内核。 如果不指定,默认为一个简单的 矩阵。否则,我们就要明确指定它的形状,可以使用函数getStructuringElement().
anchor:默认为Point(-1,-1),内核中心点。省略时为默认值。
iterations:腐蚀次数。省略时为默认值1。
borderType:推断边缘类型,具体参见borderInterpolate函数。默认为BORDER_DEFAULT,省略时为默认值。
borderValue:边缘值,具体可参见createMorphoogyFilter函数。可省略。
函数的含义:
使用腐蚀操作中的核,对相应的像素进行相乘,取最大的乘积
The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken:
opencv代码:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
Mat img = imread("d:6.jpg");
Mat dst(img.size(),8,1);
cvtColor(img, img, CV_BGR2GRAY);
threshold(img, img, 100, 255, CV_THRESH_BINARY);
dilate(img, dst, NULL, Point(-1, -1), 10, BORDER_DEFAULT, Scalar(0, 0, 255));
namedWindow("shiyan");
imshow("shiyan", dst);
waitKey(0);
return 0;
}
实验结果: