def _filter(img, method, k):
if method == 'Edge gradient':
sy = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=0, dy=1, ksize=k)
sx = cv2.Sobel(img, ddepth=cv2.CV_64F,dx=1, dy=0, ksize=k)
# sx = sobel(img, axis=0, mode='constant')
# sy = sobel(img, axis=1, mode='constant')
return np.hypot(sx, sy)
if method == 'Sobel-H':
return cv2.Sobel(img, ddepth=cv2.CV_64F,dx=0, dy=1, ksize=k)
#sobel(img, axis=0, mode='constant')
if method == 'Sobel-V':
return cv2.Sobel(img, ddepth=cv2.CV_64F,dx=1, dy=0, ksize=k)
#sobel(img, axis=1, mode='constant')
if method == 'Laplace':
return cv2.Laplacian(img, ddepth=cv2.CV_64F,ksize=5)
#laplace(img)
评论列表
文章目录