dilate函数
dilate函數
函數的調用形式: void?dilate(InputArray?src, OutputArray?dst, InputArray?kernel, Point?anchor=Point(-1,-1), int?iterations=1, intborderType=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; }實驗結果:
總結
- 上一篇: copyMakeBorder函数
- 下一篇: 二值化函数Threshold