You are viewing a single comment's thread. Return to all comments →
import numpy as np import matplotlib.pyplot as plt from skimage.io import imread, imshow from skimage.draw import disk from skimage.morphology import (erosion, dilation, closing, opening, area_closing, area_opening) from skimage.color import rgb2gray 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] ]) s = np.array([ [1,1,1], [1,1,1], [1,1,1]]) unique, freq = np.unique(dilation(a,s), return_counts=True) print("dilation", freq[1]) unique, freq = np.unique(erosion(a,s), return_counts=True) print("erosion", freq[1]) unique, freq = np.unique(closing(a,s), return_counts=True) print("closing", freq[1]) unique, freq = np.unique(opening(a,s), return_counts=True) print("opening", freq[1]) # plt.imshow(dilation(a,s), cmap='gray') # plt.show()
Seems like cookies are disabled on this browser, please enable them to open this website
Morphological Operations: Opening
You are viewing a single comment's thread. Return to all comments →