Escolar Documentos
Profissional Documentos
Cultura Documentos
ENCODING PROCESS
A PROJECT REPORT
Submitted by
SANKARI. K
RAGAVI. R
PARANIKA.S
BONAFIDE CERTIFICATE
Certified that this project report ECG SIGNAL COMPRESSION FOR LWT AND
SPIHT ENCODING PROCESS
SIGNATURE SIGNATURE
Assistant Professor
We give all glory and thanks to god almighty for showering upon us the
necessary wisdom and grace for accomplishing this project work.we express our
gratitude and thank our parents first for giving health as well as sound mind and
financial support for taking up this project.
We wish to express our special thanks to all our department faculties for their
inspiration ,help and guidance during the entire period of our project work. Finally,we
bow to all those who were directly and indirectly helpful for successful complection
of our project work.
ABSTRACT
wavelet transforms are used to compress the ECG signal by Set Partitioning in
Hierarchical Trees (SPIHT) algorithm and by incorporating lifting concepts. SPIHT
algorithm on wavelet transform which gives better simplicity and better compression
compared to the other techniques. But to scale the image more so as to get better
compression we are using the Lifting-based Wavelet transform (LWT) because it
requires lower memory without affecting the result of Wavelet transform.
TABLE OF CONTENTS
1 INTRODUCTION
1.1 Techniques used
1.2 Drawbacks
2 PROPOSED SYSTEM
2.1 Block diagram
2.2 Lifeting Wavelet Transform
2.2.1 Perfect reconstruction
2.2.2 The polyphace representation
2.2.3 Lifeting
2.3 Set pattitioning sorting algorithm
2.4 Lifeting scheme for wavelet transform
2.5 Software description
2.6 MATLAB Introduction
3 DEVELOPMENT ENVIRONMENT
3.1 Introduction
3.2 Starting and quitting MATLAB
3.3 Desktop tools
3.4 Manipulation matrices
3.4.1 Entering matrices
3.4.2 Expression
3.5 GUI
3.5.1 Creating GUIs with GUIDE
3.5.2 GUI development environment
3.5.3 The implementation of a GUI
3.5.4 Features of the GUIDE generated
Application M-file
3.6 Command-line accurability
3.7 User interface controls
ECG SIGNAL COMPRESSION USING LWT AND SPHIT
ENCODING PROCESS
CHAPTER.1
1. INTRODUCTION
ELECTROCARDIOGRAM (ECG) signal is a very useful source of
information for physicians in diagnosing heart abnormalities. With the
increasing use of ECG in heart diagnosis, such as 24 hour monitoring or in
ambulatory monitoring systems, the volume of ECG data that should be
stored or transmitted, has greatly increased. For example, a 3 channel, 24 hour
ambulatory ECG, typically has storage requirement of over 50 MB. Therefore
we need to reduce the data volume to decrease storage cost or make ECG signal
suitable and ready for transmission through common communication channels
such as phone line or mobile channel. So, we need an effective data compression
method
The main goal of any compression technique is to achieve maximum data
reduction while preserving the significant signal morphology features upon
reconstruction. Data compression methods have been mainly divided into two
major categories: 1) direct methods, in which actual signal samples are analyzed
(time domain), 2) transformational methods, in which first apply a transform to
the signal and do spectral and energy distribution analysis of signals.
Examples of direct methods are: differential pulse code modulation
(DPCM), amplitude zone time epoch coding (A TEC), turning point, coordinate
reduction time encoding system (CORTES), Fan algorithm, ASEC. Reference
[1] is a good review of some direct compression methods used in ECG
compression. Some of the transformations used in transformational compression
methods are Fourier transform, discrete cosine transform (DCT), Walsh
transform, Karhunen-Loeve transform (KLT), and wavelet transform.
1.1.Techniques Used
Discrete Cosine Transform
Huffman Coding
1.2.Drawbacks
Impossible to completely decorrelate the blocks at their boundaries
using DCT
2.PROPOSED SYSTEM
Lifting Wavelet transform
SPIHT
2.1.BLOCK DIAGRAM
2.2.LIFTING WAVELET TRANSFORM:-
(1)
The time reversion of the analyzing filters is necessary to compensate for the
delays in the filters. Without it, it would be impossible to arrive at a non-
delayed, perfectly reconstructed signal. If the conditions for perfect
reconstruction are fulfilled then all the aliasing caused by the subsampling will
be miraculously canceled in the reconstruction.
2.2.2. The polyphase representation
In the filter stage shown in the left part of figure 1 the signal is first filtered and
then subsampled. In other words, we throw away half of the filtered samples and
keep only the even-numbered samples, say. Clearly this is not efficient and
therefore we would like to do the subsampling before the filtering in order to
save some computing time. Let us take a closer look at what exactly is thrown
away by subsampling.
Figure 2. A standard FIR filter with subsampling of the output (top) and a more
efficient implementation (bottom).
In figure 2 we have drawn a standard FIR filter followed by a subsampler. If we
write down its output signal y(z), just before the subsampler, for several
consecutive samples, we get
(2)
Subsampling of y(z) will now remove the middle line (row) in (1) and all the
other odd lines (rows). We notice that with the odd lines removed the even-
numbered filter coefficients he are only used with even-numbered samples xe,
while the odd-numbered filter coefficients ho are only used with odd-numbered
samples xo. If we take the even bits together and name themhe(z)xe(z) and do the
same with the odd bits to form ho(z)xo(z), then we can write the subsampled
output signal ye(z) as
(3)
The delay z-1 in front of the odd part in (3) comes from the delay between even
and odd samples. (3) shows that we can redraw the FIR filter as shown in the
right part of figure 2. In this figure we have assumed (without loss of generality)
that n is even.
If we apply this remodeled FIR filter to our wavelet transform filter stage
in figure 1 we end up with two equations like (3), one for each filter, so that, if
we switch to vector notation, we can write
(4)
Where is the polyphase matrix [1]
(5)
(7)
where P(z) is a second polyphase matrix, the dual of the first,
(8)
Note that when we ignore the hats in (5), (8) is the transposed version of (5).
This polyphase matrix performs the inverse wavelet transform. In case of the
femmelet transform P(z) will be the unit matrix as well.
Figure 3. A one-stage filter bank for signal analysis and reconstruction using
polyphase matrices.
In figure 3 we have redrawn the filter stage of figure 1, this time using the
polyphase matrices. The delays we had in (4) and (7) are incorporated in
the split- and merge boxes. From thisfigure it will be clear that the condition for
perfect reconstruction now can be written as
(9)
Here we have time-reversed one of the two polyphase matrices because in order
for (9) to hold we need to cancel the delays caused by the polyphase matrices (a
FIR filter is a delay line, see figure 2).
If we assume that P(z) is invertible and if we use Cramers rule to calculate its
inverse, we find
(10)
From this it follows that if we demand that the determinant of P(z) = 1,
i.e. he(z)go(z) ho(z)ge(z) = 1, then not only will P(z) be invertible, but also
(11)
which implies that [2]
(12)
pair ( ).
Note that if the determinant of P(z) = 1 the filters he(z) and ho(z) have to be
relatively prime and we will exploit this property in the section on filter
factoring. Of course the pairs ge(z) andgo(z), he(z) and ge(z) and ho(z) and go(z)
will also be relatively prime.
Summarizing we can state that the problem of finding an invertible wavelet
transform using FIR filters amounts to finding a matrix P(z) with determinant 1.
From this matrix the four filters needed in the invertible wavelet transform
follow immediately. Compare this to the definition of the continuous wavelet
transform at the beginning of the wavelet tutorial. We sure have come a long
way! But there is more to come.
4. Intermezzo: Laurent polynomials
remainder is. This means that for any two Laurent polynomials
(15)
This division is not necessarily unique.
In the following sections we will unleash the power of algebra on the polyphase
matrices. The result will be an extremely powerful algorithm to build wavelet
transforms.
2.2.3. Lifting
As will be clear from our intermezzo the polyphase matrix is a matrix of Laurent
polynomials and since we demanded that its determinant be equal to 1, we know
that the filter pair (h,g) is complementary. The lifting theorem [Dau97] now
states that any other finite filter gnewcomplementary to h is of the form
(16)
where s(z2) is a Laurent polynomial. This can be seen very easily if we
write gnew in polyphase form (see also [3]) and assemble the new polyphase
matrix as
(17)
As can be easily verified the determinant of the new polyphase matrix also
equals 1, which proofs (16).
Similarly, we can apply the lifting theorem to create the filter new(z)
(18)
with the new dual polyphase matrix given by
(19)
What we just did is called primal lifting, we lifted the low-pass subband with the
help of the high-pass subband. figure 4 shows the effect of primal lifting
graphically.
Figure 4. Primal lifting, the low-pass subband is lifted with the help of the high-
pass subband.
We can also go the other way, that is lifting the high-pass subband with the help
of the low-pass subband and then it is called dual lifting. For dual lifting the
equations become
(20)
(21)
and
(22)
(23)
Dual lifting can be graphically displayed as in figure 5.
Figure 5. Dual lifting, the high-pass subband is lifted with the help of the low-
pass subband.
After all these equations and figures it should be clear how things work in the
lifting scheme and we can explain why this technique is called lifting. If we start
for example with the femmelet transform then both the polyphase matrices are
simply equal to the unit matrix. When we apply a primal- and/or a dual lifting
step to the femmelet transform we get a new wavelet transform which is a little
more sophisticated. In other words, we have lifted the wavelet transform to a
higher level of sophistication. We can perform as many lifting steps as we like
and therefore we can build highly sophisticated wavelet transforms.
The inverse lifting transform now also begins to take shape. If we start with a
femmelet transform we only split the input stream into an even and an odd
stream. Then we lift one of these streams as in the left of figures 4 and 5 by
applying a Laurent polynomial to the other and adding it to the first. We can
very easily undo this lifting step by again applying the same Laurent polynomial
to the other stream and then subtract it from the first. In other words, inverting a
lifting transform is the same as changing all the signs of the lifting Laurent
polynomials in figures 4 and 5 and run it backwards, i.e. start at the output.
Inverting the lifting scheme this way will always work! From this we can
Previous work to improve the visual quality of embedded coders has applied just
noticeable distortion thresholds for uniform noise in different subbands to
weight the transform coefficients but no distinction made between coefficients
belonging to different activity regions inside a subband. In this paper, the
differing activity regions are used to assign perceptual weights to the transform
coefficients prior to SPIHT encoding.
One of the main features of the proposed coding method is that the
ordering data is not explicitly transmitted. Instead, it is based on the fact that the
execution path of any algorithm is defined by the results of the comparisons on
its branching points. So, if the encoder and decoder have the same sorting
algorithm, then the decoder can duplicate the encoders execution path if it
receives the results of the magnitude comparisons, and the ordering information
can be recovered from the execution path.
One important fact used in the design of the sorting algorithm is that we do
not need to sort all coefficients. Actually, we need an algorithm that simply
called insignificant.
The sorting algorithm divides the set of pixels into partitioning subsets
Tm
------------- (3.18)
Max{ c } 2 n
i, j
( i , j )Tm
then it knows that all coefficients in , are insignificant. If the answer is yes
Tm
(the subset is significant), then a certain rule shared by the encoder and the
decoder is used to partition , into new subsets and the significance test is
Tm Tm ,l
then applied to the new subsets. This set division process continues until the
magnitude test is done to all single coordinate significant subsets in order to
identify each significant coefficient.
1; ---------------- (3.19)
S n (T ) Max{ c i, j } 2 n
( i , j )Tm
0; otherwise.
In order to define the new transform, we follow the general recipe for digital
wavelet transforms provided by In the most general terms, the lifting scheme
can be defined as follows:
(1)
4.
(2)
7.
(3)
with the update operator designed to preserve the DC (zero frequency)
(4)
and by constructing the update operator to preserve the running average of the
signal (Sweldens and Schrder, 1996), as follows:
(5)
the next scale computation takes , etc. so that the total number of
The digital wavelet transform is also easily invertible. Reversing the lifting
scheme operations provides the inverse transform algorithm, as follows:
1. Start with the coarsest scale data representation and the coarsest
scale residual .
2. Reconstruct the even component by reversing the operation in
equation 2, as follows:
(6)
3.
(7)
5.
6. Combine the odd and even components to generate the data at the
previous scale level and repeat the sequence of steps.
Figure 1 shows a classic benchmark image from the image analysis literature
and its digital wavelet transform using 2-D biorthogonal wavelets. Thanks to the
general smoothness of the ``Lena'' image, the residual differences from
equation 2 (stored as wavelet coefficients at different scales) have a small
dynamic range, which enables an effective compression of the image in the
transform domain. Wavelet compression algorithms are widely used in practice
for compression of natural images. As for compression of seismic data, the
classic DWT may not be optimal, because it does not take into account the
specific nature of seismic data patterns. In the next section, we turn the wavelet
transform into the seislet transform, which is tailored for representing seismic
data.
2.5.SOFTWARE DESCRIPTION
Getting Started
2.6.MATLAB INTRODUCTION
What Is MATLAB?
Development Environment. This is the set of tools and facilities that help you
use MATLAB functions and files. Many of these tools are graphical user
interfaces. It includes the MATLAB desktop and Command Window, a
command history, and browsers for viewing help, the workspace, files, and the
search path.
CHAPTER.3
3.DEVELOPMENT ENVIRONMENT
3.1.Introduction
This chapter provides a brief introduction to starting and quitting
MATLAB, and the tools and functions that help you to work with MATLAB
variables and files. For more information about the topics covered here, see the
corresponding topics under Development Environment in the MATLAB
documentation, which is available online as well as in print.
Starting MATLAB
You can change the directory in which MATLAB starts, define startup options
including running a script upon startup, and reduce startup time in some
situations.
Quitting MATLAB
MATLAB Desktop
When you start MATLAB, the MATLAB desktop appears,
containing tools (graphical user interfaces) for managing files, variables, and
applications associated with MATLAB.
You can change the way your desktop looks by opening, closing,
moving, and resizing the tools in it. You can also move tools outside of the
desktop or return them back inside the desktop (docking). All the desktop tools
provide common features such as context menus and keyboard shortcuts.
3.3.Desktop Tools
Command History
Launch Pad
Help Browser
Use the Help browser to search and view documentation for all
your Math Works products. The Help browser is a Web browser integrated into
the MATLAB desktop that displays HTML documents.
To open the Help browser, click the help button in the toolbar, or
type helpbrowser in the Command Window. The Help browser consists of two
panes, the Help Navigator, which you use to find information, and the display
pane, where you view the information.
Help Navigator
Product filter - Set the filter to show documentation only for the products you
specify.
Contents tab - View the titles and tables of contents of documentation for your
products.
Search tab - Look for a specific phrase in the documentation. To get help for
a specific function, set the Search type to Function Name.
Display Pane
Find a term in the page - Type a term in the Find in page field in the toolbar
and click Go.
MATLAB file operations use the current directory and the search
path as reference points. Any file you want to run must either be in the current
directory or on the search path.
Search Path
Workspace Browser
Array Editor
Editor/Debugger
3.4.MANIPULATING MATRICES
3.4.1.Entering Matrices
The best way for you to get started with MATLAB is to learn
how to handle matrices. Start MATLAB and follow along with each example.
A=
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
This exactly matches the numbers in the engraving. Once you have entered the
matrix, it is automatically remembered in the MATLAB workspace. You can
refer to it simply as A.
3.4.2.Expressions
Variables
Numbers
Operators
Functions
Variables
num_students = 25
Creates a 1-by-1 matrix named num_students and stores the value 25 in its
single element.
Numbers
1i -3.14159j 3e5i
All numbers are stored internally using the long format specified
by the IEEE floating-point standard. Floating-point numbers have a finite
precision of roughly 16 significant decimal digits and a finite range of roughly
10-308 to 10+308.
Operators
+ Addition
- Subtraction
* Multiplication
/ Division
\ Left division (described in "Matrices and Linear
Algebra" in Using MATLAB)
^ Power
' Complex conjugate transpose
() Specify evaluation order
Functions
help elfun
help specfun
help elmat
Some of the functions, like sqrt and sin, are built-in. They are
part of the MATLAB core so they are very efficient, but the computational
details are not readily accessible. Other functions, like gamma and sinh, are
implemented in M-files. You can see the code and even modify it if you want.
Several special functions provide values of useful constants.
Pi 3.14159265...
I Imaginary unit, -1
I Same as i
Eps Floating-point relative precision, 2-52
Realmin Smallest floating-point number, 2-1022
Realmax Largest floating-point number, (2- )21023
Inf Infinity
NaN Not-a-number
3.5.GUI
A FIG-file - contains a complete description of the GUI figure and all of its
children (uicontrols and axes), as well as the values of all object properties.
An M-file - contains the functions that launch and control the GUI and the
Note that the application M-file does not contain the code that
lays out the uicontrols; this information is saved in the FIG-file.
You can elect to have GUIDE generate only the FIG-file and write the
application M-file yourself. Keep in mind that there are no uicontrol creation
commands in the application M-file; the layout information is contained in the
FIG-file generated by the Layout Editor.
Selecting GUIDE Application Options - set both FIG-file and M-file options.
3.6.Command-Line Accessibility
When MATLAB creates a graph, the figure and axes are included
in the list of children of their respective parents and their handles are available
through commands such as findobj, set, and get. If you issue another plotting
command, the output is directed to the current figure and axes.
Push Buttons
Sliders
Toggle Buttons
Frames
Radio Buttons
Listboxes
Checkboxes
Popup Menus
Edit Text
Axes
Static Text
Figures
Push Buttons
Properties to Set
String - set this property to the character string you want displayed on the push
button.
Tag - GUIDE uses the Tag property to name the callback subfunction in the
application M-file. Set Tag to a descriptive name (e.g., close_button) before
activating the GUI.
When the user clicks on the push button, its callback executes.
Push buttons do not return a value or maintain a state.
Toggle Buttons
button_state = get(h,'Value');
if button_state == get(h,'Max')
end
Adding an Image to a Push Button or Toggle Button
a(:,:,1) = rand(16,128);
a(:,:,2) = rand(16,128);
a(:,:,3) = rand(16,128);
set(h,'CData',a)
Radio Buttons
Radio buttons have two states - selected and not selected. You
can query and set the state of a radio button through its Value property:
function mutual_exclude(off)
set(off,'Value',0)
The handles of the radio buttons are available from the handles
structure, which contains the handles of all components in the GUI. This
structure is an input argument to all radio button callbacks.
off = [handles.radiobutton2,handles.radiobutton3,handles.radiobutton4];
mutual_exclude(off)
.
.
Checkboxes
The Value property indicates the state of the check box by taking
on the value of the Max or Min property (1 and 0 respectively by default):
You can determine the current state of a check box from within
its callback by querying the state of its Value property, as illustrated in the
following example:
function checkbox1_Callback(h,eventdata,handles,varargin)
if (get(h,'Value') == get(h,'Max'))
else
% checkbox is not checked-take approriate action
end
Edit Text
Edit text controls are fields that enable users to enter or modify
text strings. Use edit text when you want text as input. The String property
contains the text entered by the user.
To obtain the string typed by the user, get the String property in
the callback.
user_string = get(h,'string');
You can use the following code in the edit text callback. It gets
the value of the String property and converts it to a double. It then checks if the
converted value is NaN, indicating the user entered a non-numeric character
(isnan) and displays an error dialog (errordlg).
function edittext1_Callback(h,eventdata,handles,varargin)
user_entry = str2double(get(h,'string'));
if isnan(user_entry)
end
Static Text
List Boxes
List boxes display a list of items and enable users to select one or
more items.
The Value property contains the index into the list of strings that
correspond to the selected item. If the user selects multiple items, then Value is a
vector of indices.
By default, the first item in the list is highlighted when the list
box is first displayed. If you do not want any item highlighted, then set the Value
property to empty, [].
The ListboxTop property defines which string in the list displays
as the top most item when the list box is not large enough to display all list
entries. ListboxTop is an index into the array of strings defined by the String
property and must have a value between 1 and the number of strings. Noninteger
values are fixed to the next lowest integer.
If Max - Min > 1, then list boxes allow multiple item selection.
If Max - Min <= 1, then list boxes do not allow multiple item selection.
Selection Type
MATLAB evaluates the list box's callback after the mouse button
is released or a keypress event (including arrow keys) that changes the Value
property (i.e., any time the user clicks on an item, but not when clicking on the
list box scrollbar). This means the callback is executed after the first click of a
double-click on a single item or when the user is making multiple selections.
Set the list box Callback property to the empty string ('') and
remove the callback subfunction from the application M-file. Leave the callback
subfunction stub in the application M-file so that no code executes when users
click on list box items.
The first choice is best if you are sure you will not use the list
box callback and you want to minimize the size and efficiency of the application
M-file. However, if you think you may want to define a callback for the list box
at some time, it is simpler to leave the callback stub in the M-file.
Popup Menus
When not open, a popup menu displays the current choice, which
is determined by the index contained in the Value property. The first item in the
list has an index of 1.
Popup menus are useful when you want to provide users with a
number of mutually exclusive choices, but do not want to take up the amount of
space that a series of radio buttons requires.
This callback checks the index of the selected item and uses a
switch statement to take action based on the value. If the contents of the popup
menu is fixed, then you can use this approach.
val = get(h,'Value');
switch val
case 1
case 2
% etc.
val = get(h,'Value');
string_list = get(h,'String');
% etc.
off - The control is disabled and its label (set by the string property) is
grayed out.
inactive - The control is disabled, but its label is not grayed out.
When a control is disabled, clicking on it with the left mouse
button does not execute its callback routine. However, the left-click causes two
other callback routines to execute:
Axes
Axes Callbacks
axes(handles.axes1).
makes the axes whose Tag property is axes1 the current axes, and therefore the
target for plotting commands. You can switch the current axes whenever you
want to target a different axes. See GUI with Multiple Axes for and example that
uses two axes.
Figure
Figures are the windows that contain the GUI you design with
the Layout Editor. See the description of figure properties for information on
what figure characteristics you can control.