Vous êtes sur la page 1sur 42

EXPERIMENT NO: 1

Measurement of BIT ERROR RATE (BER) using binary data


Name: Md Arif Ahmed
Roll NO: 12H66D7007
Date: 06/07/2013

Aim: To measure BER of binary data

Apparatus:
Personal Computer
Matlab software

Theory:
In digital transmission, the number of bit errors is the number of received bits of a data
stream over a communication channel that have been altered due to noise, interference, distortion
or bit synchronization errors.
The bit error rate or bit error ratio (BER) is the number of bit errors divided by the total number
of transferred bits during a studied time interval. BER is a unitless performance measure, often
expressed as a percentage.
The bit error probability pe is the expectation value of the BER. The BER can be considered as
an approximate estimate of the bit error probability. This estimate is accurate for a long time
interval and a high number of bit errors.
As an example, assume this transmitted bit sequence:
0110001011
and the following received bit sequence:
0010101001

The number of bit errors (the underlined bits) is in this case 3. The BER is 3 incorrect bits
divided by 10 transferred bits, resulting in a BER of 0.3 or 30%.
Procedure:

1. Switch on the personal computer


2. Open mat lab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

Source Code:
clc;

% Clears the command window

clear all;

% Clears the work space

close all;

% Clears the figure window

n=32;

% Length of code word

k=15;

% Length of messages

dmin=6;

% Minimum distance

ebno=1:20;
ber_block=bercoding(ebno,'block','hard',n,k,dmin);
berfit(ebno,ber_block);

% Plots BER points & fitted curve

xlabel('ebno(db)');

% Reprsenting x axis

ylabel('bit error probability');

% Representing y axis

title('ber upper bound vs ebno, with best curve fit');

% Representing title

Result: Bit Error Rate is measured using binary data.

EXPERIMENT NO: 2
Verification of minimum distance of HAMMING Code
Name: Md Arif Ahmed
Roll NO: 12H66D7007
Date: 06/07/2013

Aim: To find the minimum distance of Hamming code

Apparatus:
Personal Computer
Matlab software

Theory:
The number of corresponding bits that differ between two code words is the Hamming
distance of those two code words. For example, the Hamming distance between the code words
1001 and 0101 is 2. The Hamming distance of two code words can be calculated as the number
of 1 bits in the bitwise exclusive-or of the two code words: 1001 xor 0101 = 1100.
A code is the set of all code words of a given length that are constructed by adding a
specified number of check digits in a specified way to a specified number of data bits. The
minimum Hamming distance of a code is the minimum of the Hamming distance between all
possible pairs of code words of that code. The following table indicates the Hamming distance
between all pairs of a simple 4-bit binary code:
The Hamming distances between code words of a simple 4-bit code.
In the below example shown the minimum Hamming distance between any two code words is
2, the Hamming distance of the code is 2.

0000

0011

0101

0110

1001

1010

1100

1111

0000

0011

0101

0110

1001

1010

1100

1111

Procedure:

1. Switch on the personal computer


2. Open matlab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

Source Code:

clc;

% Clears the command window

clear all;

% Clears the work space

close all;

% Clears the figure window

m=3;
n=2^m-1;

% Code word length

k=4;

% Message length

msg=[0 0 0 0; 0 0 0 1; 0 0 1 0;0 0 1 1;0 1 0 0;0 1 0 1;0 1 1 0;0 1 1 1];

code1=encode(msg,n,k,'hamming/binary');

% Encodes msg using hamming encoding

code2=num2str(code1);

% Converts array A into a string

code=bin2dec(code2);

% Interprets the binary string binstr & r


% Returns the equalent decimal number

number1=[];

% One decimal array of matrix

for i=1:8;
for j=i+1:8;
[number]=biterr(code(i),code(j),7);
% Compares code(i) & code(j) element
number1=[number1 number];
end
end
minidistance=min(number1)

% Returns the smallest elements

Result: Minimum distance of HAMMING code is verified

EXPERIMENT NO: 3
Determination of output of Convolutional Encoder for a given sequence
Name: Md Arif Ahmed
Roll NO: 12H66D7007
Date: 20/07/2013

Aim: To Determine the output of convolutional encoder for a given sequence


Apparatus:
Personal Computer
Matlab software

Theory:
Convolutional codes are used extensively in numerous applications in order to achieve
reliable data transfer, including digital video, radio, mobile communication, and satellite
communication. To convolutionally encode data, start with k memory registers, each holding 1
input bit. Unless otherwise specified, all memory registers start with a value of 0. The encoder
has n modulo-2 adders, and n generator polynomials one for each adder. An input bit m1 is
fed into the leftmost register. Using the generator polynomials and the existing values in the
remaining registers, the encoder outputs n bits. Now bit shift all register values to the right and
wait for the next input bit. If there are no remaining input bits, the encoder continues output until
all registers have returned to the zero state.

Procedure:

1. Switch on the personal computer


2. Open matlab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder

Source Code:

clc;

% Clears the command window

clear all;

% Clears the workspace

close all;

% Clears the figure window

g=input('enter the generator polynomial coefficient') ;

% Providing Input

[n,k]=size(g)

% Calculates n and constrained

lengths
m=k-1

% Number of registers

state=zeros(1,m)

% Set registers to zero

input1=input('enter the message bits')

% Input the message bits

b=zeros(1,m)

% Generate row matrix of length m

inputx=[input1,b]

% Zero Padding

[trash,h]=size(inputx)
outputy=[]
for x=1:h
input=inputx(1,x)
for i=1:n
output(i)=g(i,1)*input
for j=2:k
z=g(i,j)*state(j-1)
output(i)=xor(output(i),z)
end
end
state=[input,state(1:m-1)]
outputy=[outputy,output]

% New element added to sequence

end
outputy

% Final encoder output

Result: Output of convolutional encoder is determined for a given sequence

EXPERIMENT NO: 4
Determination of output of Convolutional Decoder for a given sequence
Name: Md Arif Ahmed
Roll NO: 12H66D7007
Date: 20/07/2013

Aim: To determine output of convolutional Decoder for a given sequence


Apparatus:
Personal Computer
Matlab software

Theory:
Several algorithms exist for decoding convolutional codes. For relatively small values of
k, the Viterbi algorithm is universally used as it provides maximum likelihood performance and
is highly parallelizable. Viterbi decoders are thus easy to implement in VLSI hardware and in
software on CPUs with SIMD instruction sets.
Longer constraint length codes are more practically decoded with any of several
sequential decoding algorithms, of which the Fano algorithm is the best known. Unlike Viterbi
decoding, sequential decoding is not maximum likelihood but its complexity increases only
slightly with constraint length, allowing the use of strong, long-constraint-length codes. Such
codes were used in the Pioneer program of the early 1970s to Jupiter and Saturn, but gave way to
shorter, Viterbi-decoded codes, usually concatenated with large Reed-Solomon error correction
codes that steepen the overall bit-error-rate curve and produce extremely low residual undetected
error rates. Both Viterbi and sequential decoding algorithms return hard decisions: the bits that
form the most likely codeword. An approximate confidence measure can be added to each bit by
use of the Soft output Viterbi algorithm.

Procedure:
1. Switch on the personal computer
2. Open matlab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

Source Code:

clc;

% Clears the command window

clear all;

% Clears the workspace

close all;

% Clears the figure window

tb=2;
% Length of positive integer scalar
t=poly2trellis([3],[7,5]);

% Converting the convolution code

polynomials encoded_sequence=[1 1 0 0 1 1]
decoded= vitdec(encoded_sequence,t,tb,'trunc','hard');

% Decoding using Viterbi Algorithm

Result: The output of convolutional decoder is determined for a given sequence.

EXPERIMENT NO: 5
Direct sequence spread spectrum technique
Name: Md Arif Ahmed
Roll NO: 12H66D7007
Date: 03/08/2013

Aim: To verify Direct sequence spread spectrum technique


Apparatus:
Personal Computer
Matlab software

Theory:

Direct-sequence spread spectrum has been adopted for many current and future
communication systems, and it is also used widely for military communication networks and
systems. One of the motivations for employing direct-sequence spread spectrum is its ability to
combat fading due to multipath propagation.
Different spread-spectrum techniques are available, but all have one idea in common: the
key (also called the code or sequence) attached to the communication channel. The manner of
inserting this code defines precisely the spread-spectrum technique. The term "spread spectrum"
refers to the expansion of signal bandwidth. The formal definition of spread spectrum is more
precise: an RF communications system in which the baseband signal bandwidth is intentionally
spread over a larger bandwidth by injecting a higher frequency signal (Figure 1). As a direct
consequence, energy used in transmitting the signal is spread over a wider bandwidth, and
appears as noise. The ratio (in dB) between the spread baseband and the original signal is called
processing gain. Typical spread-spectrum processing gains run from 10dB to 60dB.To apply a
spread-spectrum technique, simply inject the corresponding spread-spectrum code somewhere in
the transmitting chain before the antenna (receiver). (That injection is called the spreading
operation.) The effect is to diffuse the information in a larger bandwidth. Conversely, you can

remove the spread-spectrum code (called a despreading operation) at a point in the receive chain
before data retrieval. A despreading operation reconstitutes the information into its original
bandwidth. Obviously, the same code must be known in advance at both ends of the transmission
channel. (In some circumstances, the code should be known only by those two parties.)

Procedure:

1. Switch on the personal computer


2. Open matlab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

Source Code:

clc;

% Clears the command window

clear all;

% Clears the workspace

close all;

% Clears the figure window

% Generating the bit pattern with each bit 6 samples long

b=round(rand(1,20));

% Round the nearest uniformly


%distributed pseudo random numbers

pattern=[];

% Construct pattern generator object

for k=1:20
if b(1,k)==0
sig=zeros(1,6)

% Create array of all zeros

else
sig=ones(1,6)

% Creates array of all ones

end
pattern=[pattern sig];
end
plot(pattern);
axis([-1 130 -0.5 1.5]);
title('\bit\if original bit sequence');

% Generating the pseudorandom bit pattern for spreading

spread_sig=round(rand(1,120));

% Round the nearest uniformly


%distributed pseudorandom numbers

figure,
plot(spread_sig);

% Plot spread signal

axis([-1 130 -0.5 1.5]);


title('\bit\if pseudorandom bit sequence');
% Add title to current axis

% XOR ing the pattern with spread signal

hopped_sig=xor(pattern,spread_sig);

% Perform the logical exclusive or


%operation

% Modulating the Hopped signal

dsss_sig=[];
t=[0:100];
fc=0.1;
c1=cos(2*pi*fc);

% Creates the cosine signal1

c2=cos(2*pi*fc*t+pi);

% Creates the cosine signal2

for k=1:120
if hopped_sig(1,k)==0;

% If the hopped signal is zero then


%perform the signal1

dsss_sig=[dsss_sig c1]
else
dsss_sig=[dsss_sig c2]

% If the hopped signal is zero then


%perform the signal2

end
end
figure,
plot(dsss_sig);
axis([-1 212 -1.5 1.5]);
figure,
plot(abs(fft(dsss_sig)));

% Plotting the fft of dsss signal

title('absolute value of dsss');

% Plots absolute value if the discrete


% sequence spread spectrum signal

Result: Direct Sequence Spread Spectrum Technique is Verified

EXPERIMENT NO: 6
Verification of DFT and IDFT on RGB image
Name: Md Arif Ahmed
Roll NO: 12H66D7007
Date: 17/08/2013

Aim: To verify DFT and IDFT on RGB image

Apparatus:
Personal Computer
Matlab software

Theory:

The discrete Fourier transform (DFT) is a fundamental transform in digital signal


processing, with applications in frequency analysis, fast convolution, image processing, etc.
Moreover, fast algorithms exist that make it possible to compute the DFT very efficiently. In
image processing, the samples can be the values of pixels along a row or column of a raster
image.
The discrete Fourier transform (DFT) is "the Fourier transform for finite-length
sequences" because, unlike the (discrete-space) Fourier transform, the DFT has a discrete
argument and can be stored in a finite number of infinite word-length locations. Yet, it turns out
that the DFT can be used to exactly implement convolution for finite-size arrays. Our approach
to the DFT will be through the discrete Fourier series DFS, which is made possible by the
isomorphism between rectangular periodic and finite-length, rectangular-support sequences.
Definition (discrete Fourier transform)

For a finite-support sequence


for integers

and

with support

, we define its DFT

as follows.

The inverse DFT (IDFT) exists and is given by

Procedure:

1. Switch on the personal computer


2. Open mat lab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

Source Code:

clc;

% Clears the command window

clear all;

% Clears the workspace

close all;

% Clears the figure window

img =imread('water.jpg');

% Reading image from a file

subplot(2,2,1);

% Create and control multiple axis

imshow(img);

% Displays rgb image

title('RGB IMAGE');

% Displays title of the image

i=rgb2gray(img);

% Converts RGB image into Gray image

subplot(2,2,2);

% Create and control multiple axis

imshow(i);

% Displays gray image of RGB

title('gray image');

% Displays title of the image

j=fft2(i);

% Perform DFT operation on gray image

subplot(2,2,3);

% Create and control multiple axis

imshow(j);

% Displays fft of gray

title('fft of gray image');

% Displays title of the image

k=ifft2(j);

% Perform IDFT operation on gray


% image

subplot(2,2,4);

% Create and control multiple axis

imshow(k, [0 255]);

% Displays IDFT image

title('idft of gray image');

% Displays title of the image

Result: DFT and IDFT operations are performed on RGB image and verified

EXPERIMENT NO: 7
Verification of DCT AND IDCT on RGB image
Name: Md Arif Ahmed
Roll NO: 12H66D7007
Date: 24/08/2013

Aim: To verify DCT and IDCT on RGB image

Apparatus:
Personal Computer
Matlab software

Theory:

The discrete cosine transform (DCT) is used to transform a signal from the spatial
domain into the frequency domain. The reverse process, that of transforming a signal from the
frequency domain into the spatial domain, is called the inverse discrete cosine transform (IDCT).
A signal in the frequency domain contains the same information as that in the spatial domain.
The order of values obtained by applying the DCT is coincidentally from lowest to highest
frequency.
This feature and the psychological observation that the human eye and ear are less sensitive to
recognizing the higher-order frequencies leads to the possibility of compressing a spatial signal
by transforming it to the frequency domain and dropping high-order values and keeping loworder ones. When reconstructing the signal, and transforming it back to the spatial domain, the
results are remarkably similar to the original signal.
This process, with a few extra bells and whistles and slightly modified versions of DCT, is the
essence behind jpeg, mpeg, and mp3 compression.

Here, we look at a simplified case of compression using the DCT and IDCT without bells and
whistles. The process:

X = Apply DCT to a sequence of values.

X' = Drop a portion of high-order values from X.

X'' = Apply IDCT to X'

Draw X'' and observe the similarity to the original X.

Procedure:

1. Switch on the personal computer


2. Open mat lab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

Source Code:

clc;

% Clears the command window

clear all;

% Clears the workspace

close all;

% Clears the figure window

RGB = imread('rose2.jpg');

% Reading image from a file

subplot(4,3,1);

% Create and control multiple axis

imshow(RGB);

% Displays RGB image

title('RGB Image');

% Displays title of the image

I = rgb2gray(RGB);

% Converts RGB image into Gray image

subplot(4,3,2);

% Create and control multiple axis

imshow(I);

% Displays gray image

title('GRAY image');

% Displays title of the image

J = dct2(I);

% Perform DCT operation on gray image

subplot(4,3,3);

% Create and control multiple axis

imshow(log(abs(J)),[]), colormap(jet(64)), colorbar


J(abs(J) < 10) = 0;

% Make zero if <10

title('DCT of the gray image);

% Displays title of the image

K = idct2(J);

% Performs IDCT operation

subplot(4,3,4);

% Create and control multiple axis

imshow(K,[0 255]);

% Displays IDCT of gray image

title('IDCT image');

% Displays title of the image

IR=dct2(RGB(:,:,1));

% Separating R(Red) from original image

subplot(4,3,5);

% Create and control multiple axis

imshow(IR);

% Displays separated R(red) image

title('DCT image of R');

% Displays title of the image

IG=dct2(RGB(:,:,2));

% Separating G(Green) from original image

subplot(4,3,6);

% Create and control multiple axis

imshow(IG);

% Displays separated G(Green) image

title('DCT image of G');

% Displays title of the image

IB=dct2(RGB(:,:,3));

% Separating B(Blue) from original image

subplot(4,3,7 );

% Create and control multiple axis

imshow(IB);

% Displays separated B(Blue) image

title('DCT image of B');

% Displays title of the image

RI=idct2(IR);

% Reconstructing R(Red) image

subplot(4,3,8);

% Create and control multiple axis

imshow(RI,[0,255]);

% Displays reconstructed R(Red) image

title('IDCT image of R');

% Displays title of the image

GI=idct2(IG);

% Reconstructing G(Green) image

subplot(4,3,9);

% Create and control multiple axis

imshow(GI,[0,255]);

% Displays reconstructed G(Green) image

title('IDCT image of G');

% Displays title of the image

BI=idct2(IB);

% Reconstructing B(Blue) image

subplot(4,3,10);

% Create and control multiple axis

imshow(BI,[0,255]);

% Displays reconstructed B(Blue) image

title('IDCT image of B');

% Displays title of the image

RGBO(:,:,1)=RI
RGBO(:,:,2)=GI
RGBO(:,:,3)=BI
subplot(4,3,11);

% Create and control multiple axis

imshow(uint8(RGBO));

% Combining and reconstructing

title('Reconstrcuted original image from R,G,B');

% Displays title of the image

Result: DCT and IDCT operations are performed on RGB image and verified

EXPERIMENT NO: 8
Verification of DFT, DCT, IDFT & IDCT on RGB image
Name: Md Arif Ahmed
Roll NO: 12H66D7007
Date: 31/08/2013

Aim: To verify DFT, DCT, IDFT and IDCT on RGB image

Apparatus:
Personal Computer
Matlab software

Theory:
The discrete Fourier transform (DFT) is a fundamental transform in digital signal
processing, with applications in frequency analysis, fast convolution, image processing, etc.
Moreover, fast algorithms exist that make it possible to compute the DFT very efficiently. In
image processing, the samples can be the values of pixels along a row or column of a raster
image.
The discrete Fourier transform (DFT) is "the Fourier transform for finite-length
sequences" because, unlike the (discrete-space) Fourier transform, the DFT has a discrete
argument and can be stored in a finite number of infinite word-length locations. Yet, it turns out
that the DFT can be used to exactly implement convolution for finite-size arrays. Our approach
to the DFT will be through the discrete Fourier series DFS, which is made possible by the
isomorphism between rectangular periodic and finite-length, rectangular-support sequences.
Definition (discrete Fourier transform)

For a finite-support sequence


for integers

and

with support

, we define its DFT

as follows.

The inverse DFT (IDFT) exists and is given by

The discrete cosine transform (DCT) is used to transform a signal from the spatial
domain into the frequency domain. The reverse process, that of transforming a signal from the
frequency domain into the spatial domain, is called the inverse discrete cosine transform (IDCT).
A signal in the frequency domain contains the same information as that in the spatial domain.
The order of values obtained by applying the DCT is coincidentally from lowest to highest
frequency. This feature and the psychological observation that the human eye and ear are less
sensitive to recognizing the higher-order frequencies leads to the possibility of compressing a
spatial signal by transforming it to the frequency domain and dropping high-order values and
keeping low-order ones. When reconstructing the signal, and transforming it back to the spatial
domain, the results are remarkably similar to the original signal.
Procedure:

1. Switch on the personal computer


2. Open mat lab software

3. Open new editor m file


4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

Source Code:

clc;

% Clears the command window

clear all;

% Clears the workspace

close all;

% Clears the figure window

pic=imread('petdog.jpg');

% Reading image from a file

subplot(3,3,1);

% Create and control multiple axis

imshow(pic);

% Displays RGB image

title('RGB Image');

% Displays title of the image

i=rgb2gray(pic);

% Converts RGB image into Gray image

subplot(3,3,2);

% Create and control multiple axis

imshow(i);

% Displays gray image

title('GRAY image');

% Displays title of the image

j=fft2(i);

% Perform DFT operation on gray image

subplot(3,3,3);

% Create and control multiple axis

imshow(j);
title('DFT of the gray image');

% Displays title of the image

k=dct2(j);

% Perform DCT operation on gray image

subplot(3,3,4);

% Create and control multiple axis

imshow(log(abs(k)),[]), colormap(jet(64)), colorbar


k(abs(k) < 10) = 0;
title('DCT of the dft image');

% Displays title of the image

l=idct2(k);

% Performs IDCT operation

subplot(3,3,5);

% Create and control multiple axis

imshow(l,[0 255]);

% Displays IDCT of gray image

title('IDCT of the DCT image');

% Displays title of the image

m=ifft2(l);

% Perform IDFT operation on gray image

subplot(3,3,6);

% Create and control multiple axis

imshow(m,[0 255]);

% Displays IDFT image

title('idft of idct image');

% Displays title of the image

Result: DFT, DCT, IDCT and IDFT operations are performed and verified for an RGB image

EXPERIMENT NO: 9
Edge, Line and Point Detection Techniques
Name: Md Arif Ahmed
Roll NO: 12H66D7007
Date: 21/09/2013

Aim: To study Edge, Line and Point Detection Techniques using Derivative Operators.

Apparatus:
Personal Computer
Matlab software

Theory:
The three basic types of gray level discontinuities in a digital image are: points, lines
and edges.
Point detection
The detection of the point is straightforward in principle. Using the mask(laplacian mask)
shown below we can say a point is detected at the location, on which the mask is centered,if |R|
>= T where T is a nonnegative threshold value. The idea is that an isolated point(a point whose
gray level is significantly different from its background) will be quite different from the
surroundings and can be easily detectable with this type of mask. The mask response R will be
zero at areas of constant gray level.
-1 -1 -1
-1 8

-1

-1 -1 -1

Line Detection
The next level of complexity is the Line detection.Consider the masks shown below.
If the given mask were moved around an image,it will respond to lines which are oriented
horizontally.With a constant background ,the maximum response would result when the line
passed through the middle row of the mask.
-1 -1 -1
2

-1 -1 -1

A similar mask as shown below, responds best to the lines oriented at +45 degrees.This is easily
verified by sketching a simple array of 1's with a line of different gray level(say 5's) running
diagonally through the array.
-1 -1 2
-1 2
2

-1

-1 -1

The lines which are oriented vertically, respond best to the mask given below.

-1 2 -1
-1 2 -1
-1 2 -1

Edge Detection
Althoughpoint and line detection are important,edge detection is the most common
approach for detecting meaningful disocontinuities in gray level. In this section ,we discuss
approaches for implementing first- and second- order level derivatives for the detection of edges
in the image.Edge detection is complicated with false edges created by image noise. The number
of false edges can be lowered by using image noise reduction techniques before detecting edges.
Procedure:

1. Switch on the personal computer


2. Open mat lab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

Source Code for Edge Detection:

clc;

% Clears the command window

clear all;

% Clears the workspace

close all;

% Clears the figure window

i=imread('cameraman.tif');

% Reads image from a file

subplot(3,2,1);

% Create and control multiple axis

imshow(i);

% Displays original image

title('original mage');

% Representing title of the image

j=edge(i,'sobel');

% Finding sobel edge detection in gray scale image

subplot(3,2,2);

% Create and control multiple axis

imshow(j);

% Displays sobel image

title('sobel edge detection');

% Representing title of the image

k=edge(i,'prewitt');

% Finding prewitt edge detection in gray scale image

subplot(3,2,3);

% Create and control multiple axis

imshow(k);

% Displays prewitt image

title('prewitt edge detection');

% Representing title of the image

l=edge(i,'robert');

% Finding robert edge detection in gray scale image

subplot(3,2,4);

% Create and control multiple axis

imshow(l);

% Displays robert image

title('robert edge detction');

% Representing title of the image

h=edge(i,'log');

% Finding logarithmic edge detection in gray scale image

subplot(3,2,5);

% Create and control multiple axis

imshow(h);

% Displays logarithmic image

title('log edge detection');

% Representing title of the image

Source Code For Line Detection:


clc;

% Clears the command window

clear all;

% Clears the workspace

close all;

% Clears the figure window

f=imread('cameraman.tif');

% Reads image from a file

subplot(2,2,1);

% Create and control multiple axis

imshow(f);

% Displays original image

title('original mage');

% Representing title of the image

g=edge(f,'horizontal');

% Finding horizontal edges in gray image

h=edge(f,'vertical');

% Finding vertical edges in gray image

subplot(2,2,2);

% Create and control multiple axis

imshow(g);

% Displays horizontal edge image

title('horizontal gradient componenet');

% Representing title of the image

subplot(2,2,3);

% Create and control multiple axis

imshow(h);

% Displays vertical edge image

title('vertical gradient component');

% Representing title of the image

k=g+h;

% Combining horizontal and vertical edge images

subplot(2,2,4);

% Create and control multiple axis

imshow(k);

% Displays combined image

title('combining the edges');

% Representing title of the image

Source Code for Point Detection:

clc;

% Clears the command window

clear all;

% Clears the workspace

close all;

% Clears the figure window

i=imread('swan.jpg');
H=[1 1 1;1 -8 1;1 1 1];
b=imfilter(i,H);

% N-D filtering in multidimensional image

subplot(1,2,1);

% Create and control multiple axis

imshow(i);

% Diaplays original image

title('original image');

% Represnting title of the image

subplot(1,2,2);

% Create and control multiplea axis

imshow(b);

% Displays filtered image

title('point detection');

% Representing title of the image

Result: EDGE, LINE and POINT Detection techniques using different operators are verified.

Procedure for writing Programs using DSP Kit

1. Open Code Composer Studio and select C6713 Simulator click save and quit.
2. Start a new project using project/new .
3. Pull down menu, save it in a separate directory (c:/my project) with file name (sine
wave.pjt).
4. Create a new source file using File/New/Source file menu and save it in folder ( in c)
5. Add the source file (sine wave.c) to the project.
6. Now go to Project menu click on add files to the project and select the File name
(sinewave.c)
7. Pull down menu and click on project and click on add files to the project now add the
Linker Command file Hello.cmd (Path:c:/cc studio/tutorial/dsk6713/hello/hello.cmd).
8. Add the run time support library file RTS6700.lib again go to project and click on add
files to project (Path:c/cc studio/cg tools/lib/rts6700.lib)
9. Complete the program using project compile pull down main menu or by ctrl+f7.
10. Build the program using project build pull down menu.
11. Load the program in the program memory of DSP kit using the file load program using
the pull down menu and now load Sinewave.out file.
12. Run the program using Debug pull down menu or run F5.
13. To View output Graphically select view/graph/time and frequency

EXPERIMENT NO: 10
Generation of Sine wave and Square wave using TMS320C6713 DSK

Name: Md Arif Ahmed


Roll NO: 12H66D7007
Date: 28/09/2013

Aim: To generate sine wave and Square wave using TMS320C6713 DSK ( DSP Starter Kit).

Apparatus:
1. TMS320C6713 DSK
2. Personal Computer
3. Code Composer Studio Software

Theory:
The sine wave or sinusoid is a mathematical curve that describes a smooth repetitive
oscillation. It is named after the function sine, of which it is the graph. It occurs often in pure and
applied mathematics, as well as physics, engineering, signal processing and many other fields. Its
most basic form as a function of time (t) is:

where:

A, the amplitude, is the peak deviation of the function from zero.

f, the ordinary frequency, is the number of oscillations (cycles) that occur each second of
time.

= 2f, the angular frequency, is the rate of change of the function argument in units of
radians per second

, the phase, specifies (in radians) where in its cycle the oscillation is at t = 0.

When is non-zero, the entire waveform appears to be shifted in time by the amount /
seconds. A negative value represents a delay, and a positive value represents an advance.
A square wave is a non-sinusoidal periodic waveform (which can be represented as an
infinite summation of sinusoidal waves), in which the amplitude alternates at a steady frequency
between fixed minimum and maximum values, with the same duration at minimum and
maximum. The transition between minimum to maximum is instantaneous for an ideal square
wave; this is not realisable in physical systems. Square waves are often encountered in
electronics and signal processing.

Source code for Sine wave:

#include<stdio.h>
#include<math.h>

float a[500];
void main()
{
int i=0;
for(i=0;i<500;i++)
{
a[i]=sin (2*3.14*2000*i);
}
}

Source code for square wave:


#include<stdio.h>
#include<math.h>
int a[1000];
void main()
{
int i,J=0;
int b=5;
for(i=0;i<10;i++)
{
for(J=0;J<=50;J++)
{
a[(100*i)+J]=b;
}
b=b*(-1);
}
}

Result: Sine wave and Sqaure wave are generated using TMS320C6713 DSK.

EXPERIMENT NO: 11
Generation of FIR Filter using TMS320C6713 DSK

Name: Md Arif Ahmed


Roll NO: 12H66D7007
Date: 28/09/2013

Aim: To generate FIR Filter using TMS320C6713 DSK ( DSP Starter Kit).

Apparatus:
1. TMS320C6713 DSK
2. Personal Computer
3. Code Composer Studio Software

Theory:
In signal processing, a finite impulse response (FIR) filter is a filter whose impulse
response (or response to any finite length input) is of finite duration, because it settles to zero in
finite time. This is in contrast to infinite impulse response (IIR) filters, which may have internal
feedback and may continue to respond indefinitely (usually decaying). The impulse response of
an Nth-order discrete-time FIR filter lasts for N + 1 samples, and then settles to zero. FIR filters
can be discrete-time or continuous-time, and digital or analog. The output y of a linear time
invariant system is determined by convolving its input signal x with its impulse response b.
For a discrete-time FIR filter, the output is a weighted sum of the current and a finite
number of previous values of the input. The operation is described by the following equation,
which defines the output sequence y[n] in terms of its input sequence x[n]:

where :

is the input signal,

is the output signal,

are the filter coefficients, also known as tap weights, that make up the impulse
response,

is the filter order; an

th-order filter has

terms on the right-hand side.

Source code:
#include<stdio.h>
#include<math.h>
# define pi3.1415
int n,N,c;
float wr[64],wt[64];
void main()
{
printf("\n enter no of samples N=;");
scanf("%d",&N);
printf("\n enter choice of window function \n 1.rect\n 2.triang\n c=:");
scanf("%d",&c);
printf("\n elements of window function are:");
switch(c)
{
case 1:
for(n=0;n<=N-1;n++)
{
wr[n]=1;
printf("\n wr[%d]=%f",n,wr[n]);
}
break;

case 2:
for(n=0;n<=N-1;n++)
{
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt(%d)=%f",n,wt[n]);
}
break;
}
}

Result: FIR Filter is generated using TMS320C6713 DSK

Result Analysis:
When the bit-error-rate is high, many bits will be in error. The worst-case bit-error-rate is
4%percent, at which point, the modem is essentially useless. Most communications systems
require bit-error-rates several orders of magnitude lower than this.
Even a bit-error-rate of one percent is considered quite high. We usually want to plot a
curve of the bit-error-rate as a function of the SNR, and include enough points to cover a wide
range of bit-error-rates. At high SNRs, this can become difficult, since the bit-error-rate becomes
very low. For example, a bit-error-rate of 10^6 means only one bit out of every million bits will
be in error.
In our test signal only contains 1000bits, we will most likely not see an error at this biterror-rate. In order to be statistically significant, each simulation we run must generate some
number of errors. If a simulation generates no errors, I t does not mean the bit-error-rate is zero;
it only means we did not have enough b its in our transmitted signal. As a rule of thumb, we need
about 100 (or more) errors in each simulation, in order to have confidence that our bit-error-rate
is statistically valid. At high SNRs, this can require a test signal containing millions, or even
billions of bits.

Result Analysis:
Hamming codes have a minimum distance of 3, which means that the decoder can detect
and correct a single error, but it cannot distinguish a double bit error of some codeword from a
single bit error of a different codeword. Thus, they can detect double-bit errors only if correction
is not attempted.

Result Analysis:
K = number of bits shifted into the encoder at one time
K =2 is used here
N = number of encoder output bits corresponding to the K information bits
r=k /n= code rate
K= constraint length, encoder memory
Each encoded bit is a function of the present input bits and their past ones.
The operation of a convolutional encoder can be represented using state diagrams and trellis
diagrams. State diagrams give a compact representation of the encoding process, but hide the
evolution of the encoding process over time. Trellis diagrams give that extra dimension.

Result Analysis:

Consider a polynomial of a length of positive integers scalar that defines a track depth
convert the convolution code polynomial code into trellis description and decode to convolution
data using veterbi decoder.
Here i had considered the same encoder inputs for which the output obtained is using
viterbi decoding algorithm.

Output:
Minimum distance of hamming code is 2

Vous aimerez peut-être aussi