标签:src sigmaSpace image 滤波 param OpenCv 026 图像
1 前备知识
此前的图像卷积处理无论是均值还是高斯都是属于模糊卷积,它们都有一个共同的特点就是模糊之后图像的边缘信息不复存在或者受到了破坏。而高斯双边滤波可以通过卷积处理实现图像模糊的同时减少图像边缘破坏,滤波之后的输出完整的保存了图像整体边缘(轮廓)信息,我们称这类滤波算法为边缘保留滤波算法(EPF)。最常见的边缘保留滤波算法有以下几种:
- 高斯双边模糊:高斯模糊是考虑图像空间位置对权重的影响,但是它没有考虑图像像素分布对图像卷积输出的影响,双边模糊考虑了像素值分布的影响,对像素值空间分布差异较大的进行保留从而完整的保留了图像的边缘信息。
- Meanshift均值迁移模糊:TODO
- 局部均方差模糊:TODO
- OpenCV中对边缘保留滤波还有一个专门的API:下文
2 所用到的主要OpenCv API
/** @brief Applies the bilateral filter to an image. The function applies bilateral filtering to the input image, as described in http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is very slow compared to most filters. _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. This filter does not work inplace. @param src Source 8-bit or floating-point, 1-channel or 3-channel image. @param dst Destination image of the same size and type as src . @param d Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace. @param sigmaColor Filter sigma in the color space. A 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. @param sigmaSpace Filter sigma in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigmaColor ). When d\>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is proportional to sigmaSpace. @param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes */ CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType = BORDER_DEFAULT );
3 程序代码
#include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace std; int main(int artc, char** argv) { Mat src = imread("images/Demo.jpg"); if (src.empty()) { printf("could not load image...\n"); return -1; } namedWindow("input", CV_WINDOW_AUTOSIZE); imshow("input", src); Mat dst; bilateralFilter(src, dst, 0, 100, 10, 4); imshow("result", dst); waitKey(0); return 0; }
4 运行结果
略
5 扩展及注意事项
none
6*目前只做大概了解,知道有这一算法,后续具体使用再做具体分析
标签:src,sigmaSpace,image,滤波,param,OpenCv,026,图像
来源: https://www.cnblogs.com/Vince-Wu/p/11846886.html
本站声明:
1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。