November 2018
Intermediate to advanced
492 pages
12h 19m
English
Dilation is another basic morphological operation that expands the size of the foreground objects, smooths object boundaries, and closes holes and gaps in a binary image. This is a dual operation of erosion. The following code snippet shows how to use the binary_dilation() function on Tagore's binary image with a disk structuring elements of different sizes:
from skimage.morphology import binary_dilation, diskfrom skimage import img_as_floatim = img_as_float(imread('../images/tagore.png'))im = 1 - im[...,3]im[im <= 0.5] = 0im[im > 0.5] = 1pylab.gray()pylab.figure(figsize=(18,9))pylab.subplot(131)pylab.imshow(im)pylab.title('original', size=20)pylab.axis('off')for d in range(1,3): pylab.subplot(1,3,d+1) im1 = binary_dilation(im, disk(2*d)) ...Read now
Unlock full access