dilate函数

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:腐蚀操作的内核。 如果不指定,默认为一个简单的 bubuko.com,布布扣 矩阵。否则,我们就要明确指定它的形状,可以使用函数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:

\texttt{dst} (x,y) =  \max _{(x',y'):  \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')



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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值