Python example code of sobel operator
下面是 Python 实现 Sobel 算子的示例代码:
import numpyas np
import cv2
def sobel_operator(image):
# 转换为灰度图像
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# 计算 x 方向的 Sobel 导数
sobel_x = cv2.Sobel(gray, cv2.CV_64F, 1, 0, ksize=3)
abs_sobel_x = np.absolute(sobel_x)
scaled_sobel_x = n
还没有评论,来说两句吧...