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; }
实验结果: