Image Compression Techniques Overview
Image Compression Techniques Overview
Image Compression
SMVIT 1
Introduction and Overview
SMVIT 2
Applications that require image
compression are many and varied such
as:
1. Internet,
2. Businesses,
3. Multimedia,
4. Satellite imaging,
5. Medical imaging
SMVIT 3
Compression algorithm development
starts with applications to two-dimensional
(2-D) still images
SMVIT 4
Image compression involves reducing the
size of image data files, while retaining
necessary information
SMVIT 5
The reduced file created by the
compression process is called the
compressed file and is used to reconstruct
the image, resulting in the decompressed
image
The original image, before any
compression is performed, is called the
uncompressed image file
The ratio of the original, uncompressed
image file and the compressed file is
referred to as the compression ratio
SMVIT 6
The compression ratio is denoted by:
SMVIT 7
The reduction in file size is necessary to
meet the bandwidth requirements for
many transmission systems, and for the
storage requirements in computer
databases
SMVIT 8
This number is based on the actual
transmission rate being the maximum,
which is typically not the case due to
Internet traffic, overhead bits and
transmission errors
SMVIT 9
Additionally, considering that a web page
might contain more than one of these
images, the time it takes is simply too long
SMVIT 10
Example 10.1.5 applies maximum data rate to Example 10.1.4
SMVIT 11
Now, consider the transmission of video
images, where we need multiple frames
per second
If we consider just one second of video
data that has been digitized at 640x480
pixels per frame, and requiring 15 frames
per second for interlaced video, then:
SMVIT 12
Waiting 35 seconds for one second’s
worth of video is not exactly real time!
SMVIT 13
Applications requiring high speed
connections such as high definition
television, real-time teleconferencing, and
transmission of multiband high resolution
satellite images, leads us to the conclusion
that image compression is not only
desirable but necessessary
1. Data:
• For digital images, data refers to the
pixel gray level values that correspond to
the brightness of a pixel at a point in
space
• Data are used to convey information,
much like the way the alphabet is used to
convey information via words
SMVIT 15
2. Information:
SMVIT 16
There are two primary types of image
compression methods:
SMVIT 17
2. Lossy compression methods:
SMVIT 18
Compression algorithms are developed
by taking advantage of the redundancy
that is inherent in image data
SMVIT 19
1. Coding redundancy
Occurs when the data used to represent
the image is not utilized in an optimal
manner
2. Interpixel redundancy
Occurs because adjacent pixels tend to
be highly correlated, in most images the
brightness levels do not change rapidly,
but change gradually
SMVIT 20
3. Interband redundancy
Occurs in color images due to the
correlation between bands within an
image – if we extract the red, green and
blue bands they look similar
4. Psychovisual redundancy
Some information is more important to
the human visual system than other
types of information
SMVIT 21
The key in image compression algorithm
development is to determine the minimal
data required to retain the necessary
information
The compression is achieved by taking
advantage of the redundancy that exists in
images
If the redundancies are removed prior to
compression, for example with a
decorrelation process, a more effective
compression can be achieved
SMVIT 22
To help determine which information can
be removed and which information is
important, the image fidelity criteria are
used
SMVIT 24
Compression System Model
1. The compressor
2. The decompressor
SMVIT 26
• Before encoding, preprocessing is
performed to prepare the image for the
encoding process, and consists of any
number of operations that are application
specific
SMVIT 29
SMVIT 30
• The decompressor can be broken down
into following stages:
SMVIT 31
3. Postprocessing: Involves enhancing the
look of the final image
SMVIT 32
Decompressed image
SMVIT 33
• The development of a compression
algorithm is highly application specific
SMVIT 34
• For example, many images that are for
viewing purposes only can be
preprocessed by eliminating the lower bit
planes, without losing any useful
information
SMVIT 35
Figure 10.1.4 Bit plane images
SMVIT 36
Figure 10.1.4 Bit plane images (Contd)
e) Bit plane 4
SMVIT 37
Figure 10.1.4 Bit plane images (Contd)
h) Bit plane 1
SMVIT 38
• The mapping process is important
because image data tends to be highly
correlated
SMVIT 39
• Differential coding: Method of reducing
data redundancy, by finding the difference
between adjacent pixels and encoding
those values
SMVIT 40
Figure -5.6.1 Principal Components Transform (PCT)
SMVIT 41
• As the spectral domain can also be used
for image compression, so the first stage
may include mapping into the frequency or
sequency domain where the energy in the
image is compacted into primarily the
lower frequency/sequency components
SMVIT 42
• Quantization may be necessary to convert
the data into digital form (BYTE data type),
depending on the mapping equation used
SMVIT 43
• Quantization can be performed in the
following ways:
SMVIT 44
SMVIT 45
• Often, nonuniform quantization bins are
designed to take advantage of the
response of the human visual system
SMVIT 46
• The concept of nonuniform quantization
bin sizes is also described as a variable bit
rate, since the wider quantization bins
imply fewer bits to encode, while the
smaller bins need more bits
SMVIT 48
• In most cases, an unequal length code is
the most efficient for data compression,
but requires more overhead in the coding
and decoding stages
SMVIT 49
LOSSLESS COMPRESSION
METHODS
SMVIT 50
Lossless compression methods can
provide substantial compression for simple
images
SMVIT 51
The underlying theory for lossless
compression (also called data compaction)
comes from the area of communications
and information theory, with a
mathematical basis in probability theory
SMVIT 52
Information theory defines information
based on the probability of an event,
knowledge of an unlikely event has more
information than knowledge of a likely
event
For example:
• The earth will continue to revolve around the
sun; little information, 100% probability
• An earthquake will occur tomorrow; more info.
Less than 100% probability
• A matter transporter will be invented in the next
10 years; highly unlikely – low probability, high
information content
SMVIT 53
This perspective on information is the
information theoretic definition and should
not be confused with our working definition
that requires information in images to be
useful, not simply novel
SMVIT 54
The entropy for an N x N image can be
calculated by this equation:
SMVIT 55
This measure provides us with a
theoretical minimum for the average
number of bits per pixel that could be used
to code the image
SMVIT 56
SMVIT 57
SMVIT 58
The two preceding examples (10.2.1 and
10.2.2) illustrate the range of the entropy:
SMVIT 59
Figure 10.2-1 Entropy
SMVIT 60
Figure 10.2-1 Entropy (contd)
SMVIT 61
Figure 10.2.1 depicts that a minimum
overall file size will be achieved if a
smaller number of bits is used to code the
most frequent gray levels
Average number of bits per pixel (Length)
in a coder can be measured by the
following equation:
SMVIT 62
Huffman Coding
SMVIT 63
• The method results in an unequal (or
variable) length code, where the size of
the code words can vary
SMVIT 64
• The Huffman algorithm can be described
in five steps:
SMVIT 72
Run-Length Coding
SMVIT 73
• RLC can also work with complex images
that have been preprocessed by
thresholding to reduce the number of gray
levels to two
• RLC can be implemented in various ways,
but the first step is to define the required
parameters
• Horizontal RLC (counting along the rows)
or vertical RLC (counting along the
columns) can be used
SMVIT 74
• In basic horizontal RLC, the number of bits
used for the encoding depends on the
number of pixels in a row
SMVIT 75
• The next step is to define a convention for
the first RLC number in a row – does it
represent a run of 0's or 1's?
SMVIT 76
SMVIT 77
SMVIT 78
• Bitplane-RLC : A technique which involves
extension of basic RLC method to gray
level images, by applying basic RLC to
each bit-plane independently
SMVIT 79
SMVIT 80
• Typical compression ratios of 0.5 to 1.2
are achieved with complex 8-bit
monochrome images
SMVIT 82
• As the adjacent pixel values are highly
correlated, adjacent pixel values tend to
be relatively close in gray level value, and
this can be problematic for RLC
SMVIT 83
SMVIT 84
SMVIT 85
• When a situation such as the above
example occurs, each bitplane
experiences a transition, which adds a
code for the run in each bitplane
• However, with the Gray code, only one
bitplane experiences the transition, so it
only adds one extra code word
• By preprocessing with a Gray code we
can achieve about a 10% to 15% increase
in compression with bitplane-RLC for
typical images
SMVIT 86
• Another way to extend basic RLC to gray
level images is to include the gray level of
a particular run as part of the code
• Here, instead of a single value for a run,
two parameters are used to characterize
the run
• The pair (G,L) correspond to the gray level
value, G, and the run length, L
• This technique is only effective with
images containing a small number of gray
levels
SMVIT 87
SMVIT 88
SMVIT 89
• The decompression process requires the
number of pixels in a row, and the type of
encoding used
SMVIT 90
• Newer versions of this standard also utilize
a two-dimensional technique where the
current line is encoded based on a
previous line, which helps to reduce the
file size
SMVIT 91
Lempel-Ziv-Welch Coding
SMVIT 92
• The string table is updated as the file is
read, with new codes being inserted
whenever a new string is encountered
SMVIT 93
For Example:
SMVIT 94
• The string codes are assigned during the
compression process, but the actual string
table is not stored with the compressed
data
SMVIT 95
• For the GIF (and TIFF) image file format
the LZW algorithm is specified, but there
has been some controversy over this,
since the algorithm is patented by Unisys
Corporation
SMVIT 97
Arithmetic Coding
SMVIT 98
• As each input symbol (pixel value) is read
the precision required for the number
becomes greater
SMVIT 99
• Arithmetic coding uses the probability
distribution of the data (histogram), so it
can theoretically achieve the maximum
compression specified by the entropy
SMVIT 100
SMVIT 101
SMVIT 102
SMVIT 103
• In practice, this technique may be used as
part of an image compression scheme, but
is impractical to use alone
SMVIT 104
Lossy Compression Methods
SMVIT 105
SMVIT 106
With more advanced methods, images can
be compressed 10 to 20 times with
virtually no visible information loss, and 30
to 50 times with minimal degradation
Newer techniques, such as JPEG2000,
can achieve reasonably good image
quality with compression ratios as high as
100 to 200
Image enhancement and restoration
techniques can be combined with lossy
compression schemes to improve the
appearance of the decompressed image
SMVIT 107
In general, a higher compression ratio
results in a poorer image, but the results
are highly image dependent – application
specific
SMVIT 108
Gray-Level Run Length Coding
SMVIT 109
Figure 10.3-2 Lossy Bitplane Run Length Coding
SMVIT 110
Figure 10.3-2 Lossy Bitplane Run Length Coding (contd)
SMVIT 111
Figure 10.3-2 Lossy Bitplane Run Length Coding (contd)
SMVIT 112
Figure 10.3-2 Lossy Bitplane Run Length Coding (contd)
SMVIT 113
• A more sophisticated method is dynamic
window-based RLC
• This algorithm relaxes the criterion of the
runs being the same value and allows for
the runs to fall within a gray level range,
called the dynamic window range
• This range is dynamic because it starts out
larger than the actual gray level window
range, and maximum and minimum values
are narrowed down to the actual range as
each pixel value is encountered
SMVIT 114
• This process continues until a pixel is
found out of the actual range
SMVIT 115
SMVIT 116
SMVIT 117
SMVIT 118
• This particular algorithm also uses some
preprocessing to allow for the run-length
mapping to be coded so that a run can be
any length and is not constrained by the
length of a row
SMVIT 119
Block Truncation Coding
SMVIT 120
• The levels for the quantizer are chosen to
minimize a specified error criteria, and
then all the pixel values within each block
are mapped to the quantized levels
SMVIT 121
• The two levels are selected so that the
mean and variance of the gray levels
within the block are preserved
• Each pixel value within the block is then
compared with a threshold, typically the
block mean, and then is assigned to one
of the two levels
• If it is above the mean it is assigned the
high level code, if it is below the mean, it is
assigned the low level code
SMVIT 122
• If we call the high value H and the low
value L, we can find these values via the
following equations:
SMVIT 123
• If n = 4, then after the H and L values are
found, the 4x4 block is encoded with four
bytes
SMVIT 124
SMVIT 125
SMVIT 126
SMVIT 127
• This algorithm tends to produce images
with blocky effects
SMVIT 128
SMVIT 129
SMVIT 130
• The multilevel BTC algorithm, which uses
a 4-level quantizer, allows for varying the
block size, and a larger block size should
provide higher compression, but with a
corresponding decrease in image quality
SMVIT 131
SMVIT 132
SMVIT 133
Vector Quantization
SMVIT 134
SMVIT 135
• VQ can be applied in both the spectral or
spatial domains
SMVIT 136
• Vector quantization treats the entire
subimage (vector) as a single entity and
quantizes it by reducing the total number
of bits required to represent the subimage
SMVIT 137
• In the example we achieved a 16:1
compression, but note that this assumes
that the codebook is not stored with the
compressed file
SMVIT 138
SMVIT 139
• However, the codebook will need to be
stored unless a generic codebook is
devised which could be used for a
particular type of image, in that case we
need only store the name of that particular
codebook file
SMVIT 140
SMVIT 141
• A training algorithm determines which
vectors will be stored in the codebook by
finding a set of vectors that best represent
the blocks in the image
SMVIT 143
• The LBG algorithm, along with other
iterative codebook design algorithms do
not, in general, yield globally optimum
codes
• These algorithms will converge to a local
minimum in the error (distortion) space
• Theoretically, to improve the codebook,
the algorithm is repeated with different
initial random codebooks and the one
codebook that minimizes distortion is
chosen
SMVIT 144
• However, the LBG algorithm will typically
yield "good" codes if the initial codebook is
carefully chosen by subdividing the vector
space and finding the centroid for the
sample vectors within each division
• These centroids are then used as the
initial codebook
• Alternately, a subset of the training
vectors, preferably spread across the
vector space, can be randomly selected
and used to initialize the codebook
SMVIT 145
• The primary advantage of vector
quantization is simple and fast
decompression, but with the high cost of
complex compression
SMVIT 146
• This type of compression is useful for
applications where the images are
compressed once and decompressed
many times, such as images on an
Internet site
SMVIT 147
Figure 10.3-8
Vector Quantization in the Spatial Domain
SMVIT 148
Figure 10.3-8
Vector Quantization in the Spatial Domain (contd)
Note: As the codebook size is increased the image quality improves and the
compression ratio decreases
SMVIT 149
Figure 10.3-9
Vector Quantization in the Transform Domain
SMVIT 150
Figure 10.3-9
Vector Quantization in the Transform Domain (contd)
SMVIT 151
Differential Predictive Coding
SMVIT 152
• Typically the difference, or error, will be
small which minimizes the number of bits
required for compressed file
SMVIT 153
SMVIT 154
• From the block diagram, we have the
following:
SMVIT 155
SMVIT 156
• This quantized error can be encoded using
a lossless encoder, such as a Huffman
coder
SMVIT 157
SMVIT 158
SMVIT 159
• The prediction equation can be one-
dimensional or two-dimensional, that is, it
can be based on previous values in the
current row only, or on previous rows also
• The following prediction equations are
typical examples of those used in practice,
with the first being one-dimensional and
the next two being two-dimensional:
SMVIT 160
SMVIT 161
• Using more of the previous values in the
predictor increases the complexity of the
computations for both compression and
decompression
SMVIT 162
• The results of DPC can be improved by
using an optimal quantizer, such as the
Lloyd-Max quantizer, instead of simply
truncating the resulting error
SMVIT 163
• Assuming a 2-bit code for the error, and a
Laplacian distribution for the error, the
Lloyd-Max quantizer is defined as follows:
SMVIT 164
SMVIT 165
• For most images, the standard deviation
for the error signal is between 3 and 15
SMVIT 166
SMVIT 167
SMVIT 168
SMVIT 169
SMVIT 170
Figure 10.3.15 DPC Quantization (contd)
SMVIT 171
Model-based and Fractal Compression
SMVIT 172
• The objects are often defined by lines or
shapes (boundaries), so a Hough
transform (Chap 4) may be used, while the
object interiors can be defined by
statistical texture modeling
• The model-based methods can achieve
very high compression ratios, but the
decompressed images often have an
artificial look to them
• Fractal methods are an example of model-
based compression techniques
SMVIT 173
• Fractal image compression is based on
the idea that if an image is divided into
subimages, many of the subimages will be
self-similar
SMVIT 174
• Treating the image as a geometric plane,
the mathematical operations (skew,
stretch, scale, rotate, translate) are called
affine transformations and can be
represented by the following general
equations:
SMVIT 175
• Fractal compression is somewhat like
vector quantization, except that the
subimages, or blocks, can vary in size and
shape
• The idea is to find a good set of basis
images, or fractals, that can undergo affine
transformations, and then be assembled
into a good representation of the image
• The fractals (basis images), and the
necessary affine transformation
coefficients are then stored in the
compressed file
SMVIT 176
• Fractal compression can provide high
quality images and very high compression
rates, but often at a very high cost
SMVIT 179
Figure 10.3-16 Fractal Compression
SMVIT 180
Figure 10.3-16 Fractal Compression (contd)
SMVIT 181
Figure 10.3-16 Fractal Compression (contd)
SMVIT 182
Figure 10.3-16 Fractal Compression (contd)
Note: Error images have been remapped for display so the background gray corresponds to zero,
then they were enhanced by a histogram stretch to show detail
SMVIT 183
Transform Coding
SMVIT 184
• Any of the previously defined transforms
can be used, frequency (e.g. Fourier) or
sequency (e.g. Walsh/Hadamard), but it
has been determined that the discrete
cosine transform (DCT) is optimal for most
images
SMVIT 185
• After the transform has been calculated,
the transform coefficients are quantized
and coded
SMVIT 187
• The simplest form of transform coding is
achieved by filtering by eliminating some
of the high frequency coefficients
SMVIT 189
SMVIT 190
• Then a quantization scheme, such as
Lloyd-Max quantization is applied
• As the zero-frequency coefficient for real
images contains a large portion of the
energy in the image and is always
positive, it is typically treated differently
than the higher frequency coefficients
• Often this term is not quantized at all, or
the differential between blocks is encoded
• After they have been quantized, the
coefficients can be coded using, for
example, a Huffman or arithmetic coding
method
SMVIT 191
• Two particular types of transform coding
have been widely explored:
1. Zonal coding
2. Threshold coding
SMVIT 192
1. Zonal coding
SMVIT 193
SMVIT 194
• The zonal mask is a bitmap of 1's and 0',
where the 1's correspond to the
coefficients to retain, and the 0's to the
ones to eliminate
SMVIT 195
2. Threshold coding
SMVIT 196
• In practice, the zonal mask is often
predetermined because the low frequency
terms tend to contain the most information,
and hence exhibit the most variance
SMVIT 197
• It also saves the overhead involved in
calculating the variance of each group of
subimages for compression and also
eases the decompression process
SMVIT 198
Figure 10.3-18
Zonal Compression with DCT and Walsh Transforms
A block size of 64x64 was used, a circular zonal mask, and DC coefficients were not quantized
SMVIT 199
Figure 10.3-18
Zonal Compression with DCT and Walsh Transforms
(contd)
d) Results from using the DCT with e) Error image comparing the original and
a compression ratio = 14.94 (d), histogram stretched to show detail,
SMVIT 200
Figure 10.3-18
Zonal Compression with DCT and Walsh Transforms
(contd)
f) Results from using the Walsh Transform g) Error image comparing the original and
(WHT) with a compression ratio = 4.27 (f), histogram stretched to show detail
SMVIT 201
Figure 10.3-18
Zonal Compression with DCT and Walsh Transforms
(contd)
h) Results from using the WHT with i) Error image comparing the original and
a compression ratio = 14.94 (h), histogram stretched to show detail
SMVIT 202
• One of the most commonly used image
compression standards is primarily a form
of transform coding
• The Joint Photographic Expert Group
(JPEG) under the auspices of the
International Standards Organization (ISO)
devised a family of image compression
methods for still images
• The original JPEG standard uses the DCT
and 8x8 pixel blocks as the basis for
compression
SMVIT 203
• Before computing the DCT, the pixel
values are level shifted so that they are
centered at zero
• EXAMPLE 10.3.7:
A typical 8-bit image has a range of gray
levels of 0 to 255. Level shifting this range
to be centered at zero involves subtracting
128 from each pixel value, so the resulting
range is from -128 to 127
SMVIT 204
• After level shifting, the DCT is computed
SMVIT 206
These quantization tables were experimentally determined by JPEG to take
advantage of the human visual system’s response to spatial frequency which
peaks around 4 or 5 cycles per degree
SMVIT 207
SMVIT 208
SMVIT 209
Figure 10.3-21:The Original DCT-based JPEG
Algorithm Applied to a Color Image
SMVIT 210
Figure 10.3-21:The Original DCT-based JPEG
Algorithm Applied to a Color Image (contd)
SMVIT 211
Figure 10.3-21:The Original DCT-based JPEG
Algorithm Applied to a Color Image (contd)
SMVIT 212
Hybrid and Wavelet Methods
SMVIT 213
• For digital images these techniques can
be applied to blocks (subimages), as well
as rows or columns
• Vector quantization is often combined with
these methods to achieve higher
compression ratios
• The wavelet transform, which localizes
information in both the spatial and
frequency domain, is used in newer hybrid
compression methods like the JPEG2000
standard
SMVIT 214
• The wavelet transform provides superior
performance to the DCT-based
techniques, and also is useful in
progressive transmission for Internet and
database use
SMVIT 215
• Thus the user need not wait for an entire
high quality image before they decide to
view it or move on
SMVIT 216
• The general algorithm is as follows:
SMVIT 217
3. Scalar quantize the 0 band linearly to 8
bits
SMVIT 218
SMVIT 219
• The example algorithms shown here utilize
10‑band wavelet decomposition
(Figure 10.3-22b), with the Daubecies 4
element basis vectors, in combination with
the vector quantization technique
SMVIT 220
• One algorithm (WVQ4) employs the PCT
for preprocessing, before subsampling the
second and third PCT bands by a factor of
2:1 in the horizontal and vertical direction
SMVIT 221
SMVIT 222
• The table (10.2) lists the wavelet band
numbers versus the three WVQ algorithms
SMVIT 223
• Vector quantization is used for bands 1-8,
where the number of bits per vector
defines the size of the codebook
• The highest band is completely eliminated
(0 bits are used to code them) in WVQ2
and WVQ4, while the highest three bands
are eliminated in WVQ3
• For WVQ2 and WVQ3, each of the red,
green and blue color planes are
individually encoded using the parameters
in the table
SMVIT 224
SMVIT 225
SMVIT 226
Figure 10.3.23 Wavelet/Vector Quantization (WVQ)
Compression Example (contd)
SMVIT 227
• The JPEG2000 standard is also based
on the wavelet transform
SMVIT 228
• The goals are as follows:
SMVIT 229
4. To allow random access to subimages
SMVIT 230
• The one-dimensional wavelet transform is
applied to the rows and columns, and the
coefficients are quantized based on the
image size and number of wavelet bands
utilized
SMVIT 231
Figure 10.3-24: The JPEG2000 Algorithm Applied to a
Color Image
SMVIT 232
Figure 10.3-24: The JPEG2000 Algorithm Applied to a
Color Image (contd)
SMVIT 233
Figure 10.3-21:The Original DCT-based JPEG
Algorithm Applied to a Color Image (contd)
SMVIT 234
Figure 10.3-24: The JPEG2000 Algorithm Applied to a
Color Image (contd)
Note: The JPEG2000 image is much smoother, even with the zero-order hold enlargement
SMVIT 235