数学之路-python计算实战(22)-机器视觉-sobel非线性滤波
来源:互联网 发布:linux追加分区大小 编辑:程序博客网 时间:2024/06/06 07:10
sobel非线性滤波,采用梯度模的近似方式
Sobel
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
- C++: void Sobel(InputArray src, OutputArray dst, int ddepth, int dx, int dy, intksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
- Python: cv2.Sobel(src, ddepth, dx, dy[, dst[, ksize[, scale[, delta[, borderType]]]]]) → dst
- C: void cvSobel(const CvArr* src, CvArr* dst, int xorder, int yorder, intaperture_size=3 )
- Python: cv.Sobel(src, dst, xorder, yorder, apertureSize=3) → None
Parameters: - src – input image.
- dst – output image of the same size and the same number of channels as src .
- ddepth –
- output image depth; the following combinations of src.depth() andddepth are supported:
- src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
- src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
- src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
- src.depth() = CV_64F, ddepth = -1/CV_64F
when ddepth=-1, the destination image will have the same depth as the source; in the case of 8-bit input images it will result in truncated derivatives.
- xorder – order of the derivative x.
- yorder – order of the derivative y.
- ksize – size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
- scale – optional scale factor for the computed derivative values; by default, no scaling is applied (seegetDerivKernels() for details).
- delta – optional delta value that is added to the results prior to storing them in dst.
- borderType – pixel extrapolation method (seeborderInterpolate() for details).
In all cases except one, the separable kernel is used to calculate the derivative. When , the or kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives.
There is also the special value ksize = CV_SCHARR (-1) that corresponds to the Scharr filter that may give more accurate results than the Sobel. The Scharr aperture is
for the x-derivative, or transposed for the y-derivative.
The function calculates an image derivative by convolving the image with the appropriate kernel:
The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with ( xorder= 1, yorder = 0, ksize = 3) or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of:
The second case corresponds to a kernel of:
本博客所有内容是原创,如果转载请注明来源
http://blog.csdn.net/myhaspl/
# -*- coding: utf-8 -*- #非线性锐化滤波,sobel算子变换#code:myhaspl@myhaspl.comimport cv2fn="test6.jpg"myimg=cv2.imread(fn)img=cv2.cvtColor(myimg,cv2.COLOR_BGR2GRAY)jgimg=cv2.Sobel(img,0,1,1)cv2.imshow('src',img)cv2.imshow('dst',jgimg)cv2.waitKey()cv2.destroyAllWindows()
Sobel
使用扩展 Sobel 算子计算一阶、二阶、三阶或混合图像差分
void cvSobel( const CvArr* src, CvArr* dst, int xorder, int yorder, int aperture_size=3 );
- src
- 输入图像.
- dst
- 输出图像.
- xorder
- x 方向上的差分阶数
- yorder
- y 方向上的差分阶数
- aperture_size
- 扩展 Sobel 核的大小,必须是 1, 3, 5 或 7。 除了尺寸为 1, 其它情况下, aperture_size ×aperture_size 可分离内核将用来计算差分。对 aperture_size=1的情况, 使用 3x1 或 1x3 内核 (不进行高斯平滑操作)。这里有一个特殊变量 CV_SCHARR (=-1),对应 3x3 Scharr 滤波器,可以给出比 3x3 Sobel 滤波更精确的结果。
- 数学之路-python计算实战(22)-机器视觉-sobel非线性滤波
- 数学之路-python计算实战(15)-机器视觉-滤波去噪(归一化块滤波)
- 数学之路-python计算实战(16)-机器视觉-滤波去噪(邻域平均法滤波)
- 数学之路-python计算实战(17)-机器视觉-滤波去噪(中值滤波)
- 数学之路-python计算实战(18)-机器视觉-滤波去噪(双边滤波与高斯滤波 )
- 数学之路-python计算实战(19)-机器视觉-卷积滤波
- 数学之路-python计算实战(20)-机器视觉-拉普拉斯算子卷积滤波
- 数学之路-python计算实战(21)-机器视觉-拉普拉斯线性滤波
- 数学之路-python计算实战(7)-机器视觉-图像产生加性零均值高斯噪声
- 数学之路-python计算实战(8)-机器视觉-图像二值化
- 数学之路-python计算实战(9)-机器视觉-图像插值仿射
- 数学之路-python计算实战(10)-机器视觉-透视投影
- 数学之路-python计算实战(11)-机器视觉-图像增强
- 数学之路-python计算实战(12)-机器视觉-图像增强
- 数学之路-python计算实战(13)-机器视觉-图像增强
- 数学之路-python计算实战(14)-机器视觉-图像增强(直方图均衡化)
- 数学之路-python计算实战(11)-机器视觉-图像增强
- 数学之路-python计算实战(1)-ubuntu安装pypy
- hdu 1532
- java 线程同步
- 程序员面试经典问题集以及offer,三方协议等常识
- Codeforces 48C The Race 模拟题
- 斩不断的平台梦,时隔3年,再次做dz平台
- 数学之路-python计算实战(22)-机器视觉-sobel非线性滤波
- [深入浅出Cocoa]之消息(二)-详解动态方法决议(Dynamic Method Resolution)
- Eclipse中Maven插件的安装与配置
- Android 获取Keystore 的SHA
- 深入浅出NodeJS——内存控制
- poj1470-Closest Common Ancestors(LCA)
- 排序算法
- zoj2913
- 双目视觉测量系统设计中的一些注意事项