3.medianBlur 中值滤波
中值滤波是基于排序统计理论的一种能有效抑制噪声的非线性信号处理技术,对脉冲噪声有良好的滤除作用,特别是在滤除噪声的同时,能够保护信号的边缘,使之不被模糊。这些优良特性是线性滤波方法所不具有的。此外,中值滤波的算法比较简单,也易于用硬件实现。
中值滤波就是将当前像素值替换为模板覆盖范围内的所有像素值中大小居中那一个:对于一个3*3的模板,第5大的就是中值:
(10,15,20,20,20,20,20,25,100)
中值滤波使得那些更亮(或者更暗)的点更像他周围的值。所以它在滤除噪音的同时,可以较好地保留细节轮廓。
函数说明
void cv::medianBlur | ( | InputArray | src, |
OutputArray | dst, | ||
int | ksize | ||
) |
Blurs an image using the median filter.
The function smoothes an image using the median filter with the ksize×ksize aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported.
-
Parameters
-
src input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U. dst destination array of the same size and type as src. ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ...
-
See also
- bilateralFilter, blur, boxFilter, GaussianBlur
-
Examples:
- houghcircles.cpp, and laplace.cpp.