KEMBAR78
Dip Assigment | PDF | Filter (Signal Processing) | Electrical Engineering
0% found this document useful (0 votes)
32 views5 pages

Dip Assigment

This document discusses various image restoration filters used to recover degraded images, including adaptive, band reject, band pass, notch, optimum notch, inverse, and Wiener filters. It provides Python implementations for each filter to demonstrate their functionality in reducing noise and enhancing image quality. The conclusion highlights the strengths of different filters based on the type of noise present in the images.

Uploaded by

Sam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views5 pages

Dip Assigment

This document discusses various image restoration filters used to recover degraded images, including adaptive, band reject, band pass, notch, optimum notch, inverse, and Wiener filters. It provides Python implementations for each filter to demonstrate their functionality in reducing noise and enhancing image quality. The conclusion highlights the strengths of different filters based on the type of noise present in the images.

Uploaded by

Sam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Image Restoration Filters

RA2311031010110

Sam Sebastin D

CSE - IT

Introduction

Image restoration is a technique used to recover an original image that has been degraded by
noise, blurring, or other distortions. Various filtering techniques help in improving image quality
by reducing noise and enhancing details. This document discusses different image restoration
filters and implements them in Python.

Types of Image Restoration Filters

Adaptive Filters

Adaptive filters adjust their parameters based on the characteristics of the local image region.
They are useful in removing noise while preserving details.

Python Implementation:

import cv2

import numpy as np

import matplotlib.pyplot as plt

from scipy.ndimage import uniform_filter

from google.colab import files

uploaded = files.upload()

image_name = list(uploaded.keys())[0]

original_image = cv2.imread(image_name, cv2.IMREAD_GRAYSCALE)

noisy_image = original_image + np.random.normal(0, 25, original_image.shape)


noisy_image = np.clip(noisy_image, 0, 255).astype(np.uint8)

adaptive_filtered = uniform_filter(noisy_image, size=3)

plt.subplot(1,2,1), plt.imshow(noisy_image, cmap='gray'), plt.title('Noisy Image')

plt.subplot(1,2,2), plt.imshow(adaptive_filtered, cmap='gray'), plt.title('Adaptive Filtered')

plt.show()

Band Reject Filter

A Band Reject Filter removes a specific range of frequencies, often used to eliminate periodic
noise.

Python Implementation:

f_transform = np.fft.fftshift(np.fft.fft2(noisy_image))

rows, cols = noisy_image.shape

crow, ccol = rows//2, cols//2

mask = np.ones((rows, cols), np.uint8)

mask[crow-10:crow+10, ccol-10:ccol+10] = 0

filtered_dft = f_transform * mask

band_reject_filtered = np.abs(np.fft.ifft2(np.fft.ifftshift(filtered_dft)))

Band Pass Filter

A Band Pass Filter allows a specific range of frequencies to pass, enhancing certain details while
removing unwanted noise.

Python Implementation:

band_pass_mask = 1 - mask

filtered_dft_bp = f_transform * band_pass_mask

band_pass_filtered = np.abs(np.fft.ifft2(np.fft.ifftshift(filtered_dft_bp)))
Notch Filter

Notch filters remove periodic noise by selectively blocking certain frequency components.

Python Implementation:

notch_mask = np.ones((rows, cols), np.uint8)

notch_mask[crow-5:crow+5, ccol-5:ccol+5] = 0

filtered_dft_notch = f_transform * notch_mask

notch_filtered = np.abs(np.fft.ifft2(np.fft.ifftshift(filtered_dft_notch)))

Optimum Notch Filtering

This filter is an optimized version of the notch filter, targeting noise more effectively.

Python Implementation:

opt_notch_mask = np.copy(notch_mask)

opt_notch_mask[crow-2:crow+2, ccol-2:ccol+2] = 0

filtered_dft_opt = f_transform * opt_notch_mask

optimum_notch_filtered = np.abs(np.fft.ifft2(np.fft.ifftshift(filtered_dft_opt)))

Inverse Filtering

Inverse filtering attempts to reconstruct the original image by reversing the effects of a known
degradation process.

Python Implementation:

blur_kernel = np.ones((5, 5)) / 25

blurred = cv2.filter2D(noisy_image, -1, blur_kernel)

blurred_dft = np.fft.fft2(blurred)

kernel_dft = np.fft.fft2(blur_kernel, s=blurred.shape)


inverse_filtered = np.abs(np.fft.ifft2(blurred_dft / kernel_dft))

Wiener Filtering

Wiener filtering is an adaptive filtering technique that minimizes the mean square error
between the estimated and original images.

Python Implementation:

from scipy.signal import wiener

wiener_filtered = wiener(noisy_image, (5, 5))


Conclusion

Each filter has its advantages based on the type of noise and degradation present in the image.
The adaptive and Wiener filters perform well in general noise reduction, while notch and band
filters are useful for removing specific frequency-based noise patterns.

You might also like