一、缩放函数
void blur( InputArray src,
OutputArray dst,
Size ksize,
Point anchor = Point(-1,-1),
int borderType = BORDER_DEFAULT );
第一个参数:输入图像
第二个参数:输出图像
第三个参数:均值滤波内核的尺寸
第四个参数:锚点,被平滑的那个点,默认值(-1,-1),表示锚点在核中心
第五个参数:用于推断图像外部像素的某种边界方式,默认值BORDER_DEFAULT
二、程序实现
1、code
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
//载入图像
Mat image = imread("C:\\Users\\zcc\\Desktop\\ghost.jpg");
if (!image.data) //Check for invalid input
{
cout << "Could not open or find the image" << endl;
return -1;
}
//创建窗口,显示原图
namedWindow("均值滤波原图");
imshow("均值滤波原图", image);
//进行滤波
Mat out;
blur(image, out, Size(7, 7));
namedWindow("均值滤波效果图");
imshow("均值滤波效果图", out);
waitKey(0);
return 0;
}
2、结果