立即学习:https://edu.csdn.net/course/play/10552/234939?utm_source=blogtoedu
图像梯度
二值图像中
白色 ; 1 黑色 :0
梯度 = 膨胀 - 腐蚀
函数morphologyEx
dst = cv2.morphologyEx(src , cv2.MORPH_GRADIENT , kernel)
import cv2
import numpy as np
img = cv2.imread('111.jpg',cv2.IMREAD_UNCHANGED)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
k = np.ones((5,5),np.uint8)
r,tw = cv2.threshold(gray, 120 , 255 , cv2.THRESH_BINARY)
dst = cv2.morphologyEx(tw, cv2.MORPH_GRADIENT, k)
cv2.namedWindow('gray',cv2.WINDOW_AUTOSIZE)
cv2.namedWindow('tw',cv2.WINDOW_AUTOSIZE)
cv2.namedWindow('dst',cv2.WINDOW_AUTOSIZE)
cv2.imshow('gray',gray)
cv2.imshow('tw',tw)
cv2.imshow('dst',dst)
cv2.waitKey(0)
cv2.destroyAllWindows()
来源:CSDN
作者:投篮不准的小宇哥
链接:https://blog.csdn.net/m0_43414015/article/details/104641646