高斯噪声
的抑制较好,处理后的图像边缘模糊较少,但对 椒盐噪声
的影响不大,这是因为在消弱噪声的同时图像总体的特征也变得模糊,其噪声仍然存在。
看一下源码中对cv::blur的声明和描述
CV_EXPORTS_W void blur(InputArray src, OutputArray dst,Size ksize, Point anchor=Point(-1, -1),int borderType=BORDER_DEFAULT);
//blur和归一化下的方框滤波效果是一样
The call `blur(src, dst, ksize, anchor, borderType)` is equivalent to `boxFilter(src, dst, src.type(), ksize,
anchor, true, borderType)`.
//输入矩阵可以有任意的通道数,各通道单独处理,但是深度必须是CV_8U,CV_16U,CV_16S,CV_32F,CV_64F这些类型中的一种
@param src input image; it can have any number of channels, which are processed independently, but
the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
//输出矩阵要和src拥有相同的尺寸和类型
@param dst output image of the same size and type as src.
//滤波核的尺寸,值越大越模糊
@param ksize blurring kernel size.
//目标点位于核的中心点
@param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel
center.
@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported.
#include
#include
using namespace std;
using namespace cv;
int main() {
Mat img, clone_img;
img = imread("D:/cat.jpg", IMREAD_COLOR);
if (img.empty()) {
return -1;
}
clone_img = img.clone();
double scale = 0.5;
int width = int(clone_img.cols * scale);
int height = int(clone_img.rows * scale);
resize(clone_img, clone_img, Size(width, height), 0, 0, INTER_AREA);
Mat dst = Mat::zeros(Size(width, height), clone_img.type());
blur(clone_img, dst, Size(5, 5), Point(-1, -1));
imshow("clone_img", clone_img);
imshow("dst", dst);
waitKey(0);
return 0;
}
效果显示