Chapter 4 - Arithmetic Coding
Chapter 4 - Arithmetic Coding
ARITHMETIC
CODING
Lecture By,
Prof.M.Dhanalakshmi,
Asst.Prof., IT Dept,
SCET,Surat.
INTRODUCTION
Huffman approach generates variable length
codes.
Another popular method of generating
variable-length codes called arithmetic
coding.
When a string is converted to arithmetic
encoding, frequently used characters will be
stored with fewer bits and not-so-frequently
occurring characters will be stored with more
bits, resulting in fewer bits used in total.
DISADVANTAGES OF HUFFMAN CODE
Huffman coding methods generating codewords
for individual symbols.
Arithmetic coding differs Huffman coding,
Rather than separating the input into
component symbols and replacing each with a
code, arithmetic coding encodes the entire
message into a single number.
It represents the current information as a range,
defined by two numbers.
Storage of Huffman code for large applications
would be a highly inefficient and time-consuming
procedure.
Impractical to obtain Huffman codes for long
sequences of symbols.
DISADVANTAGES OF HUFFMAN CODE
In order to find the Huffman codeword for a
particular sequence of length m, we need
codewords for all possible sequences of length m.
This fact causes an exponential growth in the
size of the codebook.
We need a way of assigning codewords to
particular sequences without having to generate
codes for all sequences of that length.
The arithmetic coding technique fulfills this
requirement.
HUFFMAN AND ARITHEMTIC
Implemented results show that:
Compression ratio of arithmetic coding is
better than Huffman coding,
LOGIC OF ARITHMETIC CODE
In arithmetic coding a unique identifier or tag is
generated for the sequence to be encoded.
This tag corresponds to a binary fraction, which
becomes the binary code for the sequence.
Arithmetic coding approach is divided into two
phases:
1. Phase 1: Unique identifier or tag is generated
for a given sequence of symbols.
2. Phase 2: Tag is then given a unique binary
code.
A unique arithmetic code can be generated for a
sequence of length m without the need for
generating codewords for all sequences of length m.
This is contrast to the situation for Huffman
codes.
CODING A SEQUENCE
In order to distinguish a sequence of symbols
from another sequence of symbols we need to
tag it with a unique identifier.
Step 2:
R(a1) = LB + d(Probability of a1)
R(a2) = LB + d (Probability of a2)
Iteration 3:
Next alphabet to be encoded is a3.
ENCODING ALGORITHM:
E3 condition:
Second MSB of l(k) = 1 and second MSB of u(k)=0.
Scale3 -> No.of E3 Mappings.
ENCODING ALGORITHM:
EXAMPLE:
Encode the sequence 1 3 2 1 with parameters shown
in table below:
Decrement Scale3 to 0.
Send 0.
Send 1.
Increment Scale3 to 1.
ENCODING EXAMPLE
The next element in the sequence to be encoded
is 1. Therefore,
We decode 3
DECODING EXAMPLE
Update the limits:
Decode 2.
Updating the limits using this decoded symbol,
we get:
Exercise:
Continue decoding the get the final element 1.
Final decoded sequence would be 1 3 2 1