1. 方框滤波
代码如下:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
// "/mnt/hgfs/code_for_Linux/code_opencv/test1/pic/"
int main()
{
Mat srcImage = imread("/mnt/hgfs/code_for_Linux/code_opencv/test1/pic/1.jpg");
if (!srcImage.data) {
return -1;
}
imshow("[原图]", srcImage);
Mat out;;
boxFilter(srcImage, out, -1, Size(5, 5));
imshow("[效果图]", out);
waitKey(0);
return 0;
}
效果如图所示,确实模糊了很多:
2. 均值滤波
代码如下:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
// "/mnt/hgfs/code_for_Linux/code_opencv/test1/pic/"
int main()
{
Mat srcImage = imread("/mnt/hgfs/code_for_Linux/code_opencv/test1/pic/1.jpg");
if (!srcImage.data) {
return -1;
}
imshow("[原图]", srcImage);
Mat out;
blur(srcImage, out, Size(7, 7));
imshow("[效果图]", out);
waitKey(0);
return 0;
}
效果,感觉和方框滤波差不多,额
3. 高斯滤波
代码如下:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
// "/mnt/hgfs/code_for_Linux/code_opencv/test1/pic/"
int main()
{
Mat srcImage = imread("/mnt/hgfs/code_for_Linux/code_opencv/test1/pic/1.jpg");
if (!srcImage.data) {
return -1;
}
imshow("[原图]", srcImage);
Mat out;
GaussianBlur(srcImage, out, Size(7, 7), 0, 0);
imshow("[效果图]", out);
waitKey(0);
return 0;
}
效果还是差不多啊
-----------