原图:
腐蚀运算:
k = cv2.getStructuringElement(shape=1, ksize=(3, 3), anchor=(-1, -1))
erosion = cv2.erode(src=img, kernel=k, iterations=1)
膨胀运算:
k = cv2.getStructuringElement(shape=1, ksize=(3, 3), anchor=(-1, -1))
dilation = cv2.dilate(img, k, iterations=1)
开运算:
k = cv2.getStructuringElement(shape=1, ksize=(3, 3), anchor=(-1, -1))
opening = cv2.morphologyEx(src=img, op=cv2.MORPH_OPEN, kernel=k)
闭运算:
k = cv2.getStructuringElement(shape=1, ksize=(3, 3), anchor=(-1, -1))
closing = cv2.morphologyEx(img, cv2.MORPH_CLOSE, kernel=k)