图像的梯度
An image gradient is a directional change in the intensity or color in an image.
梯度是图像中亮度或颜色的方向变化
At each image point, the gradient vector points in the direction of largest possible intensity increase, and the length of the gradient vector corresponds to the rate of change in that direction
在每个图像点上,梯度向量指向强度可能增加最大的方向,梯度向量的长度对应于该方向的变化率
算子实际上就是卷积核
使用不同的卷积核来获取图像的不同变化规律
sobel算子
sobel 实现边缘检测的原理
Sobel算子依然是一种过滤器,只是其是带有方向的。在OpenCV-Python中,使用Sobel的算子的函数原型如下:
dst = cv2.Sobel(src, ddepth, dx, dy[, dst[, ksize[, scale[, delta[, borderType]]]]])
- 第一个参数是需要处理的图像
- 第二个参数是图像的深度,-1表示采用的是与原图像相同的深度。目标图像的深度必须大于等于原图像的深度
- dx和dy表示的是求导的阶数,0表示这个方向上没有求导,一般为0、1、2
- ksize是Sobel算子的大小,必须为1、3、5、7
- scale是缩放导数的比例常数,默认情况下没有伸缩系数
- delta是一个可选的增量,将会加到最终的dst中,同样,默认情况下没有额外的值加到dst中
- borderType是判断图像边界的模式。这个参数默认值为cv2.BORDER_DEFAULT