November 2018
Intermediate to advanced
492 pages
12h 19m
English
The morphological Beucher gradient can be computed as a difference image of the dilated version and the eroded version of an input grayscale image. SciPy ndimage provides a function for computing the morphological gradient of a grayscale image. The following code block shows how these two produce the same output for an Einstein image:
from scipy import ndimageim = rgb2gray(imread('../images/einstein.jpg'))im_d = ndimage.grey_dilation(im, size=(3,3))im_e = ndimage.grey_erosion(im, size=(3,3))im_bg = im_d - im_eim_g = ndimage.morphological_gradient(im, size=(3,3))pylab.gray()pylab.figure(figsize=(20,18))pylab.subplot(231), pylab.imshow(im), pylab.title('original', size=20),pylab.axis('off')pylab.subplot(232), ...Read now
Unlock full access