为掩膜
表示图像在(i,j)位置的像素
代表图像经过掩膜操作
双边模糊:(基于高斯模糊)
#include<opencv2\opencv.hpp>
#include<iostream>
#include<math.h>
using namespace std;
using namespace cv;
//模糊原理
int main()
{Mat src = imread("E:\\vs2015\\opencvstudy\\1.jpg", 1);if (src.empty()){cout << "could not load the src image!" << endl;return -1;}char input_title[] = "input Image";imshow(input_title, src);//简单模糊Mat dst_blur;blur(src, dst_blur, Size(3, 3), Point(-1, -1));imshow("blur_image", dst_blur);//高斯滤波Mat dst_gaussian;GaussianBlur(src, dst_gaussian, Size(11, 11), 11, 11);imshow("gaussian Blur", dst_gaussian);//中值滤波Mat dst_median; //去掉椒盐噪声medianBlur(src, dst_median, 3);imshow("medianBlur", dst_median);//双边滤波 效果较好Mat dst_bilateral;bilateralFilter(src, dst_bilateral, 15, 100, 5);imshow("bilateral Blur", dst_bilateral);//双边滤波+filter2D 效果最好Mat dst_filter2D;Mat kernal = (Mat_<int>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);filter2D(dst_bilateral, dst_filter2D, -1, kernal, Point(-1, -1), 0);imshow("filter2D", dst_filter2D);waitKey(0);return 0;
}