在Opencv1.0中用于平滑处理的是:
void cvSmooth(const CvArr* src, CvArr* dst, int smoothtype = CV_GAUSSIAN, int param1 = 3, int param2 = 0, int param3 = 0, int param4 = 0);
smoothtype 各种类型是:
1、 CV_BLUR:简单模糊, 在以后高级版本中是:
C++: void blur(InputArray src, OutputArray dst, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT );
Parameters: |
|
---|
The function smoothes an image using the kernel:
The call blur(src, dst, ksize, anchor, borderType) is equivalent to boxFilter(src, dst, src.type(), anchor, true, borderType) .
其输出图像的每个像素是输入图像对应像素的简单平均。
2、CV_BLUR_NO_SCALE: 简单无缩放变换的模糊
它与 simple blur本质上是相同的,但并没有计算其平均值的造作, 不支持in place 方式:输入图像与输出图像必须不同(还没看懂)
3、CV_MEDIAN:中值滤波器
C++: void medianBlur(InputArray src, OutputArray dst, int ksize);
Parameters: |
|
---|
The function smoothes an image using the median filter with the aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported.
中值滤波器将中心像素的正方形邻域内的每个像素值用中间像素值替换。 简单模糊对噪声图像特别是有大的孤立点的图像非常敏感,即使有极少数量点存在较大差异也会导致平均值的明显波动,中值滤波可以选择中间值避免这些点的影响。
4、CV_GAUSSIAN:高斯滤波器
C++: void GaussianBlur(InputArray src, OutputArray dst, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT );
Parameters: |
|
---|
The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.
高斯滤波用卷积核与输入图像的每个点进行卷积,将最终计算结果之和作为输出图像的像素值。
5、CV_BILATERAL:双边滤波
C++: void bilateralFilter(InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT );
Parameters: |
|
---|
This filter does not work inplace.
Sigma values: For simplicity, you can set the 2 sigma values to be the same. If they are small (< 10), the filter will not have much effect, whereas if they are large (> 150), they will have a very strong effect, making the image look “cartoonish”.
Filter size: Large filters (d > 5) are very slow, so it is recommended to use d=5 for real-time applications, and perhaps d=9 for offline applications that need heavy noise filtering.
进行高斯滤波的通常原因是真是图像在空间内的像素是缓慢变化的,因此临近点的像素变化不会很明显,但是随即的两个订就可能形成很大的像素差,因此高斯滤波在保留信号的条件下减少噪声。但是在接近边缘处就无效了,在那里不希望像素与相邻像素相关,所以高斯滤波会磨平边缘。 而双边滤波能够提供一种不会讲边缘平花掉的方法,代价是需要更多的处理时间。