# Ideal Low Pass Filters in Image Preprocessing

Ideal Low Pass Filter (ILPF) work over images transformed into frequency domain by using transformation such as Fourier transform, and act as sieve that allows low frequency components to pass through and blocks the large frequency component's. This post is about exploring the overview of ILPF in image preprocessing and their working so, lets start with definition.

**What is Ideal Low Pass Filter?**

ILPF is frequency domain filter that works over sharp cutoff frequency means the frequency components which are below Do (D knot) are passed through filter and components larger than that are blocked.

**Numerical Example and step for Ideal Low Pass Filter**

Let’s have image :

Transform the image using 2D Discrete Fourier Transform (DFT) :

Matrix after DFT:

Consider cutoff frequency D0=1 . The ILPF transfer function H(u,v) for a 3x3 image with the origin at the center is:

Multiply H(u,v) and F(u,v) in order to apply ILPF

Perform inverse transformation to achieve final matrix

**Python program to apply Ideal Low Pass Filter**

import numpy as np

import matplotlib.pyplot as plt# Define the 3x3 grayscale image

image = np.array([

[10, 50, 80],

[30, 70, 90],

[20, 40, 60]

], dtype=np.float32)# Function to apply the ILPF

def apply_ilpf(image, D0):

# Compute the 2D DFT of the image

dft = np.fft.fft2(image)

dft_shifted = np.fft.fftshift(dft)

# Get the image dimensions

M, N = image.shape

u, v = np.meshgrid(np.arange(M), np.arange(N), indexing=’ij’)

# Compute the distance from the center of the frequency domain

D = np.sqrt((u — M//2)**2 + (v — N//2)**2)

# Create the ILPF mask

H = np.where(D <= D0, 1, 0)

# Apply the ILPF mask to the DFT of the image

dft_filtered = dft_shifted * H

# Compute the inverse DFT to get the filtered image

idft_shifted = np.fft.ifftshift(dft_filtered)

filtered_image = np.fft.ifft2(idft_shifted)

# Take the real part of the inverse DFT (the result should be real)

filtered_image = np.real(filtered_image)

return filtered_image# Apply the ILPF with cutoff frequency D0 = 1

D0 = 1

filtered_image = apply_ilpf(image, D0)# Plot the input and output images

plt.figure(figsize=(10, 4))plt.subplot(1, 2, 1)

plt.title(‘Input Image’)

plt.imshow(image, cmap=’gray’, vmin=0, vmax=255)

plt.colorbar()plt.subplot(1, 2, 2)

plt.title(‘Filtered Image (ILPF)’)

plt.imshow(filtered_image, cmap=’gray’, vmin=0, vmax=255)

plt.colorbar()plt.tight_layout()

plt.show()

**Python Libraries using Fourier transformations and functions**

NumPy

`numpy.fft.fft2`

`numpy.fft.ifft2`

`numpy.fft.fftshift`

`numpy.fft.ifftshift`

SciPy

`scipy.fftpack.fft2`

`scipy.fftpack.ifft2`

`scipy.fftpack.fftshift`

`scipy.fftpack.ifftshift`

OpenCv

`cv2.dft`

`cv2.idft`

MATLAB

`scipy.io.loadmat`

`scipy.io.savemat`

## Applications of Ideal Low pass Filters

**MRI and CT Imaging**: ILPFs can be applied to preprocess medical images, filtering out noise and artifacts to improve diagnostic accuracy.**Ultrasound Imaging**: In ultrasound imaging, ILPFs can enhance the visibility of tissue boundaries and reduce speckle noise, improving image quality.**Noise Reduction**: ILPFs can be used to remove high-frequency noise from images while preserving low-frequency components, resulting in smoother and clearer images.**Edge Detection**: By enhancing low-frequency components and suppressing high-frequency noise, ILPFs can aid in edge detection algorithms by emphasizing image boundaries.

## Advantages of Ideal Low pass Filter

**Improvement in Spatial Resolution**

**Use Case:** spatial resolutions of optical images taken from microscopy or telescopes are improved by dropping unwanted high frequency noise and diffraction effects which makes the images more clearer and sharper.

**Removal of Undesirable Artifacts**

**Use Case:** ILPF able to remove unwanted effects from the images of scanned documents or inference patterns in digital photographs.

**Enhancement of Low-Contrast Images**

ILPF improves the contrast of images to enhance the textures and structures of images by amplifying low frequency components.

**Image Compression**

**Use Case:** ILPF is also performs image compression by reducing the amount of high-frequency data, which typically contains unwanted noise or redundant information.

## Disadvantages of Ideal Low Pass Filters

Ringing Artifacts

Shift-Invariance Issues

Edge Effects and Boundary Artifacts

Loss of Information

Blurring of High-Frequency Details

## Conclusion

In conclusion, Ideal Low-Pass Filters (ILPF) serve as powerful tools in the realm of image processing, offering capabilities to enhance images by selectively attenuating high-frequency noise while preserving essential low-frequency details. Throughout this exploration of ILPF, we have seen its advantages ,applications, numerical and python implementation. With this post reaches to end, I hope post add values into your journey of learning.

Thank you Readers !!!