0% found this document useful (0 votes)
5 views16 pages

1739886980-Lecture#15 Spatial Filtering

The document discusses spatial filtering techniques for noise removal in images, focusing on correlation and convolution methods in both 1D and 2D. It outlines the process of applying smoothing linear filters, such as average and Gaussian filters, and provides a step-by-step algorithm for image blurring using OpenCV. Additionally, it includes code snippets for generating Gaussian noise and applying filters to images.

Uploaded by

mayur.vasisth23
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)
5 views16 pages

1739886980-Lecture#15 Spatial Filtering

The document discusses spatial filtering techniques for noise removal in images, focusing on correlation and convolution methods in both 1D and 2D. It outlines the process of applying smoothing linear filters, such as average and Gaussian filters, and provides a step-by-step algorithm for image blurring using OpenCV. Additionally, it includes code snippets for generating Gaussian noise and applying filters to images.

Uploaded by

mayur.vasisth23
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/ 16

Spatial Filtering Noise removal

Effect of Noise
Filter mask
Correlation and
Convolution (1D)
Correlation and Convolution

Correlation Convolution
Correlation
and
Convolution
(2D)
Vector representation of linear filtering
Vector representation of linear filtering
Smoothing Linear Filter (Average filter)
Average filter
Gaussian filter
Average filter
Average filter
Image blurring Algo

1. Define the type and size of filter mask


2. Image Padding depending on the size of filter mask
3. Apply the filter mask on input image using correlation or convolution technique
4. Crop the output image to make it of same size as input image
Image blurring in OpenCV

Blur(image, smoothed_image, Size(3, 3));

GaussianBlur(image, smoothed_image, Size(5, 5), 1.5);


import cv2
import numpy as np
# Load the image Inserting
img = cv2.imread('test_image.jpg') Gaussian Noise
# Generate random Gaussian noise
mean = 0
stddev = 180
noise = np.zeros(img.shape, np.uint8)
cv2.randn(noise, mean, stddev)
# Add noise to image
noisy_img = cv2.add(img, noise)
# Save noisy image
cv2.imwrite('noisy_img.jpg', noisy_img)

You might also like