The scikit-image morphology module
In this section, we shall demonstrate how to use the functions from scikit-image's morphology module to implement a few morphological operations, first on binary images and then on grayscale images.
Binary operations
Let's start with morphological operations on binary images. We need to create a binary input image (for example, with simple thresholding which has a fixed threshold) before invoking the functions.
Erosion
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 imread from skimage.color import rgb2gray import matplotlib.pylab as pylab from skimage.morphology import binary_erosion, rectangle def plot_image(image, title=''): pylab.title(title, size=20), pylab.imshow...