SPlab
SPlab
DATE:
AIM:
To find realization of adaptive channel equalizer using MATLAB.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R2014a
THEORY:
PROCEDURE:
Step 1: Start the Matlab program.
Step 2: Open new Matlab file and type the program.
Step 3: Save in current dictionary
Step 4: Compile and Run the program.
Step 5: If any error occurs in the program correct the error and run the program.
Step 6: For the output see the command window/figure window.
Step 7: Stop the program
PROGRAM:
The output of adaptive channel equalizer using matlab has been successfully verified.
EXP NO: 2 REALIZATION OF SUB BAND FILTER USING
DATE : LINEAR CONVOLUTION
AIM:
To find a realization of sub band filter using linear convolution.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R2014a
THEORY:
A filter bank is an array of band pass filters that separates the input
signal into multiple components, each one carrying a single frequency sub-band
of the original signal. Convolution is a mathematical operation used to express
the relation between input and output of an LTI system.
PROCEDURE:
Step 1: Open Matlab software.
Step 2: Type the program and save the program then run it.
Step 3 : Enter the sequence as follows in the command window.
Step 4: Give first input sequence x[n].
Step 5: Give time index sequence nx .
Step 6: Give second input sequence h[n].
Step 7: Give time index sequence nh.
Step 8: Obtain the output graph for the given sequence.
PROGRAM:
% Matlab program to implement
% the above approach
clc;
x = input('Enter the 1st sequence: ');
nx = input('Enter the Time Index sequence: ');
h = input('Enter the second sequence: ');
nh = input('Enter the Time Index sequence: ');
figure;
stem(ny, y);
xlabel('Time');
ylabel('Amplitude');
title('Linear Convolution');
disp(y);
disp(ny);
DATE:
AIM:
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R2014a
THEORY:
In the context of signal processing, one of the key applications of Bayesian techniques
is Bayesian classification or Bayesian signal detection, where we aim to determine
which signal model best explains the observed data.
P(H1∣y)= P(y∣H1)P(H
EXP NO: 6 REALIZATION OF FIR WIENER FILTER
DATE:
AIM:
To find a realization of finite impulse response wiener filter.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R2014a
THEORY:
The Wiener Filter is the MSE-optimal stationary linear filter for images
degraded by additive noise and blurring. It executes an optimal trade off
between inverse filtering and noise smoothing.
PROCEDURE:
Step 1: Start the Matlab program.
Step 2: Open new Matlab file and type the program.
Step 3: Save in current dictionary
Step 4: Compile and Run the program.
Step 5: If any error occurs in the program correct the error and run the program.
Step 6: For the output see the command window/figure window.
Step 7: Stop the program
PROGRAM:
RESULT:
AIM:
To find a image compression using discrete cosine transformation (DCT).
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R2014a
THEORY:
PROCEDURE:
STEP1: Save an image in jpg format.
STEP 2: Open Matlab new file and upload the image (jpg format) in MATLAB.
STEP 3: Type the code in the compiler and call the uploaded image for
compression
STEP4: Run the program
STEP5: Check the output and verify it.
PROGRAM:
a=imread(‘black-and-gray-background-images(1).jpg’);
imshow(a);
ad=dct2(a);
h=imagesc(ad);
impixelregion(h);
OUTPUT :
RESULT:
The output of image compression using Discrete Cosine Transformation
(dct) has been verified.
EXP NO:3 REALIZATION OF STFT USING FFT
DATE:
AIM:
To find a realization of Short-time Fourier transform using FFT.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R2014a
THEORY:
The Short-time Fourier transform (STFT), is a Fourier-related transform used
to determine the sinusoidal frequency and phase content of local sections of a
signal as it changes over time. In practice, the procedure for computing STFTs
is to divide a longer time signal into shorter segments of equal length and then
compute the Fourier transform separately on each shorter segment. This reveals
the Fourier spectrum on each shorter segment. One then usually plots the
changing spectra as a function of time, known as a spectrogram or waterfall
plot, such as commonly used in Software Defined Radio (SDR) based spectrum
displays. Full bandwidth displays covering the whole range of an SDR
commonly use Fast Fourier Transforms (FFTs) with 2^24 points on desktop
computers.
PROCEDURE:
Step 1: Open Matlab new file.
Step2: Type the program and save the file.
Step3: Run the saved file and then give the input values in the command
window.
Step4: The output graph is plotted for the input values and it is verified.
PROGRAM:
%program for stft
close
all;
clear;
clc
load mtlb
n = 1:4001;
plot(n-1,mtlb);
xlabel('Time index n');
ylabel('Amplitude');
pause
specgram(mtlb,wl,7418,hamming(wl),ov)
OUTPUT:
Input the window length =
670
Input the desired overlap =
89
RESULT:
The output of Realization of Short – time Fourier transform using
FFT has been verified.
EXP NO: 14 FACE DETECTION AND TRACKING IN VIDEO
DATE: USING OPENCV
AIM:
To find a face detection and tracking in video using open cv.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: Python 3.9
THEORY:
Detecting faces is a process of machine learning. To apply that, we need
some trained data sets and library files for that process. For this process, I am
using the pre-trained data sets for the face detection process using OpenCV for
this process. The file used should be saved as a RAW file in the same directory
where your Python program for face detection exists. I provide the file below
for your usage. After that, while coding, you need to import the OpenCV and
specify the name of the file in your program.
PROCEDURE:
Step1: Open python software.
Step2: Create a new file and save it as filename.py
Step3: Import CV2 library file.
Step4: Save video as vtest.av.
Step5: Type the program and upload the video in the python software.
Step6: Compile and run the program.
Step7: A rectangular outline is obtained in the video by detecting and tracking
the face of the people in the video.
Step8: Check the output.
PROGRAM:
import cv2
import numpy as np
cap = cv2.VideoCapture('vtest.avi')
frame_width = int( cap.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height =int( cap.get( cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc('X','V','I','D')
out = cv2.VideoWriter("output.avi", fourcc, 5.0, (1280,720))
ret, frame1 = cap.read()
ret, frame2 = cap.read()
print(frame1.shape)
while cap.isOpened():
diff = cv2.absdiff(frame1, frame2)
gray = cv2.cvtColor(diff, cv2.COLOR_BGR2GRAY)import cv2
import numpy as np
cap = cv2.VideoCapture('vtest.avi')
frame_width = int( cap.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height =int( cap.get( cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc('X','V','I','D')
out = cv2.VideoWriter("output.avi", fourcc, 5.0, (1280,720))
ret, frame1 = cap.read()
ret, frame2 = cap.read()
print(frame1.shape)
while cap.isOpened():
diff = cv2.absdiff(frame1, frame2)
gray = cv2.cvtColor(diff, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray, (5,5), 0)
_, thresh = cv2.threshold(blur, 20, 255, cv2.THRESH_BINARY)
dilated = cv2.dilate(thresh, None, iterations=3)
contours, _ = cv2.findContours(dilated, cv2.RETR_TREE,
cv2.CHAIN_APPROX_SIMPLE)
for contour in contours:
(x, y, w, h) = cv2.boundingRect(contour)
if cv2.contourArea(contour) < 900:
continue
cv2.rectangle(frame1, (x, y), (x+w, y+h), (0, 255, 0), 2)
cv2.putText(frame1, "Status: {}".format('Movement'), (10, 20),
cv2.FONT_HERSHEY_SIMPLEX,
1, (0, 0, 255), 3)
#cv2.drawContours(frame1, contours, -1, (0, 255, 0), 2)
image = cv2.resize(frame1, (1280,720))
out.write(image)
cv2.imshow("feed",
frame1) frame1 = frame2
ret, frame2 = cap.read()
if cv2.waitKey(40) == 27:
break
cv2.destroyAllWindows()
cap.release()
out.release()
OUTPUT:
RESULT:
The output of face detection and tracking in video using open CV has been
verified.
EXP NO: 5 DEMONSTRATION OF MIN - MAX TECHNIQUE
DATE:
AIM:
To find a Demonstration of MIN – MAX technique.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R2014a
THEORY:
The "min" and "max" functions in MATLAB return the index of
the minimum and maximum values, respectively, as an optional second
output argument. For example, the following code produces a row vector
'M' that contains the maximum value of each column of 'A', which is 3 for
the first column and 4 for the second column.
PROCEDURE:
Step 1: Start the Matlab program.
Step 2: Open new Matlab file and type the program.
Step 3: Save in current dictionary
Step 4: Compile and Run the program.
Step 5: If any error occurs in the program correct the error and run the program.
Step 6: For the output see the command window/figure window.
Step 7: Stop the program
PROGRAM:
clc
clear all
close all
x=5;
y=7;
disp('max is');
if x > y
disp(x);
else
disp(y);
end
%max function
disp('using max function');
disp(max(x,y));
a=[1 2 8];
disp(max(a));
b=[1 5 7];
disp(max(a,b));
%for min replace max by min
disp('min is ');
disp(min(a,b));
OUTPUT:
RESULT:
The demonstration min-max technique using MATLAB was verified
successfully.
EXP NO: 8 DESIGN AND REALIZATION OF THE
ADAPTIVE DATE: FILTER USING LMS ALGORITHM
AIM: To design and realization of the adaptive filter using LMS Algorithm
using steepest descent algorithm.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R2014a
THEORY:
Least mean squares (LMS) algorithms are a class of adaptive filter used to
mimic a desired filter by finding the filter coefficients that relate to producing
the least mean square of the error signal (difference between the desired and the
actual signal).
Adaptive filters are digital filters whose coefficients change with an objective to
make the filter converge to an optimal state. The optimization criterion is a cost
function, which is most commonly the mean square of the error signal between
the output of the adaptive filter and the desired signal.
PROCEDURE:
Step 1: Start the Matlab program.
Step 2: Open new Matlab file and type the program.
Step 3: Save in current dictionary
Step 4: Compile and Run the program.
Step 5: If any error occurs in the program correct the error and run the program.
Step 6: For the output see the command window/figure window.
Step 7: Stop the program
PROGRAM:
%program for steepest decent algorithm
clc;
clear;
closeall;
%generating desired signal
t=0.001:0.001:1;
d=2*sin(2*pi*50*t);
%generating signal corrupted with noise
n=num1(D); A=D(1:n)
+0.9*randn(1,n);
M=25;
W=Zeros(M,1);
Wi=Zeros(M,1);
R=[];
K=1;
r=xcorr(A);
rr=[];
for i=1:1:M
rr(i)=r(n-i+1);
end
R=toeplitz(rr);
ei=max(eig(R));
u=1/ei;
p=xcorr(D,A);
for i=1:1:M
P(i)=p(n-i+1);
end
for i=1:10
wi=w+u*(p'-R*w);
w=wi
end
%Estimating the signal
Est=Zeros(n,1);
for i=M:n
j=A(i:-1:i-M+1);
Est(i)=(wi)'*j)';
end
%computing the error
signal Err=Est'-D;
%Display of signals
subplot(4,1,1),plot(D);
title('desired signal');
subplot(4,1,2),plot(A);
title('signal corrupted with
noise'); subplot(4,1,3),plot(Est);
title('Estimation signal');
subplot(4,1,4),plot(Err);
title('Error signal');
OUTPUT:
RESULT:
The design and realization of LMS algorithm using adaptive filter is
obtained successfully.
EXP NO: 12 SPEECH RECOGNITION USING OPEN CV
DATE:
AIM:
To recognize speech using python software.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: Python 3.9
THEORY:
PROCEDURE:
Step1: Open python software.
Step2: Create a new file and save it as filename.py
Step3: Import CV2 library file.
Step4: Save video as vtest.av.
Step5: Type the program and upload the video in the python software.
Step6: Compile and run the program.
Step7: A rectangular outline is obtained in the video by detecting and tracking
the face of the people in the video.
Step8: Check the output.
PROGRAM:
import speech_recognition as sr
#import audio nfile to the program
filename = "sample.wav”
#create recognizer instance
r = sr.Recognizer()
with sr.AudioFile(Filename) as source:
audio_date = r.record(source)
text = r.recognize_google(audio_data)
print(text)
OUTPUT:
RESULT:
The speech recognition using python is done successfully.