Guide package:
import numpy as np import cv2 import matplotlib.pyplot as plt def show(image): plt.imshow(image) plt.axis('off') plt.show() def imread(image): image=cv2.imread(image) image=cv2.cvtColor(image,cv2.COLOR_BGR2RGB) return image
Open computing code:
kernel=cv2.getStructuringElement(cv2.MORPH_RECT,(10,10)) opening=cv2.morphologyEx(image,cv2.MORPH_OPEN,kernel) show(opening)
Closing operation codes: # closing operation following the start, and then etching after expansion, for removing black spots
kernel=cv2.getStructuringElement(cv2.MORPH_RECT,(10,10)) opening=cv2.morphologyEx(image,cv2.MORPH_OPEN,kernel) show(opening)