LPF with scipy fftpack

We can implement a LPF on an image with the following steps:

  1. Perform a 2D FFT with scipy.fftpack fft2 and obtain the frequency domain representation of the image
  2. Keep only the low frequency components (get rid of the high frequency components)
  3. Perform an inverse FFT to reconstruct the image

The Python code to implement an LPF is shown in the following code. As can be seen from the next screenshots, the high frequency components correspond more to the average (flat) image information and the detailed information (for example, the edges) of an image is lost as we get rid of more and more high-frequency components.

For example, if we keep only the first-frequency component and discard all others, in the resulting image ...

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.