source code design

Upload: eliasgeorgiou

Post on 07-Aug-2018

238 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/21/2019 Source Code Design

    1/18

    E

    E Data Communications andNetworking

    ource o e es gn

    E Dr Salem Aljareh

  • 8/21/2019 Source Code Design

    2/18

    Source Code Design

    Decision Tree10

    0 11 0

    0 10 10 1 0 1

    x1 x8x3x2 x7x6x5x4

    111110101100011010001000

  • 8/21/2019 Source Code Design

    3/18

    Weather Info System

    Very Poor Poor Good Moderate

    10

    0 0 1Moderate

    0 110Poor

    110 111GoodVer Poor

  • 8/21/2019 Source Code Design

    4/18

    Shannon Fano Encoding

    1. List symbols in descending probability order

    . v e a e n o equa or near y equa va ues o pro a y

    .

    4. Divide both u er and lower section in two

    5. Allocate binary 0 to top half and binary 1 to bottom half

    6. Repeat (4) and (5) until cant go further

  • 8/21/2019 Source Code Design

    5/18

    Shannon Fano Code Example

    x1: P = 0.25 x2: P = 0.25

    x3: P = 0.15 x4: P = 0.1

    5 . 6 .

    x7: P = 0.06 x8: P = 0.01

  • 8/21/2019 Source Code Design

    6/18

    Shannon Fano Solution

    0.25 0

    0.25 0 1.

    0.1 1 0 1

    .

    0.08

    1

    1

    1

    1

    0

    1 0

    0.06

    0.01

    1

    1

    1

    1

    1

    1

    1

    1

    0

    1

  • 8/21/2019 Source Code Design

    7/18

    Shannon Fano Encoding (con.)

    X1 X2 X3 X4 X5 X6 X7 X8

    . . . . . . . .

    00 01 100 101 110 1110 11110 11111

    Calculate the following:-

    The code length

    The code Efficienc

  • 8/21/2019 Source Code Design

    8/18

    Shannon Fano Encoding (solution)e co e eng s g ven y:

    lxPLii

    i

    i )(81=

    =

    =

    3)10.010.015.0(

    ..

    +++

    5)01.006.0(408.0 ++

    sym og ts.=

  • 8/21/2019 Source Code Design

    9/18

    Shannon Fano Encoding (solution)

    The entropy H(X) is given by:

    i 18= =

    xPi i

    11

    )(1=

    1115.0

    .

    25.0

    . 22

    1lo01.011lo06.0

    08.0.

    10.0.

    +

    symbolbits /67.2

    01.006.0

    =

  • 8/21/2019 Source Code Design

    10/18

    Shannon Fano Encoding (solution)

    The efficiency of the code is :

    100)(=

    XH

    67.2

    72.2

    .

  • 8/21/2019 Source Code Design

    11/18

    Huffman Encoding (The Algorithm)

    List the symbols in descending order of probability.

    Combine the 2 smallest probabilities to make a newprobability.

    Repeat the process until all the symbols have been.

    .

  • 8/21/2019 Source Code Design

    12/18

    Huffman Encoding (Example)

    x1

    : P = 0.25 x2

    : P = 0.25

    x : P = 0.15 x : P = 0.1

    x5: = . x6: = .

    x7: P = 0.06 x8: P = 0.01

  • 8/21/2019 Source Code Design

    13/18

    x1 0.25

    0

    000

    02

    x3 0.15

    .

    0.55 1.00

    x4 0.10.45

    0

    1

    x5 0.1

    0.2

    0.301

    1

    1

    x6 0.08 0

    x7

    x8

    0.060.07

    0

    1

    1

    101111

  • 8/21/2019 Source Code Design

    14/18

    0 0

    Huffman Encoding (Solution)

    x2

    1 0

    x3

    x

    0 1 0

    x5

    1 1 1

    x6

    x

    0 1 1 0

    0 1 1 1 0

    x8

    0 1 1 1 1

  • 8/21/2019 Source Code Design

    15/18

    Huffman Encoding (evaluation)

    For the above Code,

    Calculate the following:-

    The code length

    The code Entropy

  • 8/21/2019 Source Code Design

    16/18

    Huffman Encoding (Evaluation -result)

    The code length = 2.72 digits/symbol

    The code Entropy = 2.67 bits/symbol

    The code Efficiency = 98.2%

    Compare to those for the Shannon Fano Coding

  • 8/21/2019 Source Code Design

    17/18

    Practical Example

    circuit.

    At encoded 2.72 bits/symbol this is equivalent to 882 symbols/sec

    Improvement = 82/800 = 10.25%

  • 8/21/2019 Source Code Design

    18/18

    Implementation of Huffman Code

    A4 page scanned from top left-hand corner to the right-hand bottom corner

    Each line is subdivided into 1728 icture elements els .

    Each pel quantized into either black ple or white pel.

    The total number of pels is approximately is just under 2 pels.

    If a binary 1 is used to represent a white pel and binary 0 represent a blackpel and

    If the signalling rate is 4800bps the time taken to transmit a page using theabove scheme is:

    6

    The scanned data contains considerable redundancy.

    the transmission speed can be reduced by a factor of about 10.

    the probability of occurrence of each run length.