The LoG filter with the SciPy ndimage module

The SciPy ndimage module's gaussian_laplace() function can also be used to implement LoG, as shown in the following code block:

img = rgb2gray(imread('../images/zebras.jpg'))fig = pylab.figure(figsize=(25,15))pylab.gray() # show the filtered result in grayscalefor sigma in range(1,10): pylab.subplot(3,3,sigma) img_log = ndimage.gaussian_laplace(img, sigma=sigma) pylab.imshow(np.clip(img_log,0,1)), pylab.axis('off') pylab.title('LoG with sigma=' + str(sigma), size=20)pylab.show()

The following images show the input image and the output images obtained with the LoG filter with different values of the smoothing parameter σ (standard deviation of the Gaussian filter):

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.