0% found this document useful (0 votes)
6 views

mod3

Uploaded by

hharismitha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

mod3

Uploaded by

hharismitha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 69

Module-3 Text and Image Compression

 In almost all multimedia applications, a technique known as


compression is first applied to the source information prior to its
transmission

 This is done either to reduce the value of information to be


transmitted – text, fax and images or to reduce the bandwidth that is
required for its transmission – speech, audio or video

Compression principles

Compression principles includes –

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 a compression


algorithm is first applied to it

 At the destination to reproduce the original source information or


sometimes a nearly exact copy of it – a matching decompression
algorithm must be applied to it

 Compression algorithm carried out using a source encoder and the


decompression algorithm is carried out by the destination decoder

 In applications which involve two computers communicating with


each other, normally both algorithms are implemented in software
within the two computers
 Fig 3.1 (a) shows compression of text and or image files

 In other applications, the two algorithms must be performed by


special processors as shown in fig 3.1 (b)

 Example include speech, audio and video

Lossless and Lossy compression

 Compression algorithms can be classified as either lossless or lossy

 In the case of lossless compression algorithm, the source information


to be transmitted is reduced/compressed, when the compression
information is decompressed, there is no loss of information

 Lossless compression is said to be reversible


 Example – Transfer of a text file over a network

 In lossy compression algorithms, the exact copy of the source


information is not reproduced after decompression

 Example – Transfer of digitized images and audio and video streams

Entropy encoding

 In some applications, the algorithms are used separately while in


others they are used together

Run length encoding

 Used in applications where the source information comprises long


substrings of the same character or binary digit

 It not only indicates the particular character or bit being transmitted


but also indicates the number of characters/bits in the substring
 For example if the output of the scanner was :

000000011111111110000011……

 This could be represented as

0,7 1,10 0,5 1,2 ……

 Alternately, since only the two binary digits 0 and 1 are involved

 If we ensure the first substring always comprises binary 0’s, then the
string could be represented as 7, 10, 5, 2 …..

Statistical encoding

 Set of code words to transmit source information – ASCII code

 Example – In a string of text, the character A may occur more


frequently, say than the character P which occurs more frequently
like character Z
 An example of an encoding scheme that generates code words that
have this property is the Huffman encoding algorithm

 Minimum average number of bits that are required to transmit a


particular source stream is known as the Entropy of the source and
can be computed as

 Average number of bits/code word can be computed as


Source encoding

Differential encoding

 Differential encoding is used extensively in applications where the


amplitude of a value or signal covers a large range but the difference
in amplitude between successive values/signals is relatively small

 Instead of using a set of relatively large code words to represent the


amplitude of each value/signal, a set of smaller code words can be
used

 For example, if the digitization of an analog signal requires 12 bits to


obtain the required dynamic range but the maximum difference in
amplitude between successive samples of the signal requires only 3
bits (saving of 75% on transmission bandwidth)
Transform Coding

 Transform encoding involves transforming the source information


from one form into another
 Image – represented by pixels in the matrix form

 The magnitude of the pixel value varies as we go from one position


to the next in a matrix

 The rate of change in magnitude as one traverses the matrix gives


rise to a term known as spatial frequency

 The matrix is scanned in either the horizontal or vertical direction


and gives rise to terms horizontal and vertical frequency
components of the image

 Human eye is less sensitive to the higher spatial frequency


components associated with an image than the lower frequency
components
 Moreover, if the amplitude of the higher frequency components fall
below a certain amplitude threshold, they will not be detected by the
eye

 Hence during compression, the higher frequency components which


cannot be detected by the eye can be removed without degrading the
quality of the image

 The transformation of a two dimensional matrix of pixel values into


an equivalent matrix of spatial frequency components can be carried
out using a mathematical technique known as the discrete cosine
transform (DCT)
Text compression

Huffman coding

 For example string AAAABBCD


Arithmetic coding

 The code words produced using arithmetic coding achieve the


Shannon value

 More complicated than Huffman coding

 For example string went.


LZW Compression

 Used to build the contents of the dictionary dynamically as the text is


being transferred

 Example – This is simple as it is…


LZW Examples
Image compression

 Images – computer generated images (graphical image) and digitized


images (of both documents and pictures)

 Some formats are extensively used with the internet for the
representation and compression of graphical images – Graphics
Interchange Format (GIF)

 Tagged Image file format (TIFF)

 Digitized documents

 Digitized pictures
Image Compression – GIF interlaced mode

1/8 and 1/8 of


the total
compressed
image

• GIF also allows an image to be stored and subsequently transferred


over the network in an interlaced mode; useful over either low bit
rate channels or the Internet which provides a variable transmission
rate
Image Compression – GIF interlaced mode

Further ¼ and
remaining ½ of the
image

• The compression image data is organized so that the decompressed


image is built up in a progressive way as the data arrives
Digitized Documents

• Since FAX machines are used with public carrier networks, the
ITU-T has produced standards relating to them

• These are T2(Group1), T3 (Group2), T4 (Group3) (PSTN), and T6


(Group 4) (ISDN)

• Both use data compression ratio in the range of 10:1

• The resulting code words are grouped into termination-codes


table (white or black run-lengths from 0 to 63 pels in steps of 1) and
the make-up codes table (contains in multiples of 64 pels)

• Since this codeword uses two sets of codeword it is known as the


modified Huffman codes
Image Compression – GIF interlaced mode

ITU –T Group 3 and 4 facsimile


conversion codes: termination-codes

Termination code table


Image Compression – GIF interlaced mode

• ITU –T Group 3 and 4 facsimile


conversion codes: make-up codes

Make-up of 64 code words


• Each scanned line is terminated with an EOL code. In this way the
receiver fails to decode a word it starts to search for an EOL pattern

• If it fails to decode an EOL after a preset number of lines it aborts


the reception process and informs the sending machine

• A single EOL precedes the end of each scanned line and six
consecutive EOLs indicate the end of each page

• The T4 coding is known as one-dimensional coding


MMR coding (2 dimensional coding)

• The modified-modified relative element address designate coding


explores the fact that most scanned lines differ from the previous
line by only a few pels

• E.g. if a line contains a black-run then the next line will normally
contain the same run pels plus or minus 3 pels

• In MMR the run-lengths associated with a line are identified by


comparing the line contents, known as the coding line (CL), relative
to the immediately preceding line known as the reference line (RL)

• The run lengths associated with a coding line are classified into
three groups relative to the reference line
Image Compression – run-length possibilities: pass mode (a), vertical mode

Pass mode

• This is the case when the run-length in the reference line(b1b2) is to


the left of the next run-length in the coding line (a1a2), that is b2 is to
the left of a1

Vertical mode

• This is the case when the 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
Image Compression – run-length possibilities: Horizontal mode

• This is the case when the run-length in the reference line (b1b2)
overlaps the run-length (a1a2) by more than plus or minus 3 pels
Image Compression – JPEG encoder schematic

• The Joint Photographic Experts Group forms the basis of most


video compression algorithms
Image Compression – Image/block preparation

• Source image is made up of one or more 2-D matrices of values

• 2-D matrix is required to store the required set of 8-bit grey-level values
that represent the image

• For the colour image if a CLUT is used then a single matrix of values is
required

• If the image is represented in R, G, B format then three matrices are


required

• If the Y, Cr, Cb format is used then the matrix size for the chrominance
components is smaller than the Y matrix ( Reduced representation)
• Once the image format is selected then the values in each matrix are
compressed separately using the DCT

• In order to make the transformation more efficient a second step known


as block preparation is carried out before DCT

• In block preparation each global matrix is divided into a set of smaller


8X8 sub matrices (block) which are fed sequentially to the DCT
Image Compression – Image Preparation

• Once the source image format has been selected and prepared (four
alternative forms of representation), the set values in each matrix are
compressed separately using the DCT)
Image Compression – Example computation of a set of quantized
DCT coefficients
Image Compression – JPEG encoder
Image Compression – Image Preparation

• The values are first centred around zero by subtracting 128 from
each intensity/luminance value
Image Compression – Image Preparation

• Block preparation is necessary since computing the transformed


value for each position in a matrix requires the values in all the
locations to be processed
Image Compression – Vectoring using Zig-Zag scan

• In order to exploit the presence of the large number of zeros in the


quantized matrix, a zig-zag of the matrix is used
Image Compression – JPEG decoder

• A JPEG decoder is made up of a number of stages which are


simply the corresponding decoder sections of those used in the
encoder

You might also like