You are viewing a single comment's thread. Return to all comments →
import numpy as np import cv2
a = np.array([[0,0,0,0,0,0,0,0,0,0],[0,1,1,1,1,1,1,1,0,0],[0,0,0,0,1,1,1,1,0,0], [0,0,0,0,1,1,1,1,0,0], [0,0,0,1,1,1,1,1,0,0], [0,0,0,0,1,1,1,1,0,0], [0,0,0,1,1,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0] ],np.uint8)
s = np.array([ [1,1,1], [1,1,1], [1,1,1]],np.uint8) img_dilation = cv2.erode(a, s, iterations=1)
print(np.count_nonzero(img_dilation))
Seems like cookies are disabled on this browser, please enable them to open this website
Morphological Operations: Erosion
You are viewing a single comment's thread. Return to all comments →
import numpy as np import cv2
a = np.array([[0,0,0,0,0,0,0,0,0,0],[0,1,1,1,1,1,1,1,0,0],[0,0,0,0,1,1,1,1,0,0], [0,0,0,0,1,1,1,1,0,0], [0,0,0,1,1,1,1,1,0,0], [0,0,0,0,1,1,1,1,0,0], [0,0,0,1,1,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0] ],np.uint8)
s = np.array([ [1,1,1], [1,1,1], [1,1,1]],np.uint8) img_dilation = cv2.erode(a, s, iterations=1)
unique, freq = np.unique(dilation(a,s), return_counts=True)
print(freq[1])
print(np.count_nonzero(img_dilation))