November 2018
Intermediate to advanced
492 pages
12h 19m
English
Opening is a morphological operation that can be expressed as a combination of first erosion and then dilation operations; it removes small objects from a binary image. Closing, to the contrary, is another morphological operation that can be expressed as a combination of first dilation and then erosion operations; it removes small holes from a binary image. These two are dual operations. The following code snippet shows how to use the scikit-image morphology module's corresponding functions to remove small objects and small holes, respectively, from a binary image:
from skimage.morphology import binary_opening, binary_closing, binary_erosion, binary_dilation, diskim = rgb2gray(imread('../images/circles.jpg'))im[im <= 0.5] ...Read now
Unlock full access