opencv——图像模糊
图像模糊(所谓模糊,可以理解成每一个像素都取周边像素的平均值)是在给图像做预处理时,降低图像噪声,例如:在大目标支取之前,去除图像的一些琐碎细节。
这里的噪声与物理学中的噪声不大相同。应该找时间去查找资料理解一下。
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{
Mat src;
src=imread("图片位置");
if(!src.data)
{
prinft("could not the picture");
}
//图像模糊有一下几种
//高斯模糊
Mat dst;
dst=Mat(src,size(),src.type());
GaussianBlur (src,dst2,Size(3,3),3,3);//Size()吃一个矩阵,代表卷积核的大小
//归一化均值模糊
Mat dst2;
dst2=Mat(src.size(),src.type());
blur(src,dst2,Size(3,3));
//中值模糊
Mat dst3;
dst3=Mat(src.size(),src.type());
medianBlur(src,dst3,3);
//双边模糊
Mat dst4;
dst4=Mat(src.size(),src.type());
bilateralFilter (src,dst4,15,100,100);
waitKey(0);
return 0;
}
``
这里连接一个大佬的讲解[模糊详解](http://www.ruanyifeng.com/blog/2012/11/gaussian_blur.html)