Opening Morphology
- Erode Image
- Dilate Back Image
Code:
import cv2
import numpy as np
img = cv2.imread("img_path")
kernel = np.ones((5,5),np.uint8)
opening = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel)
Closing Morphology
- Dilate Image
- Erode Back Image
Code:
import cv2
import numpy as np
img = cv2.imread("img_path")
kernel = np.ones((5,5),np.uint8)
closing = cv2.morphologyEx(img, cv2.MORPH_CLOSE, kernel)
Reference:Morphology Methods