腐蚀和膨胀
demo1
# 腐蚀
import cv2
import numpy as np
img = cv2.imread("./atm.jpg")k = np.ones((3, 3), np.uint8)
cv2.imshow("img", img)
dst = cv2.erode(img, k)
cv2.imshow("dst", dst)
cv2.waitKey()
cv2.destroyAllWindows()
demo2
# 膨胀
import cv2
import numpy as np
img = cv2.imread("./atm.jpg")
img = cv2.resize(img, None, None, 0.5, 0.5)
k = np.ones((3, 3), np.uint8)
cv2.imshow("img", img)
dst = cv2.dilate(img, k)
cv2.imshow("dst", dst)
cv2.waitKey()
cv2.destroyAllWindows()