50
1 IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET TRANSFORM A PROJECT REPORT Submitted by BHARATHI A.L.N. RAJU G. (41501106023) HARI B.V.S. (41501106036) PAVAN KIRAN .KOTTU (41501106063) PAVAN KISHORE .KOTTU (41501106064) in partial fulfillment for the award of the degree of BACHELOR OF ENGINEERING in ELECTRONICS AND COMMUNICATION ENGINEERING S.R.M. ENGINEERING COLLEGE, KATTANKULATHUR-603 203, KANCHEEPURAM DISTRICT. ANNA UNIVERSITY : CHENNAI - 600 025 MAY 2005

IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET TRANSFORM

Embed Size (px)

DESCRIPTION

A PROJECT REPORTSubmitted byBHARATHI A.L.N. RAJU G. (41501106023)HARI B.V.S. (41501106036)PAVAN KIRAN .KOTTU (41501106063)PAVAN KISHORE .KOTTU (41501106064)

Citation preview

Page 1: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

1

IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET

TRANSFORM

A PROJECT REPORT

Submitted by

BHARATHI A.L.N. RAJU G. (41501106023)

HARI B.V.S. (41501106036)

PAVAN KIRAN .KOTTU (41501106063)

PAVAN KISHORE .KOTTU (41501106064)

in partial fulfillment for the award of the degree

of

BACHELOR OF ENGINEERING

in

ELECTRONICS AND COMMUNICATION ENGINEERING

S.R.M. ENGINEERING COLLEGE, KATTANKULATHUR-603 203, KANCHEEPURAM DISTRICT.

ANNA UNIVERSITY : CHENNAI - 600 025

MAY 2005

Page 2: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

2

BONAFIDE CERTIFICATE

Certified that this project report "IMAGE COMPRESSION AND

DECOMPRESSION USING WAVELET TRANSFORM" is the bonafide work of

"BHARATHI A.L.N. RAJU G. (41501106023), HARIB.V.S. (41501106036),

PAVAN KIRAN .KOTTU (41501106063) and PAVAN KISHORE .KOTTU

(41501106064)" who carried out the project work under my supervision.

Prof. Dr. S. JAYASHRI Mr. R. RAMESH

HEAD OF THE DEPARTMENT SUPERVISOR

Lecturer

ELECTRONICS AND ELECTRONICS AND

COMMUNICATON ENGG. COMMUNICATON ENGG.

S.R.M. Engineering College S.R.M. Engineering College

Kattankulathur - 603 203 Kattankulathur - 603 203

Kancheepuram District Kancheepuram District

ACKNOWLEDGEMENT

We would like to express our gratitude to our chairman,

Thiru.T.R.Pachamuthu for having provided us with all the facilities to build our

project successfully.

We sincerely thank our honorable principle, Prof.R.Venkataramani whose

solicit presence gave us immense boost to complete this project.

Page 3: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

3

We earnestly thank Prof. Dr. S.Jayashri, Head of the Department, E.C.E, for

her constant advice, support and valuable guidance.

We are indebted to both our internal guide Mr.R.RAMESH and our external

guide, Mr.S.THAMINMUN ANSARI, for their support in accomplishing this

project.

We are obliged to our teaching and non-teaching staff for their kind assistance.

We also express our profound gratitude towards the persons who have directly

or indirectly helped us in completing this project successfully.

ABSTRACT The aim of the project is to implement the Wavelet Transform to any time varying

signal and analyze the signal obtained. The sharp discontinuities / spikes present in the

signal can be viewed due to the special property of wavelet transforms which is to

indicate at what time what frequency is present. The ultimate goal is to implement its

typical and most common application to an image and show excellent results of

compression using wavelets and how information in the image is retained.

There are two closely interlinked reasons for compression.

� Firstly, to reduce the size of stored or transmitted files to manageable sizes, or

to reduce the time it would take to transmit these files.

� Secondly, to reduce the real-time bandwidth required to transmit time-sensitive

video data across a communication link.

The more efficient the compression technique, the more complicated the algorithm

will be and thus, requires more computational resources or more time to decompress.

This tends to affect the speed of the process. With the use of a DSP processor we can

Page 4: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

4

overcome the limitation that occurs in the process. The DSP processor we worked

with, in this project is TMS320VC5416.

TABLE OF CONTENTS

CHAPTER NO. TITLE PAGE

NO.

ABSTRACT iii

LIST OF FIGURES vi

LIST OF ABBREVATIONS vii

1 INTRODUCTION TO IMAGE COMPRESSION

1.1 Introduction 2

1.2 Need for Image Compression 3

1.3 Basic Types of Compression 4

2 WAVELET TRANSFORM TECHNIQUE

2.1 Wavelet Transform 8

2.1.1 Introduction 2.1.2 Comparison of signals using Fourier

Transform 2.1.3 Adoption of STFT 2.1.4 Conclusion

8 9

11 12

3 PROCESS INVOLVED IN COMPRESSION TECHNIQUE

3.1 Image Compression & Decompression Process 14

3.1.1 BMP File 3.1.2 Wavelet Forward Transform 3.1.3 Thresholding 3.1.4 Run Length Encoding and Decoding

Techniques 3.1.5 Inverse Wavelet Transform

14 16 20

21 24

Page 5: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

5

4 DIGITAL SIGNAL PROCESSOR

4.1 Introduction to DSP 26

4.2 TMS320C5416 DSP Processor 27

4.2.1 Description

4.2.2 Architecture and Specifications

27

28

4.3 Application Areas of DSP 32

5 TMS320C5416 ASSEMBLY LANGUAGE PROGRAM

5.1 Extraction of Pixel and Header Information 34

5.2 Wavelet Forward Transform 34

5.2.1 Row Forward

5.2.2 Column Forward

34

35

5.3 Thresholding 36

5.4 Run – Length Encoding 36

5.5 Decoding 37

5.6 Wavelet Inverse Transform 38

5.6.1 Inverse Column Forward

5.6.2 Inverse Row Forward

38

39

5.7 Implementation using DSP Processor 39

5.8 Real time Application using TMS320C5416 41

5.9 Result 54

6 7

CONCLUSION REFERENCES

56

58

LIST OF FIGURES

FIGURE NO.

TITLE PAGE NO.

1.1 Representation of Compression Techniques 5

1.2 Coding Techniques Tree 6

2.1 Graphical Representation of a Stationary Signal 8

2.2 Graphical Representation of a Non Stationary Signal 9

Page 6: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

6

2.3 Graphical Representation of Fourier Transformed Stationary Signal

10

2.4 Graphical Representation of Fourier Transformed Non-Stationary Signal

10

3.1 Steps involved in Compression Technique 14

3.2 BMP File Format 15

3.3 Types of BMP Files 15

4.1 Architecture of TMS320C5416 DSP Processor 28

LIST OF ABBREVIATIONS ALU -- Arithmetic Logic Unit

BMP -- BIT MAP

CB -- C Bus

CAB -- C Address Bus

CPU -- Central Processing Unit

DB -- D Bus

DAB -- D Address Bus

DCT -- Discreet Cosine Transform

EB -- E Bus

EAR -- EAB Address Register

EOF -- End Of Flow

FT -- Fourier Transform

ISDN -- Integrated Switching Device Network

RLE -- Run-Length Encoding

STFT -- Short Term Fourier Transform

Page 7: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

7

Chapter-1

Introduction to Image Compression

1.1 Introduction:

Compression techniques are playing an important role in the world of

telecommunication and multimedia systems where bandwidth is still a valuable

commodity. Hence, image compression techniques are of prime importance for

reducing the amount of information needed for the picture without losing much of its

quality, judged by human viewers.

The history of compression begins in the 1960s. An analogue videophone system had

been tried out in the 1960s, but it required a wide bandwidth and the postcard-size

black-and-white pictures produced did not add appreciably to voice communication!

There are two closely interlinked reasons for compression.

� Firstly, to reduce the size of stored or transmitted files to manageable sizes, or

to reduce the time it would take to transmit these files to another computer.

� Secondly, to reduce the real-time bandwidth required to transmit time-sensitive

video data across a communication link.

Communications equipment like modems, bridges, and routers use compression

schemes to improve throughput over standard phone lines or leased lines. Compression

is also used to compress voice telephone calls transmitted over leased lines so that

more calls can be placed on those lines.

As is the case with any form of communication, compressed data communication only

works when both the sender and receiver of the information understand the encoding

scheme. For example, this text makes sense only if the receiver understands that it is

intended to be interpreted as characters representing the English language. Similarly,

compressed data can only be understood if the decoding method is known by the

receiver.

Page 8: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

8

Text can typically be compressed to approximately 40% of its original size, and

graphics files from 20% to 90%. Some files compress very little. It depends entirely on

the type of file and compression algorithm used. Some schemes are reversible so that

the original data can be reconstructed (lossless data compression), while others accept

some loss of data in order to achieve higher compression (lossy data compression).

1.2 Need for image compression:

An image, 1024 pixel x 1024 pixel x 24 bit, without compression, would require 3 MB

of storage and 7 minutes for transmission, utilising a high speed, 64 Kbit/s, ISDN line.

If the image is compressed at a 10:1 compression ratio, the storage requirement is

reduced to 300 KB and the transmission time drops to under 6 seconds. Seven 1 MB

images can be compressed and transferred to a floppy disk in less time than it takes to

send one of the original files, uncompressed, over an AppleTalk network.

In a distributed environment large image files remain a major bottleneck within

systems. Compression is an important component of the solutions available for

creating file sizes of manageable and transmittable dimensions. Increasing the

bandwidth is another method, but the cost sometimes makes this a less attractive

solution.

Platform portability and performance are important in the selection of the

compression/decompression technique to be employed.

1.3 Basic types of compression:

Compression comes in two basic flavors: lossless (or information preserving) and

lossy.

• Lossless compression With lossless compression, data is compressed

without any loss of data. It assumes you want to get everything back that you

put in i.e., we can reconstruct a perfect reproduction of the original from the

compression. Critical financial data files are examples where lossless

compression is required.

• Lossy compression With lossy compression, it is assumed that some loss of

information is acceptable. When you reconstruct the information from the

Page 9: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

9

compressed data, you get something close to but not exactly the same as the

original. You can get more compression by allowing the algorithm to lose more

information. Lossy compression algorithms usually have an adjustable

parameter to control this compression vs. quality tradeoff.

The best example is a videoconference where there is an acceptable amount of

frame loss in order to deliver the image in real time. People may appear jerky

in their movements, but you still have a grasp for what is happening on the

other end of the conference. In the case of graphics files, some resolution may

be lost in order to create a smaller file. The loss may be in the form of color

depth or graphic detail. For example, high-resolution details can be lost if a

picture is going to be displayed on a low-resolution device. Loss is also

acceptable in voice and audio compression, depending on the desired quality.

Figure 1.1

Representation of compression techniques.

Lossy compression can provide compression ratios of 100:1 to 200:1, depending on

the type of information being compressed. Lossless compression ratios usually only

achieve a 2:1 compression ratio. Lossy compression techniques are often "tunable" in

that you can turn the compression up to improve throughput, but at a loss in quality.

Compression can also be turned downed to the point at which there is little loss of

image, but throughput will be affected.

Page 10: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

10

Lossy compression is very useful for images, audio signals, or other information that is

perceived through our senses. It is not, however, useful for text, numerical data,use of

scanners to locate details in images, etc. where there is a precise meaning for the data.

Even for images or other perceived signals, lossless compression is sometimes

required, particularly for legal documents, medical images, etc. Imagine the field day a

lawyer would have when he finds out that a patient was misdiagnosed from a "lossy"-

compressed image. It doesn't seem to matter that the lossy version may be perceptually

indistinguishable from the lossless version--the very term "lossy" sends the doctors

and lawyers scurrying.

Some of the data compression techniques:

• Lossless coding techniques

o Run length encoding

o Huffman encoding

o Entropy coding (Lempel/Ziv)

o Area coding

• Lossy coding techniques

o Transform coding (DCT/Wavelets/Gabor)

o Vector quantization

o Segmentation and approximation methods

o Spline approximation methods (BilinearInterpolation/Regularisation)

o Fractal coding (texture synthesis, iterated functions system [IFS],

recursive IFS [RIFS])

Page 11: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

11

Figure 1.2

Coding Techniques Tree

Page 12: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

12

Chapter-2

Wavelet Transform Technique

2.1. WAVELET TRANSFORM:

2.1.1. Introduction:

The reason why we choose wavelet transform goes way down to other transforms

like Fourier and short time Fourier transforms. So let us have a brief look of both

these transforms starting with fourier transform:

We generally have two types of signals.

� Stationary signals

� Non-stationary signals

Stationary signals:

Signals whose frequency content do not change in time are called stationary

signals. In this case, one does not need to know at what times frequency

components exist , since all frequency components exist at all times.

For example the following signal:

x(t)=cos(2*pi*10*t)+cos(2*pi*25*t)+cos(2*pi*50*t)+cos(2*pi*100*t)

Equation -1

is a stationary signal, because it has frequencies of 10, 25, 50, and 100 Hz at any

given time instant. This signal is plotted below:

Figure 2.1

Graphical representation of a Stationary signal (equation-1)

Page 13: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

13

Non Stationary signal:

A signal with different frequency components at different time intervals, hence a non-

stationary signal .The frequency content of non stationary signals change in time. In

this case one should know what frequency components occur at what times.

Figure 2.2 Graphical representation of a non-stationary signal

2.1.2. Comparison of the signals using Fourier Transform: The top plot in Figure 2.3 is the (half of the symmetric) frequency spectrum of the

signal in Figure 2.1. The bottom plot is the zoomed version of the top plot, showing

only the range of frequencies that are of interest to us. Note the four spectral

components corresponding to the frequencies 10, 25, 50 and 100 Hz.

Fourier transform of the stationary signal:

Page 14: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

14

Figure 2.3 Graphical representation of Fourier Transformed stationary signal

tFourier transform of non-stationary signal:

Figure 2.4

Graphical representation of Fourier transformed non-stationary signal

Page 15: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

15

Now, compare the Figures 2.3 and 2.4. The similarity between these two spectrum

should be apparent. Both of them show four spectral components at exactly the same

frequencies, i.e., at 10, 25, 50, and 100 Hz. Other than the ripples, and the difference

in amplitude (which can always be normalized), the two spectrums are almost

identical, although the corresponding time-domain signals are not even close to each

other. Both of the signals involves the same frequency components, but the first one

has these frequencies at all times, the second one has these frequencies at different

intervals. So, how come the spectrums of two entirely different signals look very

much alike? Recall that the FT gives the spectral content of the signal, but it gives no

information regarding where in time those spectral components appear. Therefore, FT

is not a suitable technique for non-stationary signal.

2.1.3. Adoption of STFT:

To overcome this we adopt SHORT TIME FOUTIER TRANSFORM (STFT), which

is the modified version of Fourier transform. In STFT, the non stationary signal is

divided into small portions, which are assumed to be stationary. This is done using a

window function of a chosen width (i.e., fixed), which is shifted and multiplied with

the signal to obtain the Short Time Fourier Transform of the signal.

The problem with STFT goes back to Heisenberg uncertainty principle which states

that it is impossible for one to obtain which frequencies exist at which time instance,

but one can obtain the frequency bands existing in a time interval. This gives rise to

resolution issue where there is trade off between the time resolution and frequency

resolution. To assume stationary the window is supposed to be narrow, which results

in a poor frequency resolution, i.e., it is difficult to know the exact frequency

components that exist in the signal; only the band of frequencies that exist is obtained.

If the width of the window is increased, frequency resolution improves but time

resolution becomes poor, i.e., it is difficult to know what frequencies occur at which

time intervals. Also, choosing a wide window may violate the condition of

stationarity.

2.1.4. Conclusion:

The Wavelet Transform solves the above problem to a certain extent. In contrast to

STFT, which uses a single analysis window, the wavelet transform uses short

windows at high frequencies and long windows at low frequencies. This results in

Page 16: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

16

multi resolution analysis by which the signal is analyzed with different resolutions at

different frequencies, i.e., both frequency resolution and time resolution vary in the

time frequency plane without violating the Heisenberg inequality.

Therefore, the wavelet transform can be defined as a mathematical tool that

decomposes a signal into a representation that shows signal details and trends as a

function of time. This representation can be used to characterise transient events,

reduce noise, compress data, and perform many other operations. The main

advantages of wavelet methods over traditional Fourier methods are the use of

localised basis functions and the faster computation speed. Localised basis functions

are ideal for analyzing real physical situations in which a signal contains

discontinuities and sharp spikes.

Wavelet transform (which was developed in last two decades) is capable of providing

the time and frequency information simultaneously, hence giving a better time-

frequency representation of the signal than any other existing transforms.

Chapter-3

Process involved in Compression Technique

3.1. Image Compression and Decompression Process:

The basic block diagram showing the steps involved in the process of image

compression and de-compression.

Page 17: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

17

Figure 3.1

Steps involved in Compression Technique.

3.1.1 BMP FILE:

A BMP file consists of two parts mainly.

a) HEADER consists of information about the image and is same for all the

images of its type.

b) PIXEL is the content of the image and it varies depending upon the type

and content of the image file.

Figure 3.2

BMP file format.

BMP FILE

EXTRACT HEADER &

PIXEL INFO.

ROW

FORWARD

COLUMN

FORWARD

THRESHOLD

RUN- LENGTH

ENCODING

DECODING

INVERSE ROW

FORWARD

INVERSE COLUMN

FORWARD

WAVELET FORWARD TRANSFORM

WAVELET INVERSE TRANSFORM

COLUMN FORWARD

HEADER

PIXEL

INFORMATION ABOUT THE IMAGE

CONTENT OF THE IMAGE BMP FILE

Page 18: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

18

Types of BMP Files:

Figure 3.3

Types of BMP files

Colour Image:

It consists of 54 bytes of header information. One pixel occupies 3 byte memory

space in which Red, Green and Blue occupies 1 byte each.

Grey Scale Image:

An optical pattern consisting of discrete steps or shades of gray between black and

white is known as grey scale image.It consists of 1078 bytes of header information. In

this type of image one pixel occupies one byte memory and its values range from 0 to

255. 0 represents black and 255 represents white.

Black & White Image:

It consists of 1078 bytes of header information. This type of image also occupies one

byte memory for every pixel. 0 represents black and 1 represents white.

Extraction:

This process includes the extraction of header information and pixel information from

the input image file. Pixel information varies from image to image those results in the

process where as the header information remains the same.

3.1.2 Wavelet Forward Transform:

It is a mathematical tool that decomposes a signal into a representation that shows

signal details and trends as a function of time. The wavelet transform or wavelet

analysis is probably the most recent solution to overcome shortcomings of fourier

transform. In this type of transform as frequency increases the time resolution

BMP FILE

COLOUR IMAGE

GREY SCALE

IMAGE

BLACK & WHITE IMAGE

Page 19: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

19

increases; likewise as frequency decreases the frequency resolution increases. Thus a

certain high frequency component can be located more accurately in time than a low

frequency component and a low frequency component can be located more accurately

in frequency compared to a high frequency component.

Types of wavelet algorithms:

There are a wide variety of popular wavelet algorithms. Some of them are

� Haar Wavelets

� Daubechies Wavelets

� Mexican Hat Wavelets

� Morlet Wavelets

Why Haar Wavelets?

Of these algorithms, including Daubechies wavelets, Mexican Hat wavelets and

Morlet wavelets have the advantage of better resolution for smoothly changing time

series. But they have the disadvantage of being more expensive to calculate than the

Haar wavelets. The higher resolution provided by these wavelets is not worth the cost

for financial time series (no1n-stationary), which are characterized by jagged

transitions.

Haar Wavelets:

The Haar wavelet algorithms are applied to time series1 where the number of samples

is a power of two (e.g., 2, 4, 8, 16, 32, 64...) The Haar wavelet uses a rectangular

window to sample the time series. The first pass over the time series uses a window

width of two. The window width is doubled at each step until the window

encompasses the entire time series.

Each pass over the time series generates a new time series and a set of coefficients.

The new time series is the average of the previous time series over the sampling

window. The coefficients represent the average change in the sample window. For

1 A time series is simply a sample of a signal or a record of something, like

temperature, water level or market data (like equity close price).

Page 20: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

20

example, if we have a time series consisting of the samples si, si+1, si+2... then the Haar

wavelet equations is

where ci is the wavelet coefficient.

The Haar transform preserves the average in the smoothed values (this is not true of

all wavelet transforms). The scaling function produces a smoother version of the data

set, which is half the size of the input data set. Wavelet algorithms are recursive and

the smoothed data becomes the input for the next step of the wavelet transform. The

Haar wavelet scaling function is

where ai is a smoothed value.

Function of various Filters in Wavelet Transform:

High pass filter

In digital signal processing (DSP) terms, the wavelet function is a high pass filter.

A high pass filter allows the high frequency components of a signal through while

suppressing the low frequency components. For example, the differences that are

captured by the Haar wavelet function represent high frequency change between

an odd and an even value.

Low pass filter

In digital signal processing (DSP) terms, the scaling function is a low pass filter. A

low pass filter suppresses the high frequency components of a signal and allows

the low frequency components through. The Haar scaling function calculates the

average of an even and an odd element, which results in a smoother, low pass

signal.

Page 21: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

21

In the wavelet literature this tree structured recursive algorithm is referred to as a

pyramidal algorithm.

Wavelets allow a time series to be viewed in multiple resolutions. Each resolution

reflects a different frequency. The wavelet technique takes averages and differences

of a signal, breaking the signal down into spectrum. All the wavelet algorithms work

on time series a power of two values (e.g., 64, 128, 256...). Each step of the wavelet

transform produces two sets of values: a set of averages and a set of differences (the

differences are referred to as wavelet coefficients). Each step produces a set of

averages and coefficients that is half the size of the input data. For example, if the

time series contains 256 elements, the first step will produce 128 averages and 128

coefficients. The averages then become the input for the next step (e.g., 128 averages

resulting in a new set of 64 averages and 64 coefficients). This continues until one

average and one coefficient (e.g., 20) is calculated.

The average and difference of the time series is made across a window of values.

Most wavelet algorithms calculate each new average and difference by shifting this

window over the input data. For example, if the input time series contains 256 values,

the window will be shifted by two elements, 128 times, in calculating the averages

and differences. The next step of the calculation uses the previous set of averages,

also shifting the window by two elements. This has the effect of averaging across a

four element window. Logically, the window increases by a factor of two each time.

The Haar wavelet transform has a number of advantages:

• It is conceptually simple.

• It is fast.

• It is memory efficient, since it can be calculated in place without a temporary

array.

• It is exactly reversible without the edge effects that are a problem with other

wavelet transforms.

• Works better (comparatively) for financial time series applications.

Page 22: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

22

3.1.3 Thresholding:

In certain signals, many of the wavelet coefficients are close or equal to zero. Through

a method called thresholding, these coefficients may be modified so that the sequence

of wavelet coefficients contains long strings of zeros. Through a type of compression

known as entropy coding, these long strings may be stored and sent electronically in

much less space. There are different types of thresholding.

� Hard thresholding

� Soft thresholding

� Quantile thresholding

Hard Thresholding:

In hard thresholding, a tolerance is selected. Any wavelet whose absolute value falls

below the tolerance is set to zero with the goal to introduce many zeros without losing

a great amount of detail. There is not a straight forward easy way to choose the

threshold, although the larger the threshold that is chosen the more error that is

introduced into the process.

Soft Thresholding:

This is another type of thresholding known as soft thresholding. Once again a

tolerance, h, is selected. If the absolute value of an entry is less than the tolerance,

than that entry is set to zero. All other entries, d, are replaced with sign(d)||d| - h|. Soft

thresholding can be thought of as a translation of the signal toward zero by the

amount h.

Quantile Thresholding:

A third type of thresholding is quantile thresholding. In this method a percentage p of

entries to be eliminated are selected. The smallest (in absolute value) p percent of

entries are set to zero.

Page 23: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

23

We generally use hard thresholding in order to obtain high output efficiency with out

much loss and altering of data.

3.1.4 Run Length Encoding and Decoding Techniques:

Run-length encoding (RLE) is a very simple form of data compression in which runs

of data (that is, sequences in which the same data value occurs in many consecutive

data elements) are stored as a single data value and count, rather than as the original

run. This is most useful on data that contains many such runs; for example, simple

graphic images such as icons and line drawings.

Example:

The string:

"aaaabbcdeeeeefggggghhhiiiij"

may be replaced with

"a4b2c1d1e5f1g5h3i4j1".

The numbers are in bold to indicate that they are values, not symbols.

RLE works by reducing the physical size of a repeating string of characters. This

repeating string, called a run, is typically encoded into two bytes. The first byte

represents the number of characters in the run and is called the run count. In practice,

an encoded run may contain 1 to 128 or 256 characters; the run count usually contains

as the number of characters minus one (a value in the range of 0 to 127 or 255). The

second byte is the value of the character in the run, which is in the range of 0 to 255,

and is called the run value. A black-and-white image that is mostly white, such as the

page of a book, will encode very well, due to the large amount of contiguous data that

is all the same color.

Make sure that your RLE encoder always stops at the end of each scan line of bitmap

data that is being encoded. There are several benefits to doing so. Encoding only a

simple scan line at a time means that only a minimal buffer size is required. Encoding

only a simple line at a time also prevents a problem known as cross-coding.

Cross-coding is the merging of scan lines that occurs when the encoded process loses

the distinction between the original scan lines. If the data of the individual scan lines

Page 24: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

24

is merged by the RLE algorithm, the point where one scan line stopped and another

began is lost or, at least, is very hard to detect quickly.

When an encoder is encoding an image, an end-of-scan-line marker is placed in the

encoded data to inform the decoding software that the end of the scan line has been

reached. This marker is usually a unique packet, explicitly defined in the RLE

specification, which cannot be confused with any other data packets. End-of-scan-line

markers are usually only one byte in length, so they don't adversely contribute to the

size of the encoded data.

Encoding Strings

Encoding using RLE is fairly simple. The following process can be implemented to

attain encoding:

Step 1. Set the previous symbol equal to an unmatchable value.

Step 2. Read the next symbol from the input stream.

Step 3. If the symbol is an EOF exit.

Step 4. Write out the current symbol.

Step 5. If the symbol is an does not match the previous symbol, set the previous

symbol to the current symbol, and go to step 2.

Step 6. Read and count additional symbols until a non-matching symbol is found.

This is the run length.

Step 7. Write out the run length.

Step 8. Write out the non-matching symbol.

Step 9. Set the previous symbol to the non-matching symbol, and go to step 2.

Decoding strings

Decoding is even easier than encoding. Not only are there less steps, but there are no

caveats. To decode an encoded stream the following steps are followed:

Step 1. Set the previous symbol equal to an unmatchable value.

Step 2. Read the next symbol from the input stream.

Page 25: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

25

Step 3. If the symbol is an EOF exit.

Step 4. Write out the current symbol.

Step 5. If the symbol is an does not match the previous symbol, set the previous

symbol to the current symbol, and go to step 2.

Step 6. Read the run length.

Step 7. Write out the current symbol for the amount indicated by the run length.

Step 8. Go to step 1.

3.1.5 INVERSE WAVELET TRANSFORM: The forward wavelet transform is an invertible mapping; in fact and this process is the

inverse mapping of the forward wavelet transform. Let us consider ci, ci+1, ….. as

wavelet coefficients and ai, ai+1, …. as wavelet averages or smoothed values, then the

required original data si, si+1,… can be obtained by the following inverse wavelet

equations.

si = ai + ci

si+1 = ai - ci

The obtained output data constitutes to the final decompressed image.

Chapter-4

Digital Signal Processor

4.1 Introduction to DSP

A signal is any variable that carries information. Examples of the types of

signals of interest are

� Speech (telephony, radio, everyday communication).

� Biomedical signals (EEG brain signals).

� Sound and music.

� Video and image.

� Radar signals (range and bearing).

Page 26: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

26

Digital signal processing (DSP) is concerned with the digital representation of signals

and the use of digital processors to analyse, modify, or extract information from

signals.

Many signals in DSP are derived from analogue signals which have been

sampled at regular intervals and converted into digital form.

The key advantages of DSP over analogue processing are

� Guaranteed accuracy (determined by the number of bits used).

� Perfect reproducibility.

� No drift in performance due to temperature or age.

� Takes advantage of advances in semiconductor technology.

� Greater flexibility (can be reprogrammed without modifying hardware).

� Superior performance (linear phase response possible, and filtering algorithms

can be made adaptive).

� Sometimes information may already be in digital form.

There are however (still) some disadvantages

� Speed and cost (DSP design and hardware may be expensive, especially with

high bandwidth signals)

� Finite wordlength problems (limited number of bits may cause degradation).

4.2 TMS320VC5416 DSP PROCESSOR

4.2.1 Description:

The TMS320VC5416 fixed-point, digital signal processor (DSP) (hereafter referred to

as the 5416 unless otherwise specified) is based on an advanced modified Harvard

architecture that has one program memory

bus and three data memory buses. This processor provides an arithmetic logic unit

(ALU) with a high degree of parallelism, application-specific hardware logic, on-chip

memory, and additional on-chip peripherals. The

basis of the operational flexibility and speed of this DSP is a highly specialized

instruction set.

Separate program and data spaces allow simultaneous access to program instructions

and data, providing a high degree of parallelism. Two read operations and one write

Page 27: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

27

operation can be performed in a single cycle. Instructions with parallel store and

application-specific instructions can fully utilize this architecture. In addition, data

can be transferred between data and program spaces. Such parallelism supports a

powerful set of arithmetic, logic, and bit-manipulation operations that can all be

performed in a single machine cycle. The 5416 also includes the control mechanisms

to manage interrupts, repeated operations, and function calls.

Enhanced Harvard architecture built around one program bus, three data buses, and

four address buses for increased performance and versatility.

Advanced CPU design with a high degree of parallelism and application specific

hardware logic for increased performance. A highly specialized instruction set for

faster algorithms and for optimized high-level language operation. Modular

architecture design for fast development of spinoff devices. Advanced IC processing

technology for increased performance and low power consumption. Low power

consumption and increased radiation hardness because of new static design

techniques. These are some of the major advantages offered by C5416.

4.2.2 Architecture and Specifications

Page 28: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

28

Fig.4.1

Architecture of TMS320C54X DSP Processor

It comprises the central processing unit (CPU), memory and on-chip peripherals. The

‘54x DSP`s use an advanced modified Harvard architecture that maximizes

processing power with eight buses. Separate program and data spaces allow

simultaneous access to program instructions and data, providing a high degree of

parallelism. For example, 3 reads and 1 write can be performed in a single cycle.

Instructions with parallel store and application-specific instructions fully utilize this

architecture. In addition, data can be transferred between data and program spaces.

Such parallelism supports a powerful set of arithmetic, logic and bit-manipulation

Page 29: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

29

operations that can all be performed in a single machine cycle. Also, the ‘54x includes

the control mechanisms to manage interrupts, repeated operations, and function

calling.

CPU

• Advanced multi-bus architecture with one program bus, three data buses

and four address buses

• 40-bit arithmetic logic unit (ALU), including a 40-bit barrel shifter and two

independent 40-bit accumulators

• 17-bit x 17-bit parallel multiplier coupled to a 40-bit dedicated adder for

non-pipelined single-cycle multiply/accumulate (MAC) operation

• Exponent encoder to compute the exponent of a 40-bit accumulator value in

a single cycle

• Two address generators, including eight auxiliary registers and two

auxiliary registers arithmetic units

MEMORY

•192K words x 16-bit addressable memory space (64K- words program, 64K-

words data and 64K-words I/O), with extended program memory.

• It has got high speed On chip memory.

BUSES

The ‘54x architecture is built around eight major 16-bit buses (four program/data

buses and four address buses):

• The program bus (PB) carries the instruction code and immediate operands

from program memory.

• Three data buses (CB, DB and EB) interconnect to various elements, such as

the CPU, data address generation logic, program address generation, and on-

chip peripherals and data memory.

• The CB and DB carry the operands that are read from data memory.

• The EB carries the data to be written to memory.

Page 30: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

30

• Four address buses (PAB, CAB, DAB and EAB) carry the addresses needed

for instruction execution.

ADDRESSING MODES

The ‘54x offers seven basic data addressing modes:

• Immediate addressing uses the instruction to encode a fixed value

• Absolute addressing uses the instruction to encode a fixed address

• Accumulator addressing uses accumulator A to access a location in program

memory as data

• Direct addressing uses seven bits of the instruction to encode the lower

seven bits of an address. The seven bits are used with the data page pointer

(DP) or the stack pointer (SP) to determine the actual memory address

• Indirect addressing uses the auxiliary registers to access memory

• Memory-mapped registers addressing uses the memory-mapped registers

without modifying either the current DP value or the current SP value

• Stack addressing manages adding and removing items from the system stack

During the execution of instructions using direct, indirect or memory-mapped

register addressing, the data-address generation logic (DAGEN) computes the

addresses of data-memory operands.

INSTRUCTION SET

• Single-instruction repeat and block repeat operations

• Block memory move instructions for better program and data

management

• Instructions with a 32-bit long operand

• Instructions with 2- or 3-operand simultaneous reads

• Arithmetic instructions with parallel store and parallel load

• Conditional-store instructions

ON-CHIP PERIPHERALS

• Software-programmable wait-state generator

• Programmable bank switching

• External bus-off control to disable the external data bus, address bus and

control signals

Page 31: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

31

• Data bus with a bus holder feature

SPEED:

• 25/20/15/12.5/10-ns execution time for a single-cycle, fixed-point

instruction

FEATURES

• Advanced multi bus architecture with three separate 16- bit data memory

buses and one program memory bus.

• 40-bit arithmetic logic unit (ALU) including a 40- bit barrel shifter and

two independent 40- bit accumulators.

• Two address generators with eight auxiliary registers and two auxiliary

registers arithmetic units (ARAUS).

• Data bus with a bus holder feature.

4.3 Application areas of DSP are considerable:

� Image processing (pattern recognition, robotic vision, image enhancement,

facsimile, satellite weather map, animation).

� Instrumentation and control (spectrum analysis, position and rate control,

noise reduction, data compression).

� Speech and audio (speech recognition, speech synthesis, text to speech, digital

audio, equalisation).

� Military (secure communication, radar processing, sonar processing, missile

guidance).

� Telecommunications (echo cancellation, adaptive equalisation, spread

spectrum, video conferencing, data communication).

� Biomedical (patient monitoring, scanners, EEG brain mappers, ECG analysis,

X-ray storage and enhancement).

Page 32: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

32

Chapter-5

TMS320C5416 Assembly Language Program

5.1 Extraction of Pixel & Header Information:

1. Extract the header information from the input BMP file which consists

1078 bytes of header information.

2. Pixel information of the image is obtained by scanning and is stored in

a 64x64 matrix.

3. This data which is in integer form is converted into hexadecimal form.

4. This is done in C program by using a simple logic of scanning the

matrix and printing it into a file with the help of the following

instruction. Syntax:

fprintf(fp1,"\t\t.word 0x0%04x\n",x);

5. This file is included in the program before we start simulation.

5.2 Wavelet Forward Transform:

5.2.1 Row Forward:

1. Initialize the auxiliary registers pointing to the specified memory

locations.

2. Consider two auxiliary registers pointing two consecutive pixel values

(say si, si+1).

3. Perform the operation of Haar-Wavelet to acquire smoothed values

(averages, say ai, ai+1....) and store them in a different memory location.

4. Also perform the operation of Haar-Wavelet to acquire wavelet

coefficients (say ci, ci+1) for the same values pointed previously (i.e.,

for averages) and store them in a different memory location which is

20h locations next to the previous output memory.

5. Increment the input pointers by two times and the output pointers by

one time.

Page 33: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

33

6. Repeat the steps 3 to 5 by 32 times.

7. Repeat the steps 3 to 6 by 64 times.

5.2.2 Column Forward:

1. Initialize the auxiliary registers pointing to the specified memory

locations.

2. Consider two auxiliary registers pointing two consecutive pixel values

(say si, si+1).

3. Perform the operation of Haar-Wavelet to acquire smoothed values

(averages, say ai, ai+1....) and store them in a different memory location.

4. Also perform the operation of Haar-Wavelet to acquire wavelet

coefficients (say ci, ci+1) for the same values pointed previously (i.e.,

for averages) and store them in a different memory location which is

800h locations next to the previous output memory.

5. Increment the input pointers by two times and the output pointers by

one time.

6. Repeat the steps 3 to 5 by 32 times.

7. Repeat the steps 3 to 6 by 32 times.

8. The second half of the image i.e., stored 32 locations next to the initial

output memory is copied as it is without any processing.

5.3 Thresholding:

1. Initialize the auxiliary register pointing to the specified memory

location.

2. Load the pointer value to accumulator A and check if A lies between -

15 & 15.

3. If the condition is not satisfied go to step 5.

4. If the condition is satisfied append zero in that location.

5. Increment the pointer once.

Page 34: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

34

6. Repeat steps 2 to 5 for the whole image i.e., 4096 times.

5.4 Run-Length Encoding:

1. Initialize the auxiliary registers pointing to the specified memory

locations.

2. Initialize the accumulator B by loading zero into it.

3. Load the pointer value to accumulator A and check if it is zero.

4. If the condition is not satisfied go to step 6.

5. If the condition is satisfied add one to the value in B and go to step 11.

6. Check if the value in B is equal to zero.

7. If the condition is satisfied go to step 10.

8. If the condition is not satisfied load zero to A and store the values of

A and B in consecutive output memory locations.

9. Once again initialize the accumulator B by loading zero.

10. Move the data from input memory to output memory location.

11. Increment the pointer once.

12. Repeat steps 2 to 12 for 4096 times.

5.5 Decoding:

1. Initialize the auxiliary registers pointing to the specified memory

locations.

2. Initialize a variable K by assigning a data pointer to it.

3. Initialize the accumulator A by loading zero into it.

4. Load the value of A to K.

5. Load the input pointer value to A.

6. Initialize the accumulator B and load some junk value into it.

7. Subtract A from B and check if B is equal to zero.

8. If the condition is satisfied jump to the next process.

9. If the condition is not satisfied check the value of A.

10. If it is not zero go to step 15.

11. If it is zero, increment the pointer once and load its value to

accumulator B.

12. Subtract one from the value of B and store it in the same input

location.

Page 35: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

35

13. Store the value in A i.e., zero in the output memory repeatedly for

input pointer value times.

14. Increment the input pointer once and go to step 16.

15. Move the data directly from input memory to output memory location.

16. Go to step 5.

5.6 Wavelet Inverse Transform:

5.6.1 Inverse Column Forward:

1. Move the data directly from one memory location to another memory

location (output).

2. Initialize the auxiliary registers pointing to the specified memory

locations.

3. Initialize a variable K by assigning a data pointer to it.

4. Initialize the accumulator A by loading zero into it.

5. Load the value of A to K.

6. Once again initialize the variable K and load the content of

accumulator K to A.

7. Load 20h to accumulator B and subtract A from B.

8. If B is equal to zero then jump to the next process.

9. If B is not equal to zero then go to the next step.

10. Add the input values pointed by the input pointers and store it in A.

11. Subtract the same and store it in B.

12. Store the content of A at some memory location and the content of B

at some other memory location which is 64 locations next to the

previous memory.

13. Increment both the input and output pointers once.

14. Repeat steps 10 to 13 for 31 times.

15. Now increment the input pointers by 32 times and output pointers by

95 times.

16. Update the variable K by adding one to it and go to step 6.

Page 36: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

36

5.6.2 Inverse Row Forward:

1. Initialize the auxiliary registers pointing to the specified memory

locations.

2. Initialize a variable K by assigning a data pointer to it.

3. Initialize the accumulator A by loading zero into it.

4. Load the value of A to K.

5. Once again initialize the variable K and load the content of

accumulator K to A.

6. Load 40h to accumulator B and subtract A from B.

7. If B is equal to zero then jump to the next process.

8. If B is not equal to zero then go to the next step.

9. Add the input values pointed by the input pointers and store it in A.

10. Subtract the same and store it in B.

11. Store the values of A and B to the output memory and increment the

input and output pointers once.

12. Repeat steps 9 to 11 for 31 times.

13. Now increment the input pointers by 32 times.

14. Update the variable K by adding one to it and go to step 5.

5.7 Implementation using DSP Processor:

1. Execute the program, there by, storing the data to the processor.

2. Load the required data into the system by specifying the

corresponding memory locations to the processor.

3. Store the downloaded data into a file.

4. Edit the file by allowing the required data and deleting the rest.

5. Transfer the data from the file to a buffer.

6. Convert the data which is in hexa-decimal format to integer format

and store it in a file.

Page 37: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

37

7. Now convert the data file into a BMP file, adding the header

information to it.

8. Changing the memory locations while downloading the data, we can

obtain the necessary outputs in image format.

5.8 Real time application using TMS320VC5416

;*******************************************************

; IMAGE COMPRESSION & DECOMPRESSION

;*******************************************************

.include "5416_iv.asm"

.include "pix.asm"

.def start

.data

K .word 0000h

.text

start

SSBX SXM

STM #1100h,AR2

STM #1101h,AR3

STM #2100h,AR0

STM #2120h,AR1

L1 LD #K,DP

LD K,A

LD #40h,B

SUB A,B

BC L2,BEQ

STM #31,BRC

RPTB LOOP1

ADD *AR2,*AR3,A

SFTA A,-16

NOP

Page 38: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

38

NOP

SFTA A,-1

SUB *AR2,*AR3,B

SFTA B,-16

SFTA B,-1

NOP

NOP

STL A,*AR0+

NOP

NOP

STL B,*AR1+

NOP

NOP

RPT #1h

MAR *AR2+

NOP

NOP

NOP

RPT #1h

MAR *AR3+

LOOP1 NOP

RPT #31

MAR *AR0+

NOP

NOP

NOP

RPT #31

MAR *AR1+

NOP

NOP

NOP

LD #K,DP

LD K,A

Page 39: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

39

ADD #1h,A

NOP

NOP

NOP

STL A,K

B L1

L2 LD #K,DP

LD #0h,A

STL A,K

STM #2100h,AR2

STM #3100h,AR3

RPT #4095

MVDD *AR2+,*AR3+

NOP

NOP

NOP

;*****************COL COMP********************

STM #2100h,AR2

STM #2140h,AR3

STM #3100h,AR0

STM #3900h,AR5

STM #1001h,AR1

L3 LD #K,DP

LD K,A

LD #20h,B

SUB A,B

NOP

BC L5,BEQ

NOP

NOP

STM #31,BRC

Page 40: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

40

RPTB LOOP2

ADD *AR2,*AR3,A

NOP

NOP

NOP

SFTA A,-16

NOP

SFTA A,-1

SUB *AR2+,*AR3+,B

NOP

NOP

SFTA B,-16

SFTA B,-1

NOP

NOP

STL A,*AR0+

NOP

STL B,*AR5+

NOP

NOP

LOOP2 NOP

RPT #31

MAR *AR0+

RPT #31

MAR *AR5+

RPT #95

MAR *AR2+

RPT #95

MAR *AR3+

LD #K,DP

LD K,A

NOP

ADD #1h,A

Page 41: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

41

STL A,K

B L3

;**********THRESHOLDING **************

L5 STM #3100h,AR2

STM 4095,BRC

NOP

NOP

RPTB LOOP4

LD *AR2,A

LD #0FFECh,B

NOP

NOP

SUB A,B

BC LOOP4,BGT

NOP

NOP

LD #0020h,B

SUB A,B

BC LOOP4,BLT

NOP

NOP

LD #0h,A

STL A,*AR2

NOP

NOP

MAR *AR2+

NOP

NOP

LOOP4 NOP

Page 42: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

42

;**********RUN LENGTH ENCODING***********

STM #4100h,AR3

LD #0h,A

RPT #4095

STL A,*AR3+

NOP

NOP

NOP

STM #3100h,AR2

STM #4100h,AR3

STM #4095,BRC

LD #0h,B

RPTB LOOP5

LD *AR2,A

BC L6,ANEQ

ADD #1h,B

B LOOP5

L6 BC L7,BEQ

LD #0h,A

STL A,*AR3+

SUB #1h,B

STL B,*AR3+

LD #0h,B

MVDD *AR2,*AR3+

B LOOP5

L7 MVDD *AR2,*AR3+

NOP

LOOP5 MAR *AR2+

LD #7FFFh,A

STL A,*AR3

;**********************DECODING**************

Page 43: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

43

STM #3100h,AR3

STM #4100h,AR2

L8 LD *AR2,A

LD #7FFFh,B

SUB A,B

NOP

NOP

BC L12,BEQ

NOP

NOP

BC L10,ANEQ

NOP

LD #0h,A

MAR *AR2+

NOP

NOP

RPT *AR2

STL A,*AR3+

NOP

NOP

MAR *AR2+

NOP

B L11

L10 MVDD *AR2+,*AR3+

NOP

NOP

L11 B L8

NOP

NOP

L12 NOP

STM #3100h,AR2

STM #4100h,AR3

Page 44: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

44

RPT #4095

MVDD *AR2+,*AR3+

NOP

NOP

NOP

;****************COL INV***************************

LD #K,DP

LD #0h,A

STL A,K

STM #3100h,AR2

STM #3900h,AR3

STM #4100h,AR4

STM #4140h,AR5

L13 LD #K,DP

LD K,A

LD #20h,B

NOP

SUB A,B

NOP

NOP

BC L14,BEQ

STM #31,BRC

NOP

NOP

NOP

RPTB LOOP6

ADD *AR2,*AR3,A

NOP

SFTA A,-16

NOP

NOP

SUB *AR2+,*AR3+,B

NOP

Page 45: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

45

SFTA B,-16

NOP

NOP

STL A,*AR4+

LOOP6 STL B,*AR5+

NOP

NOP

NOP

RPT #31

MAR *AR2+

NOP

NOP

NOP

RPT #31

MAR *AR3+

NOP

NOP

NOP

RPT #95

MAR *AR4+

NOP

NOP

NOP

RPT #95

MAR *AR5+

NOP

NOP

NOP

LD #K,DP

LD K,A

Page 46: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

46

NOP

NOP

ADD #1h,A

STL A,K

B L13

L14 NOP

;*******************ROW INV************************

LD #K,DP

LD #0h,A

STL A,K

STM #4100h,AR2

STM #4120h,AR3

STM #5100h,AR4

STM #5101h,AR5

L15 LD #K,DP

LD K,A

LD #40h,B

SUB A,B

NOP

BC L16,BEQ

NOP

STM #31,BRC

RPTB LOOP7

ADD *AR2,*AR3,A

NOP

SFTA A,-16

NOP

NOP

SUB *AR2+,*AR3+,B

SFTA B,-16

NOP

Page 47: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

47

STL A,*AR4+

NOP

STL B,*AR5+

NOP

MAR *AR4+

NOP

NOP

MAR *AR5+

LOOP7 NOP

RPT #31

MAR *AR2+

NOP

NOP

NOP

RPT #31

MAR *AR3+

NOP

NOP

NOP

LD #K,DP

LD K,A

NOP

NOP

ADD #1h,A

STL A,K

B L15

NOP

L16 NOP

F STM #03h, GPIOCR

STM #02h, GPIOSR

Page 48: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

48

WAIT NOP

NOP

NOP

NOP

B WAIT

5.9 Result:

Input image:

Image after compression:

Image after Decompression:

• Input grey scale image

• Contains 1078 bytes

header information.

• Image after performing

wavelet transform.

• The sharp

discontinuities / spikes

can be viewed.

Page 49: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

49

Chapter-6

Conclusion 6. Conclusion: Compression is the process of reducing the number of bits or bytes needed to

represent a given set of data. Compression takes advantage of redundancies or

similarities in the data file. By reducing the number of bits or bytes used to store a set

of data, we not only reduce the space required to store it, we also reduce the

bandwidth needed to transmit it.

Compression does have its trade-offs. The more efficient the compression technique,

the more complicated the algorithm will be and thus, requires more computational

resources or more time to decompress. This tends to affect the speed. Speed is not so

much of an importance to still images but weighs a lot in motion-pictures.

The same process of compression technique can be applied to colour images by

making necessary changes in the program. Here, we achieved a compression ratio of

nearly 58% for the grey scale image. But in practice, such a large compression ratios

cannot be obtained for audio, video or any other multimedia files. The most popular

data compression techniques now in use are zip, RAR, etc.

• Image after performing

inverse wavelet transform.

• The final recovered image.

Page 50: IMAGE COMPRESSION AND DECOMPRESSION USING WAVELET  TRANSFORM

50

Chapter-7 References

References: Books :

� Donald B. Percival and Andrew T. Walden (2000), ‘Wavelet Methods for Time Series Analysis’, Cambridge University Press.

� Jensen and la Cour-Harbo, (2001), ‘Ripples in Mathematics: the Discrete

Wavelet Transform’.

� Timothy C. Bell, Ian Witten, John Cleary (1990), Text Compression, Prentice Hall, ISBN 0139119914.

Journals :

� DeVore, R.; Jawerth, B.; and Lucier, B., (1992), ‘Images Compression through Wavelet Transform Coding’, IEEE Trans. Information Th. 38, 719-746.

Websites :

� http://www.arturocampos.com/

� http://www.ti.com/corp/docs/home.htm ---TEXAS INSTRUMENTS.

� http://zone.ni.com/zone/jsp/zone.jsp

---NATIONAL INSTRUMENTS.

� http://www.bearcave.com � http://users.rowan.edu/~polikar/homepage.html

� http://en.wikipedia.org/wiki/Run-length_encoding