#include <iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat dstImgBlur, dstImgGaussian, dstImgMedianBlur, dstBilateralFilter, filter2DImg;
Mat srcImg = imread("C:/Users/admin/Desktop/1.JPG");
if (!srcImg.data)
{
printf("没有找到");
}
namedWindow("srcImg window", CV_WINDOW_AUTOSIZE);
imshow("srcImg window", srcImg);
//blur(srcImg, dstImgBlur, Size(11, 11), Point(-1, -1));//均值滤波
//GaussianBlur(srcImg, dstImgGaussian, Size(11, 11), 11, 11);//高斯模糊
//namedWindow("dstImgGaussian window", CV_WINDOW_AUTOSIZE);
//imshow("dstImgGaussian window", dstImgGaussian);
//namedWindow("dstBlurImg window", CV_WINDOW_AUTOSIZE);
//imshow("dstBlurImg window", dstImgBlur);
medianBlur(srcImg, dstImgMedianBlur, 3);//中值模糊 可以有效的抑制噪声
bilateralFilter(srcImg, dstBilateralFilter, 15, 100, 3);//双边模糊
Mat kernel = (Mat_<int>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
filter2D(dstBilateralFilter, filter2DImg, -1, kernel, Point(-1, -1));//调整对比度
namedWindow("filter2DImg window", CV_WINDOW_AUTOSIZE);
imshow("filter2DImg window", filter2DImg);
namedWindow("dstBilateralFilter window", CV_WINDOW_AUTOSIZE);
imshow("dstBilateralFilter window", dstBilateralFilter);
namedWindow("dstImgMedianBlur window", CV_WINDOW_AUTOSIZE);
imshow("dstImgMedianBlur window", dstImgMedianBlur);
waitKey(0);
return 0;
}