opencv 笔记09Imgproc_Smoothing
来源:互联网 发布:mac应用程序没图标 编辑:程序博客网 时间:2024/06/05 15:08
归一化块滤波器 (Normalized Box Filter)
最简单的滤波器, 输出像素值是核窗口内像素值的 均值 ( 所有像素加权系数相等)
核如下:
void blur(const Mat& src, Mat& dst, Size ksize, Point anchor=Point(-1, -1), int borderType=BORDER_DEFAULT)
Parameters: - src – The source image
- dst – The destination image; will have the same size and the same type as src
- ksize – The smoothing kernel size
- anchor – The anchor point. The default value Point(-1,-1) means that the anchor is at the kernel center
- borderType – The border mode used to extrapolate pixels outside of the image
高斯滤波器 (Gaussian Filter)
最有用的滤波器 (尽管不是最快的)。 高斯滤波是将输入数组的每一个像素点与 高斯内核 卷积将卷积和当作输出像素值。
还记得1维高斯函数的样子吗?
假设图像是1维的,那么观察上图,不难发现中间像素的加权系数是最大的, 周边像素的加权系数随着它们远离中间像素的距离增大而逐渐减小。
void GaussianBlur(const Mat& src, Mat& dst, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT)
Parameters: - src – The source image
- dst – The destination image; will have the same size and the same type as src
- ksize – The Gaussian kernel size; ksize.width and ksize.height can differ, but they both must be positive and odd. Or, they can be zero’s, then they are computed from sigma*
- sigmaX, sigmaY – The Gaussian kernel standard deviations in X and Y direction. If sigmaY is zero, it is set to be equal to sigmaX . If they are both zeros, they are computed from ksize.width and ksize.height , respectively, seegetGaussianKernel() . To fully control the result regardless of possible future modification of all this semantics, it is recommended to specify all of ksize , sigmaX and sigmaY
- borderType – The pixel extrapolation method; see borderInterpolate()
Note
2维高斯函数可以表达为 :
其中 为均值 (峰值对应位置), 代表标准差 (变量 和 变量 各有一个均值,也各有一个标准差)
中值滤波器 (Median Filter)
中值滤波将图像的每个像素用邻域 (以当前像素为中心的正方形区域)像素的 中值 代替 。
void medianBlur(const Mat& src, Mat& dst, int ksize)
- src – The source 1-, 3- or 4-channel image. When ksize is 3 or 5, the image depth should be CV_8U , CV_16U orCV_32F . For larger aperture sizes it can only be CV_8U
- dst – The destination array; will have the same size and the same type as src
- ksize – The aperture linear size. It must be odd and more than 1, i.e. 3, 5, 7 ...
双边滤波 (Bilateral Filter)
- 目前我们了解的滤波器都是为了 平滑 图像, 问题是有些时候这些滤波器不仅仅削弱了噪声, 连带着把边缘也给磨掉了。 为避免这样的情形 (至少在一定程度上 ), 我们可以使用双边滤波。
- 类似于高斯滤波器,双边滤波器也给每一个邻域像素分配一个加权系数。 这些加权系数包含两个部分, 第一部分加权方式与高斯滤波一样,第二部分的权重则取决于该邻域像素与当前像素的灰度差值。
- 详细的解释可以查看 链接
void bilateralFilter(const Mat& src, Mat& dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT)
- src – The source 8-bit or floating-point, 1-channel or 3-channel image
- dst – The destination image; will have the same size and the same type as src
- d – 像素的邻域直径,The diameter of each pixel neighborhood, that is used during filtering. If it is non-positive, it’s computed fromsigmaSpace
- sigmaColor – 颜色空间的标准方差Filter sigma in the color space. Larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace ) will be mixed together, resulting in larger areas of semi-equal color
- sigmaSpace – 坐标空间的标准方差Filter sigma in the coordinate space. Larger value of the parameter means that farther pixels will influence each other (as long as their colors are close enough; see sigmaColor ). Then d>0 , it specifies the neighborhood size regardless of sigmaSpace , otherwise d is proportional to sigmaSpace
- opencv 笔记09Imgproc_Smoothing
- OpenCV笔记
- openCV笔记
- OpenCV笔记
- OpenCV笔记
- opencv笔记
- Opencv笔记
- opencv 笔记
- opencv笔记
- opencv笔记
- opencv笔记
- OpenCV--笔记
- opencv笔记
- OpenCV笔记
- OpenCV笔记
- OpenCV笔记
- 【OpenCV笔记 09】OpenCV中离散傅里叶变换、归一化的运用
- OpenCV学习笔记
- hdu 2922 Relax! It’s just a game
- 作业
- Selenium python
- 黑马程序员_java内部类之学习笔记
- 分享:sp_get_object_definition查找所有数据库下面哪些对象定义语句中包括想要查找的字符串
- opencv 笔记09Imgproc_Smoothing
- putty登录本地linux虚拟机
- Spring AOP IOC 的 Annotation 实现方式
- GIS开源软件大全
- PHP程序员最容易忽略的几个精华之处
- 黑马程序员_String类的学习
- 使用iphlpapi动态链接库函数实现ping功能
- Android学习笔记——OAuth完全手册_国内篇
- 状态压缩dp poj1185