MMC Notes Module 3
MMC Notes Module 3
MMC Notes Module 3
Module 3
Text and Image Compression
3.1 Introduction
This denotes that in order for the destination to reproduce the original source
information nearly exact copy it, a matching decompression algorithm must be
applied to it.
The application of the compression algorithm is the main fuction carried out by the
source encoder and the decompression algorithm is carried out by destination decoder.
In the above figure two computers communicating with each other, the time required
to perform the compression and decompression algorithms is not always critical.
Therefore both algorithms are normally implemented in software within two
computers.
The general scheme is shown in part (a) of the above Figure 3.1.
It is an example application which uses this approach is the compression of text or
image files.
In some application time required to perform compression and decompression
algorithms in software is not acceptable and instead of two algorithms must be
performed by special processors in separate units as shown in part (b).
Statistical Encoding
Statistical encoding uses a set of variable-length codewords with the shorter
codewords used to represent the more frequently occurring symbols.
The theoretical minimum average number of bits that are required to transmit a
particular source stream is known as the Entropy of the source.
Entropy is defined as
where n is the number of different symbols in the source stream and Pi is the
probability of occurrence of symbol i.
For a particular codebook, the average number of bits per codeword is given by ,
Figure 3.2 Transform Coding: (a) Example pixel Patterns; (b) DCT transform Principles
The human eye is less sensitive to the higher spatial frequency components.
If we can transform the original spatial form of representation into an equivalent
representation involving spatial frequency components, then we can more readily
identify and eliminate those higher frequency components which the eye cannot
detect thereby reducing the volume of information.
The transformation of a two-dimensional matrix of pixel values into an equivalent
matrix of spatial frequency components discrete cosine transform(DCT) which is
shown in Figure 3.2 (b).
Figure 3.3 Huffman Code Tree Construction: (a) Final tree with Codes; (b) Tree
Derivation
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.
4 × 1 + 2× 2 + 1×3 + 1×3 = 14 bits
Figure 3.4 shows the example of Huffman encoding example.
Huffman codewords have the unique property that a shorter codeword will never form
the start of a longer codeword prefix property.
Figure 3.7 Arithmatic Coding Principles: (a) Example Character set and their range
Assignments; (b) Encoding of the string went..
The first character to be encoded w is in the range 0.8 To 0.9, then itself subdivided
into five further segments.
The segment for the character e, is from 0.8 to 0.83(0.8 + 0.3× 0.1).
Figure 3.8 LZW Compression algorithm: (a) Basic operation; (b) Dynamically extending
the number of entries in the dictionary
The encoder prior to sending each word in the form of single characters, first checks
to determine if the word is currently stored in its dictionary and, if it is, it sends only
the index for the word.
The available space become full, then the number of entries is allowed to increase
incrementally.
Figure 3.9 GIF compression principles: (a) Basic operational mode; (b) Dynamic mode
using LZW coding
JPEG Encoding
i) Image/block preparation
The four alternative forms of representation are shown in Figure 3.15 (a).
Once the source image format has been selected and prepared, the set of values in
each matrix are compressed separately using the DCT.
Before performing the DCT on each matrix, however a second step known as Block
preparation is carried out.
It would be too time consuming to compute the DCT of the total matrix in a single
step so each matrix is first divided into set of smaller 8× 8 submatrics as a block
which is shown in part (b).
iii) Quantization
The human eye responds primarily to the DC coefficient and the lower spatial
frequency coefficients.
Quantization phase by dropping-in practice, setting to zero-those spatial frequency
coefficients in the transformed matrix whose amplitudes are less than a defined
threshold value.
The quantization process aims to reduce the size of the DC and AC coefficients so
that less bandwidth is required.
A division operation is performed using the defined threshold value as the divisor.
The quantization table with the threshold value to be used with a particular DCT
coefficient in the corresponding position in the matrix.
An example set of threshold values is given in the quantization tableshown in Figure
3.17.
Zig-zag scan
The DC coefficient and lower-frequency AC coefficients-both
horizontal and vertical-are scanned first.
After quantization, the 63 AC coefficients are ordered into the “zig-
zag” sequence (for entropy encoding) as shown in Figure 3.18.
The probability of coefficients being zero is an increasing monotonic
function of the index.
The dc coefficients are encoded using the predictive coding techniques.
There is usually a strong correlation between dc coefficients of
adjacent 8x8 blocks.
Differential Encoding
The first element in each transformed block is the DC coefficient which
is a measure of the average color/luminance/chrominance.
The DC coefficient varies only slowly from one block to the next.
Differential encoding since this encodes only the difference between
each pair of values.
Runlength Encoding
The remaining 63 values in the vector are the AC coefficients.
Each pair is made up of (skip, value) where skip is the number of zeros
in the run.
Figure 3.18 would be encoded as: (0,6) (0,7) (0,3) (0,3) (0,3) (0,2)
(0,2) (0,2) (0,2) (0,0).
Final pair (0,0) indicates the end of the string for this block and that all
the remaining coefficients in the block are zero.
Huffman Encoding
Significant levels of compression can be obtained by replacing long
string of binary digits by a string of much shorter codewords
The length of each codeword being a function of its relative frequency
of occurrence
v) Frame Building
The frame builder is to encapsulate all the information relating to an encoded
image/picture in this format.
This is shown in Figure 3.20.
JPEG Decoding
As we can see in Figure 3.21, a JPEG decoder is made up of a number of stages which
are simply the corresponding decoder sections of those used in the encoder.
On reciept of the encoded bitstream the frame decoder first identifies the control
information and tables within the various headers. Then control information passes
through the image builder.
The compressed bitstream it start pass to the Huffman decoder which carries out the
corresponding decompressed streams containing DC and AC coefficients of each
block are then passed to the diffential and run length decoders respectively.
Then the resulting values is then dequantized using either default or preloaded values
in the quantization table.
Each resulting block of 8 X 8 spatial frequency coeffients is passed in turn to the
inverse DCT which transforms them back into their spatial form.