Ece3005 Digital Image Processing
Name: Vaibhav Arora
Reg. No.: 19BEC1381
EXPERIMENT – 4
AIM:
To do noise addition to an image and apply the
following filters:
A. Low Pass Filter for Image Smoothing
B. Median Pass Filter
C. High Pass Filter for Image Sharpening.
TOOLS:
Matlab, Image processing toolbox.
PROCEDURE:
1. Insert an input image using the command imread.
Convert the image to its GrayScale using rgb2gray.
2. Add salt and pepper noise to the image using the
command imnoise.
3. Apply low pass filter, median filter and high pass
filter. View the images using imshow and identify
the differences
CODE:
clc
clear all
close all
format compact
X=imread('C:\Users\91974\OneDrive - vit.ac.in\Winter sem
21-22\DIP LAB\LAB 1\nature.jpg');
X=rgb2gray(X);
J=imnoise(X,'salt & pepper',0.02);
k1=ones(3,3)/9;
k2=[0 -1/4 0;-1/4 2 -1/4;0 -1/4 0];
f1=imfilter(X,k1);
f2=imfilter(X,k2);
f3=medfilt2(J);
figure(1)
subplot(2,1,1)
imshow(X);
title('Original Image');
subplot(2,1,2)
imshow(f1);
title('Low Pass Filtered / Smoothened Image');
figure(2)
subplot(2,1,1)
imshow(X);
title('Original Image');
subplot(2,1,2)
imshow(f2);
title('High Pass Filtered / Sharpened Image');
figure(3)
subplot(2,1,1)
imshow(J);
title('Noisy Image');
subplot(2,1,2)
imshow(f3);
title('Median Filtered Image after Noise Addition');
OUTPUT:
RESULT:
Image sharpening and smoothing was done using
MATLAB.