Professional Documents
Culture Documents
CHP - 10 - Image Compression - Error Free and Lossy Compression Min
CHP - 10 - Image Compression - Error Free and Lossy Compression Min
10
10.0 Objectives
10.1 Error-free compression
10.2 Variable-length coding
10.2.1 Huffman coding
10.2.2 Arithmetic coding
10.3 LZW (Lempel-Ziv-Welch) Coding
10.4 Bit-Plane coding
10.4.1 Run-length Coding of bit-plane images
10.5 Lossless Predictive Coding
10.6 Summary
10.7 Unit end exercise
10.8 Further Reading
10.0 OBJECTIVES
www.rocktheit.com www.facebook.com/rocktheit
2 Image Compression: Error Free and Lossy Compression
If the compression and decompression processes induce no information loss, then the
compression scheme is lossless; otherwise, it is lossy.
Error-free compression techniques usually rely on entropy-based encoding algorithms.
How do we measure information?
What is the information content of a image?
What is the minimum amount of data that is sufficient to describe completely an image
without loss of information?
Modelling Information
Information generation is assumed to be a probabilistic process.
Idea: associate information with probability!
A random event E withprobability P(E) contains:
Using
Entropy :
www.rocktheit.com www.facebook.com/rocktheit
3 Image Compression: Error Free and Lossy Compression
units/pixel
Redundancy
Redundancy
where:
if Lavg= H, the R=0 (no redundancy
Entropy Estimation
It is not easy to estimate H reliably!
Image :
Table 10.1
The first-order estimate provides only a lower-bound on the compression that can be
achieved.
Differences between higher-order estimates of entropy and the first-order estimate
indicate the presence of interpixel redundancy!
www.rocktheit.com www.facebook.com/rocktheit
4 Image Compression: Error Free and Lossy Compression
A variable-length code is a code which maps source symbols to a variable number of bits.
Variable-length codes can allow sources to be compressed and decompressed with zero
error (lossless data compression)
Most entropy-based encoding techniques rely on assigning variable-length codewords to
each symbol, whereas the most likely symbols are assigned shorter codewords.
In the case of image coding, the symbols may be raw pixel values or the numerical values
obtained at the output of the mapper stage (e.g., differences between consecutive pixels,
run-lengths, etc.).
The most popular entropy-based encoding technique is the Huffman code.
It provides the least amount of information units (bits) per source symbol.
www.rocktheit.com www.facebook.com/rocktheit
5 Image Compression: Error Free and Lossy Compression
Step I:
Order the probabilities of the symbols under consideration
www.rocktheit.com www.facebook.com/rocktheit
6 Image Compression: Error Free and Lossy Compression
Step II:
www.rocktheit.com www.facebook.com/rocktheit
7 Image Compression: Error Free and Lossy Compression
Huffman coding use an integer number (k) of bits for each symbol, hence k is never less
than 1. ie.Can not assign fractional codelengths.
Can not efficiently adapt to changing source statistics.
Number of entries in Huffman table grows exponentially with block size
Sometimes, e.g., when sending a 1-bit image, compression becomes impossible.
www.rocktheit.com www.facebook.com/rocktheit
8 Image Compression: Error Free and Lossy Compression
Algorithm :
www.rocktheit.com www.facebook.com/rocktheit
9 Image Compression: Error Free and Lossy Compression
www.rocktheit.com www.facebook.com/rocktheit
10 Image Compression: Error Free and Lossy Compression
0 1
2) Subdivide [0, 1) based on the probability of αi
Example
Table 10.4
www.rocktheit.com www.facebook.com/rocktheit
11 Image Compression: Error Free and Lossy Compression
The Lempel-Ziv-Welch algorithm is named after the three inventors and is usually referred
to as the LZW algorithm.
www.rocktheit.com www.facebook.com/rocktheit
12 Image Compression: Error Free and Lossy Compression
These are lossless compression algorithms in which no data is lost, and the original image
can be entirely reconstructed from the encoded image.
Requires no prior knowledge of pixel probability distribution values.
Included in GIF and TIFF and PDF file formats
LZW uses fixed-length codewords to represent variable-length strings of
symbols/characters that commonly occur together.
A codebook (or dictionary) needs to be constructed
The LZW encoder and decoder build up the same dictionary dynamically while receiving
the data.
LZW places longer and longer repeated entries into a dictionary, and then emits the code
for an element, rather than the string itself, if the element has already been placed in the
dictionary.
Initially, the first 256 entries of the dictionary are assigned to the gray levels 0,1,2,..,255
(i.e., assuming 8 bits/pixel)
Consider a 4x4, 8 bit image
39 39 126 126
39 39 126 126
39 39 126 126
39 39 126 126
As the encoder examines image pixels, gray level sequences (i.e., blocks) that are not in
the dictionary are assigned to a new entry.
Table 10.5
www.rocktheit.com www.facebook.com/rocktheit
13 Image Compression: Error Free and Lossy Compression
Compression Algorithm:
BEGIN
s = next input character;
while not EOF
{ c = next input character;
if s + c exists in the dictionary
s = s + c;
else
{ output the code for s;
add string s + c to the dictionary with a new code;
s = c;
}
}
output the code for s;
END
www.rocktheit.com www.facebook.com/rocktheit
14 Image Compression: Error Free and Lossy Compression
Decoding LZW
The dictionary which was used for encoding need not be sent with the image
Can be built on the “fly” by the decoder as it reads the received code words.
LZW Decompression Algorithm:
BEGIN
s = NIL;
while not EOF
{
k = next input code;
entry = dictionary entry for k;
output entry;
if (s != NIL)
add string s + entry[0] to dictionary with a new code;
s = entry;
}
END
www.rocktheit.com www.facebook.com/rocktheit
15 Image Compression: Error Free and Lossy Compression
A bit plane of a digital image is a set of bits corresponding to a given bit position in each of
the binary numbers representing the image.
www.rocktheit.com www.facebook.com/rocktheit
16 Image Compression: Error Free and Lossy Compression
If we now consider an array containing only the ith bit of every pixel (i = 0,1,….,7), we get
the ithbit plane image.
Let us consider a simple 4x4 array, whose elements are integers in the range 0-15 .
The corresponding 4-bit binary representations are indicated within the parenthesis, s shown
below:
Bitplane coding is a effective technique to reduce inter pixel redundancy is to process each
bit plane individually.
1) Decompose an image into a series of binary images.
2) Compress each binary image (e.g., using run-length coding)
www.rocktheit.com www.facebook.com/rocktheit
17 Image Compression: Error Free and Lossy Compression
www.rocktheit.com www.facebook.com/rocktheit
18 Image Compression: Error Free and Lossy Compression
Since the predictor can only consider the pixels received so far, the prediction is based the
set of pixels from the current row and the set of pixels
where, a1,a2,a3,a4are the coefficients associated with the respective neighboring pixels,
such that a1+ a2+ a3+ a4= 1 .
Above equation describes a linear predictive coding.
The corresponding lossless predictive decoder is shown in figure below :
www.rocktheit.com www.facebook.com/rocktheit
19 Image Compression: Error Free and Lossy Compression
It receives the encodederror signal e (n1, n2)and reconstructs the current pixel s( n1, n2
)using
10.6 SUMMARY
If the compression and decompression processes induce no information loss, then the
compression scheme is lossless; otherwise, it is lossy.
Information generation is to be a probabilistic process.
Variable-length codes can allow sources to be compressed and decompressed with zero
error
Huffman coding is based on the frequency of occurrence of a data item (pixel in images).
Arithmetic encoders are better suited for adaptive models than Huffman coding.
LZW uses fixed-length codewords to represent variable-length strings of
symbols/characters that commonly occur together.
LZW places longer and longer repeated entries into a dictionary, and then emits the code
for an element, rather than the string itself, if the element has already been placed in the
dictionary.
A bit plane of a digital image is a set of bits corresponding to a given bit position in each of
the binary numbers representing the image.
Bitplane coding is an effective technique to reduce inter pixel redundancy is to process
each bit plane individually.
In one-dimensional run-length coding schemes for binary images, runs ofcontinuous 1s or
0s in every row of an image are encoded together, resulting insubstantial bit savings.
www.rocktheit.com www.facebook.com/rocktheit
20 Image Compression: Error Free and Lossy Compression
www.rocktheit.com www.facebook.com/rocktheit