You are on page 1of 6

Image Compression Using Wavelet Transform,

Discrete Cosine Transform and Performance


Comparison.
Gunamani Jena, Assoc. Prof., CSE, BVC Engg College (JNTU), AP. Email g_jena@rediffmail.com

R.B.Singh, Prof., CSE, NIT, Rourkela, Orissa. Email rbsingh@nitrkl.ac.in


sorting, storing and searching for data would be nearly
Abstract- In this paper we have taken the standard image LENA impossible. Typically television image generates data rates
and applied wavelet techniques for image compression and have exceeding 10million bytes/sec. There are other image sources
compared the result with the popular DCT image compression. WT that generate even higher data rates. Storage and transmission of
provided better result as far as properties like RMS error, image
intensity and execution time is concerned. Now a days wavelet
such data require large capacity and bandwidth, which could be
theory based technique has immerged in different signal and image expensive. Image data compression technique, concerned with
processing application including speech, image processing and the reduction of the number of bits required to store or transmit
computer vision. In particular Wavelet Transform [7] is of interest image without any appreciable loss of information. . Using
for the analysis of non-stationary signals, because it provides an wavelets, the FBI obtains a compression ratio of about 1: 20.
alternative to the classical Short Term Fourier Transform (STFT),
and Gabor Transform [4][8]. The basic difference is that in STFT a A. The principles behind compression
single analysis window is used, where as in the WT at high
frequencies short windows and low frequencies long windows are
used. Since discrete wavelet is essentially sub band–coding system A common characteristic of most images is that the
and sub band coders have been quit successful in speech and image neighboring pixels are highly correlated and therefore contain
compression. It is clear that DWT has potential application in highly redundant information. The foremost task then is to find
compression problem. an image representation in which the image pixels are de-
Keywords-STFT-Short Term Fourier transform, DWT-Discrete Wavelet correlated. Redundancy and irrelevancy reductions are two
Transform, DCT-Discrete Cosine Transform, DFT-Discrete Fourier
fundamental principles used in compression. Whereas
Transform, DHT-Discrete Hatley Transform, KLT, MSE- Mean Square
Error redundancy reduction aims at removing redundancy from the
signal source (image/video), irrelevancy reduction omits parts of
I. INTRODUCTION the signal that will not be noticed by the signal receiver. In
general, three types of redundancy in digital images and video
Uncompressed graphics, audio and video data require can be identified:
considerable storage capacity and transmission bandwidth.
Despite rapid progress in mass storage density, processor speeds • Spatial Redundancy or correlation between neighboring
and digital communication system performance, demand for data pixel values.
storage capacity and data transmission bandwidth continues to • Spectral Redundancy or correlation between color
out strip the capabilities of the available technologies. The recent planes or spectral bands.
growths of data intensive digital audio, image, and video based • Temporal Redundancy or correlation between adjacent
(multimedia) web applications, have sustained the need for more frames in a sequence of images (video).
efficient ways. With the growth of technology and the entrance
into the Digital Age, the world has found itself amid a vast Image compression research aims at reducing the number of bits
amount of information. Dealing with such enormous amount of needed to represent an image by removing the spatial and
information can often present difficulties. Digital information spectral redundancies as much as possible.
must be stored and retrieved in an efficient manner in order to
put it to practical use. Wavelet compression is one way to deal
B. The different types of compression
with this problem. For example, the FBI uses wavelet
compression to help store and retrieve its fingerprint files. The
FBI possesses over 25 million cards, each containing 10 There are different ways of classifying compression
fingerprint impressions. To store all of the cards would require techniques. Two of these would be mentioned here. The first
over 250 Terabytes of space. Without some sort of compression, categorization is based on the information content of the
reconstructed image. They are ‘ loss less compression’ and domain, it is relatively simple to implement and is readily
‘Lossy compression’ schemes. adapted to local image characteristics. Differential Pulse Code
Modulation (DPCM) is one particular example of predictive
Loss less vs. Lossy compression: In loss less compression, the coding. Transform coding, on the other hand, first transforms the
reconstructed image after compression is numerically identical to image from its spatial domain representation to a different type
the original image on a pixel-by-pixel basis. However, only a of representation using some well-known transforms mentioned
modest amount of compression is achievable in this technique. In later, and then codes the transformed values (coefficients). The
Lossy compression on the other hand, the reconstructed image primary advantage is that, it provides greater data compression
contains degradation relative to the original, because redundant compared to predictive methods, although at the expense of
information is discarded during compression. As a result, much greater computations.
higher compression is achievable, and under normal viewing
conditions, no visible loss is perceived (visually loss less). Typical image coder
A typical Lossy image compression system shown in Fig 1,
Predictive vs. Transform coding: The second categorization of consists of three closely connected components viz. (a) Source
various coding schemes is based on the ‘space’ where the Encoder or Linear Transforms (b) Quantizer and(c) Entropy
compression method is applied. These are ‘predictive coding’ Encoder. Compression is accomplished by applying a linear
and ‘transform coding’. In predictive coding, information already transform to decorrelate the image data, quantizing the resulting
sent or available is used to predict future values and the transform coefficients and entropy coding the quantized values.
difference is coded. Since this is done in the image or spatial

Input
Signal/ Image Source Encoder Quantizer Entropy Encoder Compressed
Signal/ Image

Fig. 1 Lossy image compression system


direction. One can image the computational complexity of doing
A Quantizer simply reduces the number of bits needed to store so for a large image. Thus, many algorithms, such as
the transformed coefficients by reducing the precision of those the FFT (Fast Fourier Transform), have been created to
values. Since this is a many-to-one mapping, it’s a Lossy process speed the computation. More recently, wavelet transform has
and is the main source of compression in an encoder. become a Cutting edge technology for image compression
Quantization can be performed on each individual coefficient, research. It is seen that, wavelet-based coding provides
which is known as Scalar Quantization (SQ). Quantization can substantial improvement ill picture quality at higher compression
also be performed on a group of coefficients together and this is ratios mainly (Lie to the better energy compaction property of
known as Vector Quantization (VQ). Both uniform and non- wavelet transforms Over the past years, a variety of powerful and
uniform quantizer can be used depending on the problem at hand. sophisticated wavelet-based schemes for image compression
An entropy encoder further compresses the quantized values have been developed and implemented. Because of the many
losslessly to give better overall compression. Most commonly advantages the top contenders in the upcoming JPEG-2000 are
used entropy encoders are the Huffman encoder and the standard rare all wavelet-based compression algorithms.
Arithmetic encoder, although for applications requiring fast
execution, simple run-length coding has proven very effective. A II. 2-D DISCRETE COSINE TRANSFORM
properly designed quantizer and entropy encoder are absolutely
necessary along with optimum signal transformation to get best The Discrete Cosine Transform [3] is a fast transform. It is a
possible compression. Over the years, a variety of linear widely used and robust method used for image compression. It
transforms have been developed which include Discrete Fourier has excellent energy compaction for highly correlated data,
Transform (DFT), Discrete Cosine Transform (DCT), Discrete which is superior to that of DFT and DHT [5]. Through KLT [5]
Wavelet Transform (DWT) and many more, each with its own minimizes the mean square error for any input image, KLT is
advantages and disadvantages. The Discrete Cosine Transform is seldom used in various application because as KLT is data
one of many transforms that takes the input and transforms it into dependent, obtaining the KLT basis images for each sub images
a linear combination of weighted basis functions. These basis is a nontrivial computational task. In contrast to it, the DCT has
functions are commonly the frequency, like sine waves. The 2D fixed basis images. Hence most practical transform coding
Discrete Cosine Transform is just a one dimensional DCT systems are based on the DCT, which provides a good
applied twice once in the x direction, and the second in the y compromise between the information packing ability and
computational complexity. In fact, the properties of the DCT transform arrays. The goal of the transformation process is to
have proved to be of such practical value that it has become the decorrelate the pixels of each sub image or to pack as such
international standard for transform coding systems. Compared information as possible into the smaller number of transform
to other input independent transforms, it has the following coefficients. The quantization stage then selectively eliminates or
advantages. It has been implemented in a single integrated more coarsely quantizes the coefficient that carries the least
circuit. It has the ability to pack most in formation into fewest information. These coefficients have the smallest impact on the
coefficients. It minimizes the block like appearance, called reconstructed sub image quality. The en coding process
blocking artifact that results when the boundaries between sub terminates by coding the quantized coefficients.
images become visible. To study compression using DCT, the N
x N input image is first sub-divided into sub-image of size n x n, The forward 2D-DCT is given by the following equation.
which are then transformed to generate (N/n)2 n x n sub-image
N -1 N - 1
⎡(2x+1) uπ ⎤ ⎡(2y+1) vπ ⎤
c(u,v)= a(u)a(v)∑∑ f (x, y)cos⎢ ⎥ × cos⎢
x=0 y=0 ⎣ 2N ⎦ ⎣ 2N ⎥⎦
For u, v = 0, 1, 2, 3, ……………., N – 1 (1.1)

The inverse 2D-DCT-transformation equation is given by the following equation.


N -1 N -1
⎡ (2x + 1) uπ ⎤ ⎡ (2y + 1) vπ ⎤
f (x, y) = ∑ ∑ a(u) a(v)a(u, v) cos ⎢ ⎥ × cos ⎢ ⎥⎦
u =0 v=0 ⎣ 2N ⎦ ⎣ 2N
(1.2)
1 2
where a(u) = for u = o a(u) = for u = 1, 2, ,3, ……(N – 1) (1.3)
N N

Input Construct n Forward Quantizer Symbol Compressed


image x n sub Transform Encoder image
(N x N) images

Compressed Symbol Inverse Merge Decompress


image Encoder Transform n x n sub ed image
images

Fig. 2 Transform Coding System


finite length thus it covers only a finite portion of the signal,
III. WAVELET TRANSFORM which causes the frequency resolution to get poorer. We cannot
know the exact frequency exits in the signal but we know a band
Wavelet Transform (WT) has become a cutting edge of frequencies that exits.
technology for image compression research recently. It is seen
that wavelet based coding provides substantial improvement in The Discrete Wavelet Transform
picture and higher compression ratio due to the better energy
compaction property of it. A powerful and sophisticated wavelet The foundations of the DWT go back to 1976 when Croiser,
based schemes for image compression have been developed and Esteban and Galand devised a technique to decompose discrete
implemented. The JPEG-2000 standards are also wavelet–based time signals. Crochiere, Weber, and Flanagan did a similar work
compression. WT is basically needed to analyze non-stationary on coding of speech signals in the same year. They named their
signals, i.e., whose frequency response varies in time. In case of analysis scheme as sub band coding. In 1983, Burt defined a
FT the time resolution in frequency domain and the frequency technique very similar to sub band coding and named it
resolution in time domain are zero. In STFT the window is of pyramidal coding which is also known as multiresolution
analysis. Later in 1989, Vetterli and Le Gall made some
improvements to the sub band-coding scheme, removing the Soft threshold can be thought of as a translation of the signal
existing redundancy in the pyramidal coding scheme. toward zero by the amount h. A third type of threshold is quartile
threshold. In this method a percentage p of entries to be
A. Image Compression Using DWT eliminated are selected. The smallest (in absolute value) p
percent of entries are set to zero.
DWT can be used to reduce the image size without losing Entropy Coding
much of the resolution. For a given image, you can compute the
DWT of, say each row, and discard all values in the DWT that Wavelets and threshold help process the signal but up until this
are less then a certain threshold. We then save only those DWT point, no compression has yet occurred. One method to compress
coefficients that are above the threshold for each row and when the data is Huffman entropy coding. With this method, and
we need to reconstruct the original image, we simply pad each integer sequence, q, is changed into a shorter sequence, e, with
row, with as many zeros as the number of discarded coefficients, the numbers in e being 8 bit integers. An entropy-coding table
and use the inverse DWT to reconstruct each row of the original makes the conversion. Strings of zeros are coded by the numbers
image. We can also analyze the image at different frequency I through 100, 105, and 106, while the non-zero integers in q are
bands, and reconstruct the original image by using only the coded by 101 through 104 and 107 through 254. In Huffman
coefficients that are of a particular band. The steps needed to entropy coding, the idea is to use two or three numbers for
compress an image are as follows: coding, with the first being a signal that a large number or long
zero sequence is coming. Entropy coding is designed so that the
1. Digitize the source image into a signal s, which is a numbers that are expected to appear the most often in q need the
string of numbers. least amount of space in e.
2. Decompose the signal into a sequence of wavelet
coefficients w. Quantization
3. Use threshold to modify the wavelet coefficients The fourth step of the process, known as Quantization,
from w to another sequence w'. converts a sequence of floating numbers w' to a sequence of
4. Use Quantization to convert w' to a sequence q. integers q. The simplest form is to round to the nearest integer.
5. Apply entropy coding to compress q into a sequence Another option is to multiply each number in by a constant k, and
e. then round to the nearest integer. Quantization is called Lossy
because it introduces error into the process, since the conversion
Digitization of w' to q is not a one-to-one function. In FT, the kernel function,
The first step in the wavelet compression process is to digitize allows us to obtain perfect frequency resolution. Because the
the image. The digitized image can be characterized by its kernel itself is a window of infinite length. If we use a window of
intensity levels or scales of gray, which range from 0 (black) to infinite length, we get the FT, which gives perfect frequency
255 (white) and its resolution, or how many pixels per square resolution but no time information. Furthermore, in older to
inch, Each of the bits involved in creating an image takes up both obtain the stationarity, we have to have a short enough window
time and money, so a tradeoff must be made. in which the signal is stationary. The narrower we make the
window, the better the time resolution and better the assumption
Thresholding of stationarity but poorer the frequency resolution. The Wavelet
In certain signals, many of the wavelet coefficients are close or transform (WT) solves the dilemma of resolution to a certain
equal to zero. Through a method called threshold, these extent.
coefficients may be modified so that the so sequence of wavelet
coefficients contains long strings of zeros. Through a type of IV.IMAGE COMPRESSION THEORY
compression known as entropy coding these long strings may be
stored and sent electronically in much less space. There are The underlying basis of the reduction process is the removal of
different types of threshold. In hard threshold, a tolerance is redundant data i.e., the data that either provides no relevant
selected. Any wavelet whose absolute value falls below the information or simply restart that which is already known. Data
tolerance is set to zero with the goal to introduce many zeros redundancy is the central issue in digital image compression. If
without losing a great amount of detail. There is not a n1 and n2 denote the number of information carrying units in two
straightforward easy way to choose the threshold. Although the data sets that represent the same information, then the
larger the threshold that is chosen the more error that is compression ration CR is defined as below.
introduced into the process. Another type of threshold is soft CR = n1/n2 (1.3)
threshold. Once again a tolerance, h, is selected. If the absolute In this case relative data redundancy RD of the first data set can
value of an entry is less than the tolerance, than that entry is set be defined as follows.
to zero. All other entries, d, are replaced with sign (d)⎢⎢d ⎢- h⎢. RD = 1 – 1/CR (1.4)
When n2 = n1, then CR = 1 and hence RD = 0. It indicates that the
first representation of the information contains no redundant data.
When n2 << n1, then CR -> ∞ and RD -> 1. It implies significant
compression and highly redundant data. In the final case when n2
<< n1, then CR -> 0 and RD -> -∞, indicating that the second data
set contains much more data than the original representation.
Various methods can be used for the compression of the image
that contains redundant data. At first we have used the Discrete
Cosine Transform (DCT) method to get a compressed image of
an original image and then we have applied WT for compression.
V. SIMULATION
The algorithm for image compression using WT uses Fig.3 Original image LENA
averaging and differencing to form the wavelet. Then we use the Image compression using 2D DCT
threshold technique to reduce the number of coefficients. Inverse
transform is then applied to get the compressed mage.
Algorithm
1. W=s1*s2*s3 where s1, s2, s3 are obtained by using the
averaging and differencing techniques
2. T=W’AW where W’ is the transpose of the matrix W.
3. Now T is compressed to T*.We select a certain threshold value
and all the coefficients below that particular value are neglected.
window size4x4
4.(W-1)’T*W-1=A*. window size2x2
(MSE=10.7702 dB)
(MSE=8.7047 dB)
5. A* is a matrix approximate to the original matrix A.

RESULT

Here we have taken the standard image LENA for our study
purpose. We have subdivided the whole image into 3 x 3 sub
images. The forward 2D-DCT-transformation is applied to all the
pixels of each sub image. Next the pixels that carry least
information eliminated. So the values of the pixels, which have window size8x8 window size16x16
values less than the threshold value, are set to zero. In our (MSE=12.2919 dB) (MSE=13.5021 dB)

experiment we have chosen the threshold value equals to 20. So Fig3.a Image Compression using 2D-DCT
all the pixels having value less than 20 are assumed to be having
value equals to zero. Then the inverse Discrete Cosine 15 25

Transformation equation is applied to all the transformed pixels ws 1=2x2


20
ws 2=4x4
of the sub image. The same procedure is followed for all the sub 10 ws 3=8x8
c pu tim e

images. It has been found that the energy retained by the ws 4=16x16
mse

15

compressed image is equal to 98.16%. The original and the 5


10
compressed images are shown in Fig. 3, Fig.3.a. The
compression using Wavelet Transform gave a better performance 0 5
1 2 3 4 1 2 3 4
than the 2D DCT shown in Fig 4.a, Fig.4.b. The image intensity window size window size
was around 96.4%, the MSE is 12 dB. The time taken for the 98.25 0.04
program execution was reduced to around 0.9. Also the
98.2
compression was 8.5. The comparison is shown in Table 1. 0.03
c om pres s ion

98.15
intens ity

TABLE 1 0.02
98.1
COMPARISON OF WAVELET TRANSFORM AND 2D DCT
0.01
98.05
Property 2D DCT Wavelet transform
98 0
Image Intensity 98.16% 96.4% 1 2 3 4 1 2 3 4
MSE in dB 8 12 window size window size

CPU time/Exec. Time 3.8 0.9 Fig.3.b Using DCT the intensity, CPU time, compression ratio
Compression 0.025 8.5
and mean square error
Image Compression using Wavelet Transform
2.5 40

2 35

c pu tim e
1.5 30

mse
1 25

0.5 20

0 15
1 2 3 4 1 2 3 4
window size 2x2 window size 4x4 window s iz e window s iz e
MSE=15.9124 MSE=11.7675
98.5 15

98
10
97.5

intens ity

c om res s ion
97
5
96.5

96 0
window size 8x8 window size 16X16 1 2 3 4 1 2 3 4
window s iz e window s iz e
MSE=12.7569 MSE=12.7569
P erform anc e Com paris on us ing W av elet T rans form

Fig.4.a Compression Using WT Fig.4.b Using WT the intensity, CPU time, compression ratio and
mean square error

CONCLUSION 6. h, Danny Lazar and Moshe Israeli, “Image Compression using WT


and Multiresolution Decomposition”, IEEE Trans. On Image Proc.,
Vol. 5, No. 1, Jan 1996.
Even if Discrete Cosine Transform is a widely adapted and
robust method used for compression of digital image as it has the 7. The Wavelet Digest.
ability to carry most of the information in smallest number of 8. R. Baliarsingh and G. Jena, “Gabor Function: An Efficient Tool for
pixels compared to other method, the WT provided better result Digital Image Processing,” Intl. Conf., SRKR Engg college (JNTU),
as far as properties like RMS error, image intensity and execution vol. 1 pp 98-101, Oct 2005.
time is concerned. So WT has been widely used. 9. Getting started with Matlab 5 by Rudra Pratap.

10. The Wavelet tutorials by Roby Polikar


REFERENCES
1. Digital Signal Processing Principles Algorithm and Applications By
John G. Proakis. Dimitris G. Manolokis.
2. Jain, Fundamentals of Digital Image Processing, PHI, Englewood
Cliff, NJ, 1989.
3. Rafel G. Gonzalez and Richard E. Woods, “Digital Image
Processing”, Addison Wesley, 1998.
4. D. Gabor, “Theory of communications,” Jnl. Inst. Elect. Engrs. 01, 93,
1946, pp-429-457.
5. Oppenhiem and R.W. Schafer, 'Digital Signal Processing', PHI, New
Delhi.

You might also like