Multimedia Communication Vtu Unit 3
Multimedia Communication Vtu Unit 3
UNI T 3:
Text and Image Compression: Introduction, Compression principles, Text compression,
Image compression 6 Hours
TEXT BOOK:
1. Multimedia Communications: Applications, Networks, Protocols and Standards, Fred
Halsall, Pearson Education, Asia, Second Indian reprint 2002.
REFERENCE BOOKS:
1. Multimedia Fundamentals: Vol 1 - Media Coding and Content Processing, Ralf
Steinmetz, Klara Narstedt, Pearson Education, 2004.
Special Thanks To:
1. Ramisuniverse.
PREPARED BY:
RAGHUDATHESH G P
Asst Professor
ECE Dept, GMIT
Davangere 577004
Cell: +917411459249
Mail: [email protected]
Quotes from Great People:
Dream, Dream, Dream, Dreams transform into thoughts And thoughts result in action.
The knowledge sacrifice is superior to any material sacrifice.
Life's not fair, get over it.
Its fine to celebrate success, but it is more important to heed the lessons of failure.
Depth of friendship does not depend on length of acquaintance.
When death is certain, it is best to sacrifice oneself for a good cause.
A true success makes up for a hundred false trails.
Success is always just an idea away.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 1
R
a
g
h
u
d
a
t
h
e
s
h
G
P
TEXT AND IMAGE COMPRESSION
INTRODUCTION:
In many Multimedia applications a technique known as compression is applied to the
source information prior to its transmission.
Compression done to achieve 2 things:
1. Reduce the volume of information to be transmitted for text, fax, and images.
2. Reduce the bandwidth required for the transmission of speech, audio, and video.
COMPRESSION PRINCIPLES:
Compression algorithms based on the following compression principles:
1. Source encoders and destination decoders
2. Lossless and lossy compression
3. Entropy encoding
4. Source encoding
Source encoders and destination decoders:
Prior to transmitting the source information relating to a particular multimedia
application, a compression algorithm is applied to it.
In order for the destination to reproduce the original source information or, in some
instances, a nearly exact copy of it a matching decompression algorithm must be applied
to it.
The application of the compression algorithm is the main function carried out by the
source encoder.
The application of the decompression algorithm is the main function carried out by the
destination decoder.
In applications which involve two computers communicating with each other, the time
required to perform the compression and decompression algorithms is not always
critical both algorithms are normally implemented in software within the two computers
as shown in figure below.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 2
R
a
g
h
u
d
a
t
h
e
s
h
G
P
An application which uses this approach is the compression of text and/or image files.
In applications, where the time required to perform the compression and decompression
algorithms in software is not acceptable and instead the two algorithms must be
performed by special processors in separate units as shown in figure below.
Lossless and lossy compression:
Compression algorithms can be classified as being either lossless or lossy.
Lossless compression algorithm: The aim is to reduce the amount of source information
to be transmitted in such a way that, when the compressed information is decompressed,
there is no loss of information.
Ex.: transfer of a text file over a network, since no, part of the source information
is lost during either the compression or decompression operations.
Lossless compression algorithm: The aim is normally not to reproduce an exact copy
of the source information after decompression but rather a version of its which is
perceived by the recipient as a true copy. With such algorithms the higher level of
compression being applied to the source information the more approximate the received
version becomes.
Ex.: transfer of digitized images, audio and video streams. In such cases, the
sensitivity of the human eye or ear is such that any fine details that may be
missing from the original source signal after decompression are not detectable.
Entropy encoding:
It is lossless and independent of the type of information that is being compressed.
Concerned solely with how the information is represented.
Ex.: Run-length encoding and Statistical encoding.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 3
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Run-length encoding:
Typical applications: When source information comprises long substrings of the same
character or binary digit.
Here, instead of transmitting source string in the form of independent codewords or bits
source string is transmitted in the form of different set of codewords which indicates:
1. Particular character or bit being transmitted and
2. Number of characters/bits in the substring
Providing the destination to know the set of codewords being used destination simply,
interprets each codeword received and outputs the appropriate number of characters or
bits.
Ex.: An application involves transmission of long strings of binary bits that comprise
limited number of substrings. Each substring can be assigned a separate codeword, total bit
string is then transmitted in the form of the string of codewords selected from the
codeword set.
Ex.: Transmission of the binary strings produced by the scanner in a facsimile machine.
When scanning typed documents in many instances scanner produces long substrings of
either binary 0s or 1s. Instead of transmitting directly, they are sent in the form of a string
of codewords each indicating both the bit 0 or 1 and the number of strings in the substring.
Ex.: if the output of the scanner was 000000011111111110000011 then it can be
represented as (0,7) (1,10) (0,5)(1,2)
Since, only the two binary digits 0 and 1 are involved and if, first substring always
comprises binary 0s then, the string could be represented as 7, 10, 5, 2
To send this in the digital form, individual decimal digits would be sent in their binary
form. Assuming the fixed number of bits per codeword number of bits per codeword
would be determined by the largest possible substring.
Statistical encoding:
Applications use a set of codewords to transmit the source information.
Ex.: Set of ASCII codewords are often used for the transmission of strings of characters.
Normally, all the codewords in the set comprise a fixed number of binary bits.
Ex.: 7 bits in the case of ASCII.
In many applications: Symbols (characters) and hence codewords that are present in the
source information do not occur with the same frequency of occurrence, that is with equal
probability.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 4
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Ex.: Consider a string of text in which character A may occur more frequently than
character P which again, will occur more frequently than character Z, and so on.
Statistical encoding exploits this property by using the set of variable length codewords,
with the shortest codewords used to represent the most frequently occurring symbols.
Use of variable-length codewords is not quite as straight-forward. Destination must know
the set of codewords being used by the source as in run-length encoding.
When variable-length codewords used, in order for the decoding operation to be carried
out correctly. It is necessary to ensure that a shorter codeword in the set does not form the
start/beginning of a longer codeword otherwise; the decoder will interpret the string on the
wrong codeword boundaries.
Prefix property codeword set are used, which avoids the above happening.
Ex.: Huffman encoding algorithm.
Source entropy: Theoretical minimum average number of bits that are required to
transmit a particular source stream and is given by
Entropy,
Here,
o n number of different symbols in the source stream.
o P
i
probability of occurrence of symbol i.
Efficiency of a encoding scheme: ratio of the entropy of the source to the average number
of bits per codeword that are required with the scheme
Source encoding:
Uses a particular property of the source information to produce an alternative form of
representation which are:
1. Compressed version of the original form
2. Is more amenable to the application of compression.
Differential encoding:
Used extensively in applications where, the amplitude of a value or signal covers a large
range but Difference in amplitude between successive values/signals is relatively small.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 5
R
a
g
h
u
d
a
t
h
e
s
h
G
P
To exploit this property of the source information: A set of smaller codewords can be
used each of which indicates only difference in amplitude between the current value/signal
being encoded and the immediately preceding value/signal instead, of using a relatively
large codewords to represent the amplitude of each value/signal.
Ex.: If the digitization of analog signal requires say, 12 bits to obtain the required dynamic
range but, the maximum difference in amplitude between successive samples of the signal
requires only 3 bits then, by using only the difference values a saving of 75% on
transmission bandwidth can be saved.
Differential encoding can be:
1. lossless or
2. lossy.
Selection of the mode (lossy or lossless) depends on the number of bits used to encode the
difference values.
Can be lossless if the number of bits used is sufficient to cater for the maximum difference
value.
Can be lossy if the number of bits used is not sufficient to cater for the maximum
difference value.
Transform encoding:
Involves transforming the source information from one form into another form which,
lending it to more readily to the application of compression.
In general, there is no loss of information associated with the transformation operation.
Applications: image and video applications.
Ex.: Digitization of a continuous tone monochromatic image produces a 2-D matrix of
pixel values each of which represents the level of gray in a particular position of the image.
Scenario: Moving from one position in the matrix to the next magnitude of each pixel
value can be varying. So, if a scan if performed across the pixel locations rate of change in
magnitude will vary from zero, if all the pixel values remain the same to a low rate of
change if, say one half is different from the next half through to a high rate of change if
each pixel magnitude changes from one location to the next as shown in the figure below.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 6
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Spatial frequency: It is the rate of change in magnitude as one traverses the matrix.
For any particular image there will be a mix of different spatial frequencies whose
amplitudes are determined by the related changes in magnitude of the pixels.
In practice Human eye is less sensitive to the higher spatial frequency components
associated with an image than, the lower frequency components. If the amplitude of the
higher frequency components falls below a certain amplitude threshold they will not be
detected by the eye.
Thus, in terms of compression: If we can transform the original spatial form of
representation into an equivalent representation involving spatial frequency components
then, more readily identifying and eliminating those higher frequency components which
the eye cannot detect can be done. It reduces the volume of information to be transmitted
without degrading the perceived quality of the original image.
DCT (Discrete Cosine Transform):
Transformation of 2-D matrix of pixel values into an equivalent matrix of
spatial frequency components can be carried out from this mathematical
technique.
Transformation using DCT is lossless apart, from small rounding errors in the
mathematics.
Once the equivalent matrix of spatial frequency components known as coefficients
has been derived then any frequency components in the matrix whose amplitude is
less than a defined threshold can be dropped it is at this point DCT operation, will
become lossy. Fig. shows the basic principle behind the DCT.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 7
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Text Compression:
3 different types of text unformatted, formatted and hyper text are all represented as
strings of characters selected from a defined set.
The strings comprise alphanumeric characters which are interspersed with additional
control character.
Different types of text use and interpret the latter in different ways.
Compression algorithm associated with text must be lossless.
Due to the above reason we use entropy encoding in particular, statistical encoding
methods.
Two types of Statistical encoding methods are used with text:
Use single character as the basis of deriving an optimum set of codewords.
Ex.: Huffman and arithmetic coding algorithm.
Use variable length strings of characters.
Ex.: Lempel-Ziv (LZ) algorithm.
Two types of coding are used with Text:
Static coding:
Intended for applications in which the text to be compressed has known
characteristics in terms of the characters used and their relative frequencies of
occurrence.
Using above an optimum set of variable length codewords (instead of fixed length)
is derived with the shortest codewords used to have more frequently occurring
characters.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 8
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Resulting set of codewords are then used for all subsequent transfers involving this
type of text.
Dynamic coding(adaptive coding):
Intended for more general applications type of text transferring may vary from one
transfer to another.
In this case, optimum set of codewords also likely to vary from one transfer to
another.
Codeword set used to transfer a particular text string is derived as the transfer takes
place this can be done by building up knowledge of both the characters that are
present in the text and their relative frequency of occurrence dynamically as the
characters are being transmitted.
Codewords used change as a transfer takes place in such a way that receiver is able
to dynamically compute the same set of codewords that are being used at each
point during a transfer.
Static Huffman coding:
Character string to be transmitted is first analyzed for character types and their relative
frequency determined.
Coding operation involves creating an unbalanced tree with some branches shorter than
others.
Degree of imbalance is a function of relative frequency of occurrence of the characters
larger the spread, more unbalanced the tree.
Resulting tree obtained from above process is known as Huffman code tree.
Huffman code tree:
Basics:
It is a binary tree with branches assigned a value 0 of 1.
Base of the tree is normally, the geometric top in practice known as root node.
Point at which the branch divides is known branch node.
Leaf node is a termination point of a branch for which the symbols being encoded are
assigned.
Figure Below is an Example of Huffman code tree corresponding to string of characters
AAAABBCD
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 9
R
a
g
h
u
d
a
t
h
e
s
h
G
P
As each branch divides binary value 0 of 1 are assigned to each new branch a 0 for left and
1 for right.
Codewords used for each character (shown in leaf nodes) are got by tracing the path from
root node to each leaf node and forming a string of binary values associated with each
branch traced.
Set of codes associated with this tree is 4*1+2*2+1*3+1*3=14bits is required to transmit
the complete string AAAABBCD.
Figure below shows Huffman tree with information frequency of occurrence of each
characters here characters listed in a column in decreasing weight order.
Tree construction:
Huffman tree can be constructed from the set of codewords, the actual codewords,
however start at the root and not the leaf node.
Optimality check for tree (hence for Codewords):
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 10
R
a
g
h
u
d
a
t
h
e
s
h
G
P
1. Listing the resulting weights of all the leaf and branch nodes in the tree starting
with the smallest weight and proceeding from left to right and from bottom to
top.
2. Tree is optimal if the resulting list increments in weight order.
Each character in its encoded form has a variable number of bits; received bitstream must
be interpreted (decoded) in a bit-oriented way rather than on fixed 7/8 bit boundaries.
Shorter codeword will never form the start of a longer codeword which is a prefix
property.
Prefix property: received bitstream can be decoded by carrying out a recursive search bit
by bit until each valid codeword is found.
Decoding Algorithm:
Figure below shows the flowchart of a decoding algorithm.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 11
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Assumption: Table of codewords are available at the receive and also had corresponding
ASCII codeword.
Received bit stream is held in the variable BIT-STREAM.
Variable CODEWORD - used to hold the bits in each codeword - while it is being
constructed.
From the flow chart once the codeword is identified corresponding ASCII codeword is
written into the variable RECEIVE_BUFFER.
Procedure - repeats until all the bits in the received string have been processed.
Figure below shows example of the decoded string.
Huffman code tree and hence, codewords varies for different sets of characters being
transmitted for the receiver to perform the decoding operation, it must know the codewords
relating to the data being transmitted can be done in 2 ways:
1. Codewords relating to the next set of data are sent before the data is transmitted.
Advantage: adaptive compression since, Codewords can be changed to
suit the type of data being transmitted.
Disadvantage: overhead of having to send the new set of codewords (and
characters corresponding) whenever a new type of data is to be sent.
2. Receiver knows in advance what codewords are being used.
Here the receiver to have one or more different sets of codewords and
Sender to indicate to the receiver through an agreed message which
codeword set to use for the next set of data.
Ex.: word processor and bibliography in text books frequency of
occurrence of characters is used to construct the Huffman code tree for
alphabet. If this data is being sent transmitter and receiver automatically
use this set of codewords.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 12
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Problem: A series of messages is to be transferred between two computers over a PSTN.
The messages comprise just the characters A through H. Analysis has shown that the
probability (relative frequency of occurrence) of each character is as follows:
A and B=0.25, C and D=0.14, E,F,G and H=0.055
(a) Use Shannons formula to derive the minimum average number of bits per
character.
(b) Use Huffman coding to derive a codeword set and prove this is the minimum set by
constructing the corresponding Huffman code tree.
(c) Derive the average number of bits per character for your codeword set and
compare this with:
(i) The entropy of the messages(Shannons value),
(ii) Fixed-length binary codewords,
(iii) 7-bit ASCII codewords.
Solution:
(a) Shannons formula states:
Entropy,
C(i)C(j)
Cos
Cos
Here C(i) and C(j) =
for i , j=0
=1 for all other values of i and
x, y, i , and j all vary from 0 through 7.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 32
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Consider a typical image say of 640 x480 pixels.
If block size is 8 x 8 pixels, then image will have 80 x 60 or 4800 block each of which,
for a screen width of say, 16 inches (400 mm), will occupy a square of only 0.2x0.2
inches (5x 5 mm).
Those regions of picture that contains a single color will generate a set of transformed
blocks all of which will have firstly, the same DC coefficient and secondly AC
coefficient with them.
Also only those areas of picture which contain color transition that will generate a set of
transformed blocks with different DC coefficient and a large number of AC coefficients
with them.
The above features are exploited in the quantization and entropy encoding phases of the
compression algorithm.
Quantization:
The values from the DCT are initially floating point; they are change to integers by
quantization.
During the DCT phase there is very little loss of information the main source of
information loss occurs during the quantization and entropy encoding stages where the
compression takes place.
Human eye responds primarily to the DC coefficient and the lower spatial frequency
coefficients i.e. having higher magnitude volume.
If the magnitude of a higher frequency coefficient is below a certain threshold, the eye
will not detect it.
The above property is exploited in the quantization phase by dropping those spatial
frequency coefficients in the transformed matrix whose amplitudes are less than a defined
threshold value.
Quantization process aims to reduce size of the DC and AC coefficients so that less
bandwidth is required for their transmission.
For the above point a division operation is performed using the defined threshold value as
the divisor.
If the resulting (rounded) quotient is zero, the coefficient is less than the threshold value.
If it is non-zero, this indicates the number of times the coefficient is greater than the
threshold rather than its absolute value.
The sensitivity of the eye varies with spatial frequency, which implies that the amplitude
threshold below which the eye will detect a particular spatial frequency also varies.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 33
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Threshold values used vary for each of the 64 DCT coefficients which are held in a two-
dimensional matrix known as the quantization table with the threshold value to be used
with a particular DCT coefficient in the corresponding position in the matrix.
The choice of threshold values is important and, in practice, is a compromise between the
level of compression that is required and the resulting amount of information loss that is
acceptable.
JPEG standard includes two default quantization table values:
1. One for use with the luminance coefficients and
2. The other for use with the two sets of chrominance coefficients.
It also allows for customized tables, to be used and sent with the compressed image.
An example set of threshold values is given in the quantization table shown in Figure
below together with a set of DCT coefficients and their corresponding quantized values.
Number of points can be concluded from the values shown in the tables:
1. The computation of the quantized coefficients involves rounding the quotients to
the nearest integer value.
2. The threshold values used, in general, increase in magnitude with increasing
spatial frequency.
3. The DC coefficient in the transformed matrix is largest.
4. Many of the higher-frequency coefficients are zero.
It is the last two points that are exploited during the encoding stage.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 34
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Entropy encoding:
It has 4 stages:
1. Vectoring
2. Differential encoding
3. Run-length encoding
4. Huffman encoding.
Vectoring:
Since the output of the quantization stage is a 2-D matrix of values, in order to apply any
entropy encoding to the set of values in the matrix, we must first represent the values in
the form of a 1-D vector and this operation is known as vectoring.
In vectoring operation in order to exploit the presence of the large number of zeroes in
the quantization matrix, a zig-zag scan of the matrix is used as shown in the figure
below.
With this type of scan, the DC coefficient and lower frequency AC coefficients both
horizontal and vertical are scanned first.
All the high frequency coefficients are in sequential order so making this form of
representation more suitable for compression.
Two differential encoding schemas are applied in parallel to the values in the vector.
1. Differential encoding to DC-coefficient only
2. Run-length encoding to AC-coefficient
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 35
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Differential encoding:
In this stage only the difference in magnitude of the DC coefficient in a quantized block
relatively to the value in the preceding block is encoded.
In this way number of bits required to encode DC coefficient is reduced significantly.
Ex: if the sequence of DC coefficients in consecutive quantized blocks-one per block-
were 12,13,11,11,10,..
Corresponding difference amount will be,
12, 1,-2, 0,-1
The difference values are then encoded in the form (SSS,value)
Where,
SSS = number of bits needed to encode the value.
Value = actual bits that represent the value.
Value SSS Encoded value
12 4 1100[ binary form]
1 1 1
-2 2 01[contemporary
form]
0 0
1 1 0
Run-length encoding:
The remaining 63 values in the vector are the AC coefficients and, because of the zig-zag
scan, the vector contains long strings of zeros within it.
To exploit this feature, the AC coefficients are encoded in the form of a string of pairs of
values. Each pair is made up of (skip, value)
where
skip = number of zeros in the run and
value = next non-zero coefficient.
Hence the 63 values in the vector would be encoded as:
(0,6) (0,7) (0,3) (0,3) (0,3) (0,2) (0,2) (0,2) (0,2) (0,0)
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 36
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Note that the final pair (0,0) indicates the end of the string for this block and that all the
remaining coefficients in the block are zero. Also, that the value field is encoded in the
form SSS/ value.
Huffman encoding :
Huffman coding is used to encode the output of both the differential and run-length
encoders.
For the differential-encoded DC coefficients in the block, the bits in the SSS field are not
sent in their unsigned binary form but are sent in a Huffman-encoded form. This is done
so that the bits in the SSS field have the prefix property and this enables the decoder to
determine unambiguously the first SSS field from the received encoded bitstream.
For each of the run-length encoded AC coefficients in the block. The bits that make up
the skip and SSS fields are treated as a single (composite) symbol and this is then encoded
using either the default table of Huffman codewords or a table of codewords that is sent
with the encoded bitstream.
This is done so that the strings of encoded composite symbols all have the prefix property
so that the decoder can interpret the received bitstream on the correct coefficient
boundaries.
To enable the decoder to discriminate between the skip and SSS fields, each combination
of the two fields is encoded separately and the composite symbol is then replaced by the
equivalent Huffman codeword.
Because of the use of variable-length codewords in the various parts of the entropy
encoding stage, this is also known as the variable-length coding (VLC) stage.
Frame building:
In order for the decoder in the remote computer to be able to interpret all the different
fields and tables that make up the bitstream, it is necessary to delimit each field and set of
table values in a defined way. The JPEG standard, therefore, includes a definition of the
structure of the total bitstream relating to a particular image/picture. This is known as a
frame and its outline structure is shown in Figure below.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 37
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Set of Huffman CWs for the block
The role of the frame builder is to encapsulate all the information relating to an encoded
image/picture in this format and, the structure of a frame is hierarchical.
At the top level, the complete frame-plus-header is encapsulated between a start-of-frame
and an end-of-frame delimiter which allows the receiver to determine the start and end of
all the information relating to a complete image/picture.
The frame header contains a number of fields that include:
1. The overall width and height of the image in pixels
2. The number and type of components that are used to represent the image (CLUT,
R/G/B, Y/Cb/Cr )
3. The digitization format used (4:2:2, 4:2:0 etc.).
At the second level, a frame consists of a number of components each of which is known
as a scan. These are also preceded by a header which contains fields that include:
1. The identity of the components (R/G/B etc.)
2. The number of bits used to digitize each component
3. The quantization table of values that have been used to encode each component.
Typically, each scan/component comprises one or more segments each of which can
contain a group of (8 x 8) blocks preceded by a header. This contains the Huffman table
of values that have been used to encode each block in the segment should the default
tables not be used. In this way, each segment can be decoded independently of the others
which overcome the possibility of bit errors propagating and affecting other segments.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 38
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Hence each complete frame contains all the information necessary to enable the JPEG
decoder to identify each field in a received frame and then perform the corresponding
decoding operation.
JPEG decoding:
JPEG decoder is made up of a number of stages which are simply the corresponding
decoder sections of those used in the encoder.
The time to carry out the decoding function is similar to that used to perform the
encoding.
On receipt of the encoded bitstream the frame decoder first identifies the control
information and tables within the various headers.
It then loads the contents of each table into the related table and passes the control
information to the image builder.
It then starts to pass compressed bitstream to the Huffman decoder which carries out the
corresponding decompression operation using either the default or the preloaded table of
codewords.
The two decompressed streams containing the DC and AC coefficients of each block are
then passed to the differential and run-length decoders respectively. The resulting matrix
of values is then dequantized using either the default or the preloaded values in the
quantization table.
Each resulting block of 8 x 8 spatial frequency coefficients is passed in turn to the
inverse DCT which transforms them back into their spatial form using the expression:
P[x,y]=
cos
Where C (i) and C (j) = 1/ for i, j= 0
= 1 for all other values of i and j.
The image builder then reconstructs the original image from these blocks using the
control information passed to it by the frame decoder.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 39
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Compression ratio:
1. JPEG standard is relatively complicated owing to the number of encoding/decoding
stages associated with it, compression ratios in excess of 20:1 can be obtained while
still retaining a good quality output image/picture. This level of compression,
however, applies to pictures whose content is relatively simple - that is, have
relatively few color transitions and
2. For more complicated pictures, compression ratios nearer to 10:1 are more common.
Finally, as with the GIF, it is also possible to encode and rebuild the image the image in a
progressive way by first sending an outline of the image and progressively adding more
detail to it. This can be achieved in the following ways:
1. Progressive mode:
In this mode, first the DC and low-frequency coefficients of each block
are sent and then the higher-frequency coefficients;
2. Hierarchical mode:
In this mode, the total image is first sent using a low resolution - for
example 320 x 240 - then at a higher resolution such as 640 x 480.
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 40
R
a
g
h
u
d
a
t
h
e
s
h
G
P
VTU Questions BE
1. Draw the Adaptive Huffman tree for AADCCDD and obtain the sequence of symbols
and codes sent to the encoder. June 2008 (10 M)
2. What is Dictionary based coding? Write the algorithm for LZW compression and further
obtain the output codes for the string ABABBABCA. June 2008 (10 M)
3. A series of messages is to be transmitted between computers over a PSTN. The messages
comprise the characters A through H. The probability of each character is as follows:
A and B = 0.25 C and D = 0.14 E,F,G and H = 0.055.
a. Use Shanons formula to derive the minimum average number of bits/character.
b. Use Huffman coding to derive codeword and prove that this is the minimum set
by constructing the corresponding Huffman code tree. June 2010 (14 M),
Jan 2014 (10 M)
4. With the help of a block diagram, identify the five main stages associated with the
baseline mode of operation of JPEG encoder and give a brief description of the role of
image/block preparation. June 2010 (6 M)
5. Explain the meaning of the following terms, relating to compression:
a. Lossless and lossy compression.
b. Source and entropy encoding. December 2010 (04 M)
6. Code the given string ABACADABACADABACABAB using Huffman coding.
Derive Huffman code tree. Determine the savings in transmission bandwidth over normal
ASCII and binary coding. December 2010 (06 M), June 2012 (14 M), June 2013
(06 M), Jan 2014 (10 M)
7. With the help of a block diagram, identify the five main stages of operation of JPEG
encoder and explain each stage briefly and decoder. December 2010 (10 M),
December 2011 (06 M), June 2012 (14 M), June 2013 (14 M)
8. Compare Arithmetic and Huffman coding. A message comprising of a string of
characters with probabilities e = 0.3, n = 0.3, t = 0.2, w = 0.1, . = 0.1 is to be encoded.
The message is went. Compute the arithmetic codeword. December 2011 (07 M)
9. Explain the features of TIFF. December 2011 (03 M)
VTU Questions M-Tech
1. Compare Huffman coding and Arithmetic coding, used for data compression. December
2013 (04 M)
2. A series of messages is to be transferred between two computers over a PSTN. The
messages comprise just the characters A through H. Analysis has shown that the
probability (relative frequency of occurrence) of each character is as follows:
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 41
R
a
g
h
u
d
a
t
h
e
s
h
G
P
A and B=0.25, C and D=0.14, E,F,G and H=0.055
a) Use Shannons formula to derive the minimum average number of bits per character.
b) Use Huffman coding to derive a codeword set and prove this is the minimum set by
constructing the corresponding Huffman code tree.
c) Derive the average number of bits per character for your codeword set and compare this
with:
a. The entropy of the messages(Shannons value),
b. Fixed-length binary codewords,
c. 7-bit ASCII codewords. December 2013 (08 M)
3. Explain the principle of operation of the LZW compression algorithm. How this is
different from the LZ-algorithm. December 2013 (07 M)
4. Explain Basic and Dynamic mode of compression of image using GIF. December 2013
(07 M)
5. With the help of neat block diagram, describe the operation of a JPEG decoder. December
2013 (06 M)
Additional Questions:
1. Define Run length encoding & statistical encoding.
2. Differentiate between entropy & source encoding?
3. Explain with the block diagrams DCT, spatial frequency, horizontal and vertical
frequency components?
4. Develop Dynamic Huffman coding tree for following sentence. This is
5. Find the code word for following text went using Arithmetic coding technique. e=0.3,
n= 0.3, t=0.2, w=0.1, .=0.1 & explain the coding operation in detail.
6. Briefly state the Huffman coding algorithm. Show how you would use Huffman coding to
encode the following set of tokens: AAABDCEFBBAADCDF
7. Explain the Dictionary models used for text compression with an example.
8. Explain the principle of operation of the LZW compression algorithm & how this is
different from the LZ algorithm?
9. Describe the principles of TIFF algorithm & its application domains.
10. Why is data compression necessary for Multimedia activities?
11. What is the distinction between lossless and lossy compression? What broad types of
multimedia data are each most suited to?
12. Briefly state the LZW compression algorithm and show how you would use it to encode
the following steam of characters: MYMEMYMO. You may assume that single character
tokens are coded by their ASCII codes, as per the original LZW algorithm. However, for
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 42
R
a
g
h
u
d
a
t
h
e
s
h
G
P
the purpose of the solution you may simply output the character rather than the ASCII
value. JAN 04
13. What is the improvement of the LZW algorithm over the LZ algorithm? Given the
following string as input (excluding the quotes), /THIS/IS/HIS/IS/ with the initial
dictionary below, encode the sequence with LZW algorithm, showing the intermediate
steps.
14. What advantages does the arithmetic coding algorithm offer over Huffman coding
algorithm with respect to data compression? Are there any disadvantages with the
arithmetic coding algorithm? 2010
15. Given the following Differential Pulse Code Modulated (DPCM) Sequence reconstruct the
original signal. +4 + 2 + 3 2 + 3 1 + 1 + 1 2010
16. GIF and JPEG are two commonly used image representations. What images are suitable to
be represented as GIF and JPEG? Do they usually use lossless or lossy compression
Explain the reason by showing the major compression algorithm (for lossless) or the lossy
steps of the algorithm (for lossy). 2011
17. In the following situations, which (mostly) lossless compression algorithm is most
suitable? Briey describe the basic idea of each algorithm in one sentence.
a. Compression of a sequence of tokens with known, uneven probability distribution.
b. Compression of a sequence of tokens with unknown probability but with
reoccurrence of patterns.
c. Compression of a sequence of gradually changing numbers.
d. Compression of a sequence of tokens with same tokens often appearing
consecutively.
18. Given the following Run Length Encoded (RLE) Sequence reconstruct the original 2D
8x8 (binary) data array.
(0; 8),
(0; 1); (1; 1); (0; 4); (1; 1); (0; 1),
(0; 1); (1; 2); (0; 2); (1; 2); (0; 1),
(0; 1); (1; 6); (0; 1),
(0; 2); (1; 4); (0; 2),
(0; 3); (1; 2); (0; 3),
(0; 2); (1; 1); (0; 2); (1; 1); (0; 2),
(0; 1); (1; 1); (0; 4); (1; 1); (0; 1)
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 43
R
a
g
h
u
d
a
t
h
e
s
h
G
P
Test and Image Compression Raghudathesh G P Asst Professor
ECE Dept, GMIT [email protected] Page No - 44
R
a
g
h
u
d
a
t
h
e
s
h
G
P