BCE613A-MOD 3
BCE613A-MOD 3
3.1 INTRODUCTION
Compression: Technique, which is first applied to the source information prior to its transmission.
Compression done to:
1. Reduce the volume of information to be transmitted text, fax, and images
2. Reduce the bandwidth required for the transmission of speech, audio, and video
Page 1
2. Lossless and lossy compression algorithms can be lossless or lossy
Lossless compression algorithm:
Aim : To reduces the amount of source information to be transmitted in such a way that in destination
when decompressed there is no loss of information.
Reversible compression is another name of lossless compression.
Ex.: Text file transfer over the network no, part of the source information is lost during either the
compression or decompression operations
Lossy compression algorithm:
Aim: Normally, not to produce the exact copy of the source information after decompression, but to
produce ideally a close approximation of the original data.
Page 2
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 indicate:
1. Particular character or bit being transmitted and
2. Number of characters/bits in the substring
Destination knows the set of codewords being used.
Destination simply, interprets each codeword received and outputs the appropriate number of characters
or bits Ex.: 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 of typed documents scanner produces long substrings of either binary 0s or 1s are
transmitting directly. Instead 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… 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
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.
Page 3
Ex.: String of text in character A may occur more frequently than character P which again , will occur
more frequently than character Z, and so on
Statistical encoding uses this property by using the set of variable length codewords with the shortes
codewords used to represent the most frequently occurring symbols.
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 of a longer codeword
otherwise, the decoder will interpret the string on the wrong codeword boundaries.
Prefix property in the codeword set avoids the above problem.
Source encoding
It uses a particular property of the source information to produce an alternative form of representation
which is:
1. Compressed version of the original form or
2. Is more amenable to the application of compression
1. Differential encoding
Small codewords are used, each of which indicates only the difference in amplitude between the current
value/signal being encoded and the immediately preceding value/signal.
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 obtained
2. Transform Encoding
Transforming the source information from one form into another which is more readily compressible
In general there is no loss of information associated with the transformation operation.
Applcations: image and video applications.
Page 4
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.
Moving from one position in the matrix to the next magnitude of each pixel value can be varying.
Spatial
frequency is a 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 relate changes in
magnitude of the pixels.
It is true if, matrix been scanned in either, the horizontal or vertical direction, which provides the
horizontal and vertical frequency components of the image.
In practice, Human eye is less sensitive to the higher spatial frequency components associated with an
image, 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 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. 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.
Page 5
Transformation using DCT is lossless apart from small rounding errors in the mathematics.
Once the equivalent matrix of spatial frequency components known as coefficients 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
3 different types of text are represented as strings of characters from selected a defined set of strings
and alphanumeric characters are interspersed with additional control characters
Entropy encoding (statistical encoding) methods are lossless and used for text compression.
Statistical encoding method: Two types
1. Use single character as the basis of deriving an optimum set of codewords.
Ex.: Huffman and arithmetic coding algorithm
2. Use variable-length strings of characters
Ex.: Lempel-Ziv (LZ) algorithm
1. 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.
Page 6
Using static coding an optimum set of variable length codewords is derived with the shortest codewords
used to have more frequently occurring characters.
2. Dynamic coding(adaptive coding):
Each uses a different algorithm to derive the codeword set.
Intended for more general applications - type of text transferring may vary from one transfer to another.
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
Fig: Example of Huffman code tree - corresponding to string of characters - AAAABBCD branch as
divides - binary value 0 of 1 - assigned to each new branch - 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 - 4*1+2*2+1*3+1*3=14bits - to transmit the complete string –
AAAABBCD.
Shorter codeword will never form the start of a longer codeword - prefix property.
Received bitstream can be decoded - by carrying out a recursive search bit by bit until each valid
codeword is found.
Page 7
AAAABBCD
Page 8
Fig. shows the flowchart of a suitable decoding algorithm
Assumption: Table of codewords - are avaialable at the receiver - 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.
Page 9
A series of message is to be transferred between two computers over a PSTN. The message comprise just
the character A to H with 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 Shannon’s formula to derive the minimum average number of bits per character.
b) Use Huffman coding to derive a codeword set.
C) Derive the average number of bits per codeword.
Page 10
Arithmetic coding
No. of decimal digits in the final codeword - increases linearly with the number of characters in the string
to be encoded.
Max. no. of characters in a string - is determined by the precision with which floating-point numbers are
represented in the source and destination computers.
Complete message may be first fragmented into multiple smaller strings
Each string is then encoded separately - and the resulting set of codewords sent as a block of floating-
point numbers each in a known format.
Alternatively - binary arithmetic coding can be used.
Page 11
Lemple-Ziv (LZ) Coding
Lempel-Ziv compression algorithm: uses strings of characters - as the basis of the coding algorithm.
Ex.: For compression of text -Table containing all the possible character strings. Words – that occur in
the text to be transferred is held by both encoder and decoder
Instead of sending the word as a set of individual say ASCII codewords - the encoder ends only the
index of where the word is stored in the table.
Word processing packages - had dictionary associated text around 25000words will be - hence 15 bits
which has 32768 combinations are required to encode the index.
To send "multimedia" - just 15bits needed instead 70bits with 7bit ASCII codewords.
Compression ratio - 4.7:1. Shorter words will have - lower compression ratio and longer words a higher
ratio.
Requirement
Copy of the dictionary is held by both the encoder and the decoder standard word processing package to
be used.
For transmission of text can be relatively inefficient if the text to be transmitted comprises only a small
subset of the words stored in the dictionary.
Page 12
Text to be compressed starts with the string: This is simple as it is ....
Page 13
3.4 Image Compression
Images can be :
Digitized Images
Used extensively with the Internet for the representation and compression of graphical images.
Color images comprising 24-bit pixels (8 bits each for R, G, and B) are supported 2^24 colors
among 256 colors choosing by GIF (reduces no of possible colors that are present) - which matches
most closely those used in original image.
Resulting table of colors so, consists of 256 entries each of which contains a 24-bit color value.
Instead of sending 24-bit value – 8 bit index to the table entry that contains closest match color to
the original - is sent to decoder.
Compression ratio of 3:1 is obtained.
Global color table : is called to table of colors if table of colors can relate to the whole image.
Local color table : is called to table of colors if table of colors relate to a portion of the image.
Contents of the table are sent across the network - together with the compressed image data and
other information - such as aspect ratio, screen size, in standardized format.
Page 14
LZW - coding used for further levels of compression. It can be done - by extending the basic color table
dynamically - as the compressed image data is being encoded and decoded.
GIF Allows the image transfer over the network - in an interlaced mode.
This can be used to transfer images over either low bit rate channels or the Internet - which
provides a variable transmission rate.
From this - compressed image data is organized - so, that decompressed image is built up in a
progressive way as - the data arrives – this is done by - dividing the compressed data by 4 groups:
1. Contains 1/8 th of total compressed image data
2. Contains a further 1/8 th
3. Contains a further 1/4 th
4. Contains the last remaining 1/2 nd
Page 15
TIFF(Tagged Image File Format)
Page 16
Starts with the basic color table - containing 256 colors
Table can be extended to contain up to 4096 entries - containing common strings of pixels - in the image
being transferred.
Standard format is used - for the transfer of both the color table and the compressed image data.
Digitized documents
In digital representation of scanned page - one single binay bit is used to represent each picture element -
with the resolutions of needed - uncompressed bit stream of the order of 2Mbits
Most of the cases in - this must be transferred using modems and PSTN
If the relatively low bit rate modems and PSTN used - it will costly and time consuming to transfer a total
document comprising many pages in the basic form.
In most documents - many scanned lines consist only of long strings of white pels.
While - others comprise - a mix of long strings of white and long strings of black pels.
Normally - facsimile machines are used with - public carrier networks .
T4:
Uses modems for use with analog PSTN.
Time taken to transmit a page - is reduced to less than a minute with these machines.
Uses no error-correction protocol.
T6 :
Used with digital networks such as ISDN
Higher transmission rate of 64kbps - is used
Time taken to transmit a page - is less than a few second.
Page 17
T4 and T6:
Use data compression.
Compression ratios - in excess of 10:1 are common with most document pages.
Standardization process - extensive analyses of typical scanned document pages were made.
Tables of codewords - produced based on the relative frequency of occurrence of the number of
contiguous white and balck pels found in a scanned line
Resulting codewords are fixed and grouped into two separate tables -
1. Termination-codes table
2. Make-up codes table
Codewords in the termination - codes table are for white or black runlengths of from 0 to 63 pels - in steps
of 1 pel.
Make-up codes table contains - codewords for white or black run-lengths - that are multiples of 64 pels.
Overscanning technique used - in which all lines start with a minimum of one white pel -so, here -
receiver knows the first codeword always relates to white pels and then alternates between black and
white
This scheme- use 2 sets of codewords (termination and make-up) - these are known as modified Huffman
codes
Ex.: Run-length of 12 white pels is coded directly as 0010000
Run-length of 12 black pels is coded directly as 0000111
Run-length of 140 black pels is coded as - 000011001000 + 0000111 - 128 +12 pels
Run-length exceeding 2560 pels - are encoded - using more than one make-up code + one termination
code.
EOL ( End-of-line) code: to enable the receiver to regain synchronism - each scanned line is transmitted
with EOL code.
T4 (Group 3):
One-dimensional coding scheme - used here - since, each scanned line is encoded independently.
Scanned image contains significant areas of white or black pels - for ex. which occur - where documents
consist of letters and line drawings
T4 works satisfactorily for documents containing - photographic images - however, not satisfactory - as
the different shades of black and white –are represented by varying densities of black and white pels.
This in turn - results - in a large number of very short black or white run-lengths which - with T4 coding
scheme - can lead to negative compression ratio (more bits are needed to send the scanned document in its
Page 18
compressed form than are needed in its uncompressed form
T6 coding scheme:
Compulsory feature in Group 4 machines.
Optional feature for Group 3 facsimile machines - when used here, EOL code at the end of each
(compressed) line has an additional tag bit added.
If, it is a binary 1, then the next line has been encoded using T4 coding scheme.
If, it is a binary 0, then the next line has been encoded using T6 coding scheme (known as MMR coding).
2-D coding : Alternative name is MMR coding (Modified Modified READ coding) - since, it
identifies black and white run-lengths by comparing adjacent scan lines.
MMR coding:
It uses the fact that - most scanned lines differ from - the previous line by only a few pels.
Ex.: If a line contains a black-run hen the next line will normally contain the same run plus or minus up to
3 pels.
Run-lengths associated with a line are identified by comparing the line contents - known as - coding line
(CL) - with the immediately Preceding line - known as the reference line (RL).
Assumption: first reference line is assumed to be an imaginary all-white line and the first lien proper is
encoded relative to this.
Run lengths associated with a coding line - can be identified - as one of 3 possibilities of modes - relative
to the reference line.
3 modes are identified by the position of the next run-length - in the reference line (b1b2) relative to the
start and end of the next pair of run-lengths in the coding line (a0a1 and a1a2).
Page 19
1. Pass mode:
Run-length in the reference line (b1b2) is to the left of the next run-length in the coding line (a1a2)
i.e., b2 is to the left of a1
2. Vertical mode:
Run-length - in the reference line (b1b2) overlaps the next run-length in the coding line (a1a2) by
a maximum of plus or minus 3 pels
For this mode - just the difference run-length a1b1 is coded
Most codewords - are in this category.
Page 20
3. Horizontal mode:
Run-length - in the reference line (b1b2) overlaps the run-length (a1a2) - by more than plus or minus 3
pels. For this mode - two run-lengths a0a1 and a1a2 are coded using the codewords .
Page 21
Digitized Pictures
Digitization of both continuous tone monochromatic pictures and color pictures.
Amount of memory needed - 307 kbyte to 2.4 Mbytes.
Interactive applications - in unacceptable long delays - in some low bit rate networks are causes
problem.
JPEG (Joint Photographic Experts Group)
JPEG - also forms the basis for most of the video compression algorithms.
JPEG
JPEG is defined in the international standard IS 10918.
The standard defines a range of different compression modes, each of which is intended for use in a
particular application domain.
Lossy Sequential Mode/ Base Mode is intended for the compression of both monochromatic and color
digitized pictures/ images as used in multimedia communication applications,
There are 5 main stages associated with this mode:
1. Image/ block preparation.
2. Forward DCT
3. Quantization
4. Entropy encoding
5. Frame Building
Page 22