Band-pass filter (BPF) with DoG

The Difference of Gaussian (DoG) kernel can be used as a BPF to allow the frequencies in a certain band and discard all other frequencies. The following code block shows how the DoG kernel can be used with fftconvolve() to implement a BPF:

from skimage import img_as_floatim = img_as_float(pylab.imread('../images/tigers.jpeg'))pylab.figure(), pylab.imshow(im), pylab.axis('off'), pylab.show()x = np.linspace(-10, 10, 15)kernel_1d = np.exp(-0.005*x**2)kernel_1d /= np.trapz(kernel_1d) # normalize the sum to 1gauss_kernel1 = kernel_1d[:, np.newaxis] * kernel_1d[np.newaxis, :]kernel_1d = np.exp(-5*x**2)kernel_1d /= np.trapz(kernel_1d) # normalize the sum to 1gauss_kernel2 = kernel_1d[:, np.newaxis] * kernel_1d[np.newaxis, ...

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.