#include "mainwindow.h"
#include <QApplication>
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//加载图形
Mat src = imread("E:/QTimage/6.jpg");
if(!src.data){
cout<< "can't load image ..."<< endl;
return -1;
}
imshow("src",src);
//中值模糊
Mat mediaBlurMat;
medianBlur(src,mediaBlurMat,9);
imshow("mediaBlurMat",mediaBlurMat);
//高斯双边滤波
Mat bilateralMat;
/**
* 双边滤波参数说明:
* 15--->计算半径,半径之内的都会被纳入计算,如果提供-1则根据sigma space参数进行计算
* 100--->sigma color 决定多少差值之内的像素会被计算
* 5----->sigma space 如果d的值大于0则申明无效,否则根据他来计算d的值
**/
bilateralFilter(src,bilateralMat,15,50,5);
imshow("bilateralMat",bilateralMat);
//对双边滤波后的图像执行锐化操作,提升图片的棱角以及清晰度
Mat resultImage;
Mat kernel = (Mat_<int>(3,3)<< 0, -1, 0, -1, 5, -1, 0, -1, 0);
filter2D(bilateralMat,resultImage,-1,kernel,Point(-1,-1),0);
imshow("resultImage",resultImage);
waitKey(0);
//return 0;
return a.exec();
}标签:src,模糊,Mat,resultImage,mediaBlurMat,imshow,bilateralMat From: https://www.cnblogs.com/dq0618/p/17135630.html