Computing the morphological Laplace

The following code block demonstrates how to compute the morphological Laplace using the corresponding ndimage function with a binary image of Tagore, and compares it with the morphological gradient with structuring elements of different sizes, though as can be seen, for this image a smaller structuring element with gradient and a larger structuring element with Laplace yields better output images in terms of extracted edges:

im = imread('../images/tagore.png')[...,3]im_g = ndimage.morphological_gradient(im, size=(3,3))im_l = ndimage.morphological_laplace(im, size=(5,5))pylab.figure(figsize=(15,10))pylab.subplot(121), pylab.title('ndimage morphological laplace', size=20), pylab.imshow(im_l)pylab.axis('off') ...

Get Hands-On Image Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.