Erosion is a basic morphological operation that shrinks the size of the foreground objects, smooths the object boundaries, and removes peninsulas, fingers, and small objects. The following code block shows how to use the binary_erosion() function that computes fast binary morphological erosion of a binary image:
from skimage.io import imreadfrom skimage.color import rgb2grayimport matplotlib.pylab as pylabfrom skimage.morphology import binary_erosion, rectangledef plot_image(image, title=''): pylab.title(title, size=20), pylab.imshow(image) pylab.axis('off') # comment this line if you want axis ticks im = rgb2gray(imread('../images/clock2.jpg'))im[im <= 0.5] = 0 # create binary image with fixed threshold 0.5im[im > 0.5] = 1pylab.gray() ...