Pmmc Ch3 Completed (06.03.11)

Embed Size (px)

Citation preview

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    1/46

    3.TEXT AND IMAGE COMPRESSION

    INTRODUCTION.

    COMPRESSION PRINCIPLES.

    TEXT COMPRESSION.

    IMAGE COMPRESSION.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    2/46

    INTRODUCTION

    In almost all multimedia application a technique known as

    compression is first applied prior to its transmission.

    Why Do We Need Compression?

    Requirements may outstrip the anticipatedincrease of storage space and bandwidthFor data storage and data transmission

    - DVD- Video conference- Printer

    The bit rate of uncompressed digital cinema

    data exceeds 1 Gbps

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    3/46

    COMPRESSION PRINCIPLES

    Compression is done either to reduce the VOLUME of

    information to be transmitted ( text, fax or images) or to reduce

    the BAND-WIDTH that is required for its transmission.

    Different compression principles are:

    Source encoders and Destination decoders.

    Lossless and Lossy compression.

    Entropy encoding.

    Source encoding.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    4/46

    1. Source encoders and Destination decoders.

    Compression algorithm and Decompression algorithm.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    5/46

    Source encoders and Destination decoders contd

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    6/46

    2. Lossless and Lossy compression.

    Lossless compression algorithm is used to reduce

    the amount of source information to be transmitted and to

    decompress the information without any losses. It is also

    called as REVERSIBLE.

    Lossy compression algorithm does not reproduce an

    exact copy of the source information but rather a version ofit which is perceived by the recipient as a true copy.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    7/46

    3. Entropy encoding.

    It is a lossless and independent type of compression it is

    concerned with how the information is represented. It includes

    two widespread algorithm, they are:

    1. Run-length encoding : Source information comprises long

    sub-strings of same character or binary digit.

    2. statistical encoding : It exploits the property of using a

    variable length code words. In this encoding the destination must

    aware of code words set. A code word set that avoids the wrongcode word is said to posses the PREFIX PROPERTY.

    HAFFUMAN CODING is the better example of having a

    prefix property.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    8/46

    Minimum average number of bits that are required to transmit a sourcestream is known as ENTROPY and can be coded by using

    SHANNON ENTROPY formula.

    entropy (H)= Pi log 2 (Pi)N number of different symbols

    Piprobability of occurrence of symbol I.

    Efficiency is the ratio ofentropy of source to the average

    number of bits per codeword

    Average number of bits per codeword is = Ni Pi

    Problem (1) pg no. 142

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    9/46

    4. Source encoding.

    It uses an alternative form of representation of a compressed version

    of original information. This can be used in two ways, they are:

    1. Differential encoding.

    2. Transform encoding.

    DIFFERENTIAL ENCODING: in this type of encoding, instead of

    using a set of relatively large code words, a set of small code words

    is used which indicates only the difference in amplitude between the

    current value and the next Immediately preceding value.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    10/46

    TRANSFORM ENCODING: involves transforming the source fromone form into another

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    11/46

    Rate of change in magnitude as one transverses the matrix

    gives rise to a term known as SPATIAL FREQUENCY.

    DISCRETE COSINE TRANSFORM (DCT) is used as

    mathematical analysis for transferring of 2-D matrix.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    12/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    13/46

    TEXT COMPRESSION:-

    All the three types of text are represented as string of characters

    selected from a defined set.

    any compression algorithm associated with text must be lossless

    .

    text compression uses statistical encoding.

    For the text compression this statistical encoding can be used in

    mainly in three types, they are HUFFMAN CODING

    ARITHMETIC CODING

    LEMPEL-ZIV (LZ) CODING

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    14/46

    HUFFMAN CODING

    Huffman coding is a type of text compression which can be

    clearly analyzed by static Huffman coding and Dynamic

    Huffman coding.

    STATIC HUFFMAN CODING: character string is first

    analyzed and their relative frequency is determined. Coding

    involves creating an unbalanced tree with some branches shorter

    than others.

    DYNAMIC HUFFMAN CODING:

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    15/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    16/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    17/46

    ARITHMETIC CODING

    Huffman coding achieves shannon value only if the

    character or the symbol are all integers of (1/2). And set

    codeword obtained are optimum

    ARITHMETIC CODING results a set of codewords

    sent as a block of data known as binary arithmetic coding.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    18/46

    LEMPEL-ZIV CODING

    Instead of using a single character we are using a strings

    of characters. The occurrence of the character in the text to be

    transmitted is held by both the encoder and decoder in a table.

    This table is used as dictionary and the LZ algorithm is known as

    Dictionary based compression algorithm.

    LEMPEL-ZIV- WELSH CODING

    This algorithm is used to build the contents of thedictionary dynamically as the text being transferred . Initially

    the encoder and decoder uses the character that has been used

    to create the text. The remaining entries are then built up

    dynamically by both ( the encoders and decoders ).

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    19/46

    IMAGE COMPRESSION:-

    Images are of two types, they are:

    1. Computer generated (Graphical) images are represented via a

    form of program written in a particular graphics programming

    languages.

    2. Digitized images (both document & picture) 2-D matrix

    representation is used.

    There are several formats used to compress the image and

    are sent via a network to the destination. Mainly run length and

    statistical coding, transform and differential coding is used.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    20/46

    It is used extensively with the INTERNET for the

    representation and compression of the graphical images. The color

    images uses 24 pels of 8-bits each for R,G and B by selecting 256

    colors from the original set.

    Instead of sending each pels as a 24-bit value only 8-bit

    index to the table entry is sent.

    This table of colors relate either to the whole image {global

    color table} or to a portion of the image (local color table}.

    LZW coding algorithm is used.

    Graphics Interchange Format :-

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    21/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    22/46

    Dynamic mode using LZWcoding

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    23/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    24/46

    DIGITIZED DOCUMENT :-

    Scanned lines consist only of long strings of white picture

    element while other comprise a mix of long strings of

    white pels and long string of black pels. Facsimile machie

    is the best example of this format.

    ITU-T has produced standards they are:

    1. T2(group1)

    2. T3(group2)

    3. T4(group3)

    4. T6(group4).

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    25/46

    DIGITIZED DOCUMENT contd.. :-

    Codeword are fixed and grouped in to 2 separate tables, they are

    1. The termination code table: are for white and black run-length

    of from 0 to 63 pels

    2. Make-up codes table : code words for white or black run length

    that are multiples of 64 pels

    Run-length coding are associated with a coding line as one of the three

    possibilities or modes they are

    1. Pass mode.

    2. vertical mode.

    3. horizontal mode.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    26/46

    DIGITIZED PICTURE :-

    The most widely adopted standard relating to the compression

    of digitized picture has been introduced by an international

    standard body known as Joint Photographic Experts Group

    (JPEG).

    It is a standard that was developed by a team of experts working

    on behalf of ISO, The ITU, & the TEC. JPEG is defined in theinternational standards IS10918.

    JPEG defines a number of format (modes), we will study only the

    lossy sequential mode used in this case. This mode is also known

    as BASELINE MODE.

    JPEG :-

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    27/46

    Flow chart.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    28/46

    JPEG contd.. :-

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    29/46

    JPEG contd.. :-

    There are 5 different stages associated with this mode,

    they are

    1. Image / block representation.

    2. Forward DCT.

    3. Quantization.

    4. Entropy encoding .5. Frame building

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    30/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    31/46

    Block preparation

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    32/46

    2. Forward DCT

    P[x,y] is the input 2-D matrix. F[i,j] is the transformed matrix.

    C(i) and c(j) = For I,j=0

    = 1 for all other value of I & j.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    33/46

    2. Forward DCT contd..

    The following steps are remembered during the DCT:

    1. All 64 values in the input p[x,y] contributes to each entry in

    the transformed matrix f[i,j].

    2. For i=j=0, two cosine terms are 0. the value in the location

    f[0,0] of the transformed matrix is a summation of all the

    values in the input. It is the mean of all the values in the

    matrix and is known as DC-COEFFICIENTS.

    3. All the other values has the coefficients either in horizontal

    (x=1-7 for y=0), vertical (x=0 for y=1-7)or both (x=1-7 for

    y=1-7) they are known as AC-COEFFICIENTS

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    34/46

    2. Forward DCT contd..

    4. If j=0, only horizontal frequency components are presented

    for i=1-7. If i=0, only vertical frequency components are

    presented for j=1-7.

    5. In other loaction both horizontal and vertical frequencycomponents are present to varying degree.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    35/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    36/46

    Example: assuming a quantization threshold value of 16, derive

    the resulting quantization error for each of the following DCT

    co-efficient of 127,72,64,56,-56,-64,-72,-128.

    Co-efficient

    Quantizedvalue

    Roundedvalue

    Dequantizedvalue

    Error

    127 127/16=7.937

    8 128 -1

    72 4.5 5 80 -8

    64 4 4 64 0

    56 3.5 4 64 8

    -56 -3.5 -4 -64 -8

    -64 -4 -4 -64 0

    -72 -4.5 -5 -80 -8

    -128 -8 -8 -128 0

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    37/46

    4. Entropy Encoding

    This stage comprises 4 steps, they are:

    1. Vectoring

    2. Differential encoding

    3. Run-length encoding

    4. Huffman encoding

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    38/46

    5. Frame Building

    Frame building is to encapsulate all the information relating toan encoded image / picture. It consists of the parameters like, at

    the top level the complete frame plus header is encapsulated

    between a start of frame and a end of frame.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    39/46

    5. Frame Building contd..

    Frame header contains:

    1. Overall width and height of the image in pixels.

    2. Number & type of component that are used to represent the

    image (CLUT, R/G/B, Y/Cb/Cr).

    3. Digitization format used (4:2:2, 4:2:0).

    At second level the frame consist of :

    1. Identity if the components used.

    2. Number of bits used to digitize each component.

    3. Quantization table of values that have been used to encode

    each component.

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    40/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    41/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    42/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    43/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    44/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    45/46

  • 7/31/2019 Pmmc Ch3 Completed (06.03.11)

    46/46