Deconvolution and inverse filtering with FFT

Given a blurred image with a known (assumed) blur kernel, a typical image processing task is to get back (at least an approximation of) the original image. This particular task is known as deconvolution. One of the naive filters that can be applied in the frequency domain to achieve this is the inverse filter that we are going to discuss in this section. Let's first start by blurring the grayscale lena image with Gaussian blur using the following code:

im = 255*rgb2gray(imread('../images/lena.jpg'))gauss_kernel = np.outer(signal.gaussian(im.shape[0], 3),signal.gaussian(im.shape[1], 3))freq = fp.fft2(im)freq_kernel = fp.fft2(fp.ifftshift(gauss_kernel)) # this is our Hconvolved = freq*freq_kernel ...

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.