Last Exp - Digital Signal Processing

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

1) Signal Noise cancellation by Moving average filter

Code:

clear all
close all
clc
A=5;
wn=10;
t=0:0.01:1;
mf=6;
xmf=zeros(1,mf)
x=A*sin(wn*t)
awjn=.4*randn(size(t));
xn=A*sin(wn*t)+awjn;
xn=[xn zeros(1, mf-1)];

for i=1:length(xn)-mf+1
xmf(i)=mean(xn(i:i+mf-1));
end
figure;
subplot(311)
plot(t,x);
xlabel('Time')
ylabel('Amplitude')
subplot(312)
plot(t,xn(1:length(t)));
xlabel('Time')
ylabel('Amplitude')

subplot(313)
plot(t,xmf(1:length(t)));
title('Moving Average Filtered Signal')
xlabel('Time')
ylabel('Amplitude')

OUTPUT:
2) Filter design :
Code:
clc
clear all;
close all;
omegac=.3*pi;
L=100;
M=L/2;
l=-M:M;
h=omegac/pi*sinc(omegac*(l)/pi);
omega = 0:2*pi/200:pi;
Hd=freqz(h,l,omega);
plot((omega/pi),abs(Hd))
xlabel('Normalised frequency'), ylabel('Magnitude'),grid;
axis([-.1 1 0 1.2]);
grid on;
figure
plot(l,h)

OUTPUT:
3) Picture noise cancellation by Moving Average Filter:
Code:

originalImage = imread('E:/Radar_antenna.jpg');
Noise=imnoise(originalImage,'salt & pepper')
original = double(Noise);
filterSize = 3;
kernel = ones(filterSize) / filterSize^2;
filteredImage = imfilter(original, kernel);
filteredImage = uint8(filteredImage);

figure;
subplot(1, 3, 1);
imshow(originalImage, []);
title('Original Image');

subplot(1, 3, 2);
imshow(original, []);
title('Noise added Image');

subplot(1, 3, 3);
imshow(filteredImage, []);
title('Filtered Image');
OUTPUT:

You might also like