python opencv 实现开闭运算

涉及到的函数为erodedilate:

import cv2
import matplotlib.pyplot as plt
size = 11
kernel = np.ones((size, size), dtype=np.uint8)
img_erosion = cv2.erode(img, kernel, iterations=1)
img_dilation = cv2.dilate(img, kernel, iterations=1)
img_close = cv2.erode(cv2.dilate(img4, kernel), kernel)
plt.imshow(img_close)

你可能感兴趣的:(python,opencv)