sobel非线性滤波,采用梯度模的近似方式
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
Parameters: |
|
---|
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:
# -*- coding: utf-8 -*-
#非线性锐化滤波,sobel算子变换
#code:[email protected]
import cv2
fn="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 算子计算一阶、二阶、三阶或混合图像差分
void cvSobel( const CvArr* src, CvArr* dst, int xorder, int yorder, int aperture_size=3 );