Sunteți pe pagina 1din 3

JANUARY TUTOR ■

JPEG2000

millennium
jpeg
Su r fing the Web will never be the same again. Wavelet compression is set to ch a n g e
the way we view, transmit and edit images. Used in the new JPEG2000 st a n d a rd ,
this technology shrinks image data to a fraction of its original size – and enables
f a st decompression without loss. Here are the facts .

igh quality images are essential in

H a modern Web site. Transmitting


a page-sized image, however, eats
up vastly more bandwidth than
transmitting a page of text. Most popular
image formats include some form of built-
in compression, but the algorithms they
use don’t provide a good looking image and
high levels of compression at the same
time. Wavelet compression will change all
that; Web-based images will download
faster and look better.
The JPEG2000 standard, which should
be finalised by the time you read this, uses
wavelet compression. You don’t have to
wait for J P E G2000-based products to
appear, though. You can take advantage
of wavelet compression right now, in prod-
ucts such as LuraWave and LuraDocument
from LuraTech (www.luratech.com) and
MrSID from LizardTech (www.lizardtech
Figure 1: The left JPEG image was stored at 20 per-
cent compression, the right image at 95 percent.

82 January 2001 www.DITnet.co.ae ■ www.PCmag-mideast.com


■ JANUARY TUTOR
JPEG2000

.com). This article will explain what’s spe-


cial about wavelet compression, starting
with a look at the alternatives.

A DATA COMPRESSION PRIMER


A data compression algorithm is a tech-
nique for reducing the number of bytes
required to store or transmit data. If the
algorithm is lossless, decompressing a com-
pressed file will yield a result that is iden-
tical to the original. This type of compres-
sion is used when every bit and byte of
data is essential – for example, in com-
pressing executable programs, or text. You
wouldn’t want the compressed message
“You must not press the red button” to be
decompressed as “You must now press the
red button”!
Strangely enough, if a lossless compres-
sion algorithm makes even one type of file
smaller, then there will be at least one type
of file the algorithm would actually make
larger, a fact that can be proven mathe-
matically. That being the case, the goal in
designing lossless compression algorithms
is to ensure that common file types such as
documents, programs and images are
among those that do become smaller. The
popular ZIP file format uses a lossless com-
pression algorithm. As you might expect,
files that have already been compressed
become larger when the same lossless com-
pression algorithm is applied again.
A lossy compression algorithm discards
less important details from its input, both to
reduce the total amount of data stored and
to put the remaining data into a form that
can easily be compressed further. When
you compress a file using lossy compression
and then decompress it, the result will be with large blocky areas of the same colour, Experts Group. JPEG uses a lossy com-
very similar to the original but will not be but an image with few runs of adjacent pression algorithm that can be adjusted by
identical. Lossy algorithms are typically identically colored pixels will be larger after the user, trading increased compression for
used for compressing images. There’s a processing. Thus RLE is worse than useless decreased faithfulness to the original. (There
limit to the amount of detail the human for compressing digital photographs. is also a lossless JPEG format, but its best
eye can take in, so if the lossy algorithm is The popular GIF (Graphics Interchange compression ratio is about 2:1 – too low to
designed correctly there should be no per- Format) image format uses the lossless Lem- be interesting.) The JPEGcompression algo-
ceptible difference between the decom- pel-Ziv-Welch (LZW) algorithm. LZW com- rithm divides an image into small squares
pressed image and the original. The wild- pression works by constructing a dictio- for processing, and at high compression
ly popular MP3 format for audio also uses nary – a list of repeating patterns in the levels these squares can become visible as
a lossy compression algorithm. input data. Each occurrence of a pattern is ugly artifacts. Figure 1 shows the result of
Standard Windows bitmaps (BMP files) replaced by the corresponding code from storing the same 160x240-pixel image of a
tend to be extremely large, as they must the dictionary. LZW can decompress a data garden spider at 20 percent compression
store from 0.5 to 3 bytes for every single stream in one pass, thus lending itself to and at 95 percent compression. The left
p i xe l o f t h e im ag e. Fo r ex a mpl e , a progressive display, which allows an image hand image is about 10K, and the right
1,024x768-pixel BMP image using 24-bit to display before receipt of all the image hand image is about 2K – but the right hand
colour occupies over 2MB. Even the ancient data. GIF images are limited to 8-bit colour, image looks dreadful. The background has
BMP file format includes an option for built- however, and the best digital photographs degenerated into square blocks and the
in compression, a straightforward lossless use 24-bit colour. The PNG (Portable Net- spiderwebs no longer look like spiderwebs.
scheme called Run-Length Encoding (RLE). work Graphics) format is similar to GIF but Note that this same image stored as a Win-
RLE is defined only for 16-colour and 256- avoids use of the patented LZW algorithm. dows bitmap would require over 110K.
colour images. If you have, for example, a JPEG’s image compression has its roots in
run of 80 red pixels in a row, you just store THE JPEG IMAGE FORMAT the work of the scientist and mathematician
the colour (red) and the length of the run The JPEG image format is named for the Joseph Fourier. In the early 1800s, he
(80). This works well for simple images group that devised it, the Joint Photographic demonstrated that any periodic function

www.DITnet.co.ae ■ www.PCmag-mideast.com January 2001 83


JANUARY TUTOR ■
JPEG2000

Figure 2: A Web-based wavelet-compressed image appears quickly, then gradually gains clarity.

(think of the squiggly waves on an oscillo- applying the right wavelet transformation In simple terms, this is how such an image
scope) could be expressed as the sum of a to a photographic image can yield excellent would be decompressed:
series of sine and cosine functions with compression without the blocky artifacts
particular parameters. The procedure that found in highly compressed JPEG images.
renders a periodic function into such a The biggest diff e rence between the 1. Display the stored minimum size
series is called a Fourier transform, and is wavelet transformation and the direct cosine image, but stretched to the final full
useful for enabling scientists to see pat- t r a n s f o rm used in J P E G c o m p re s s i o n width and height. The image will look
terns in the transformed data that weren’t involves scale. The DCT is always applied quite fuzzy.
evident in the raw data. to 8 by 8 squares. In contrast, the wavelet 2. Repeatedly apply the sets of
The Fourier transform applies to mathe- t r a n s f o rmation is applied to the whole differences, doubling the image’s
matical functions, not to digital images, but image repeatedly at different scales. The clarity at each step.
a related transformation called a discrete wavelet functions alternately record and
cosine transform (DCT) can be used on remove detail from the image. Most wavelet Figure 2 shows an enlarged view of four
non-continuous data. A DCT transforms an functions are too complex to describe eas- stages in the process of decompressing a
array of data into a set of parameters that ily, but the Haar wavelet, one of the first simple, 32x32-pixel gray scale image of a
can be used to re-create the original data invented, can be approximated in a simple five-pointed star. The image at left is
precisely. JPEG compression breaks an description: stretched from just 4 by 4 pixels and does-
image into 8x8-pixel blocks and applies n’t show much detail. When the first set of
the DCT to the pixel colours in each block. differences is applied, the next image is the
There’s no loss of data at this point, but 1. Reduce the image to half its width result; this is effectively an 8x8-pixel image.
there’s no compression, either. and height by averaging the colours of Applying the next set of differences yields
The JPEG algorithm reduces the space each 2 by 2 block of pixels into a the third image, which is much clearer. Final-
required to store the image by quantising single pixel. ly, the last set of differences restores the
the output of the DCT – dividing the para- 2. Record the differences between the original 32x32-pixel image, the rightmost
meters by specific values and rounding the original pixels and the averaged pixel in the figure.
result to the nearest integer. This step that replaced them (this will often be In the real world of wavelet compression,
reduces many of the parameters to zero. zero or close to zero). functions much more complex than the
Also, there are fewer distinct values, which 3. Repeat until the image is reduced Haar wavelet are used. Still, this approxi-
makes the data stream more easily com- to a specified minimum size. mation should illustrate the principles
pressible. Some data is lost, but the quan- 4. Store the minimum size image. behind wavelet compression.
tising step is designed to minimise the visu- 5. Store the sets of difference infor- Wavelet compression is extremely well
al effect of that loss. The resulting data mation in reverse order. suited to Web-based images. The moment
stream is compressed again, using a lossless the minimum size image has been received,
algorithm that assigns the smallest codes to At each stage in this process, the image a fuzzy picture can be displayed. As the rest
the most common bit patterns. detail is removed by averaging adjacent of the data stream arrives, the picture gets
pixels, and recorded by storing the differ- steadily clearer. Also, there’s no need to
WAVELET COMPRESSION ences. The resulting data stream includes maintain copies of the image at different
Wavelet analysis has been around for almost many zeroes, representing pixels that are sizes. To obtain a half-size image, you sim-
100 years. As with Fourier analysis, scien- the same colour as their neighbors. Now, ply begin the display process at half the
tists use wavelet analysis to find patterns in as with original JPEG, a lossless compres- original size and omit the final set of differ-
data. The technique has been used to clean sion algorithm that works well with such a ences. No doubt about it, wavelet com-
up “noisy” statistical and audio data, includ- data stream is applied. Additional com- pression is going to improve your browsing
ing an antiquated recording of composer pression can be gained, at the expense of experience; you’ll see better pictures on the
Johannes Brahms playing part of his own faithfulness to the original, by taking val- Web, and they’ll appear faster than ever.
Hungarian Dance No. 1. Wavelet analysis ues near zero and changing them to zero. Visit www.lizardtech.com or www.lurate-
has applications in mathematics, quantum Visually important elements like edges ch.com for currently available examples, or
physics, electrical engineering and seis- won’t be affected, because there the dif- wait a little while longer for products imple-
mology, among other fields. As it happens, ferences are large. menting JPEG2000.

84 January 2001 www.DITnet.co.ae ■ www.PCmag-mideast.com

S-ar putea să vă placă și