Professional Documents
Culture Documents
C LLEGPT IT603N
4 Arithmetic Coding
Data
Data
Compression
Compression
Prepared and Edited by:- Divya Kaurani Designed by:- Kussh Prajapati
www.collegpt.com collegpt@gmail.com
Unit - 4 : Arithmetic Coding
Arithmetic Coding :
Arithmetic Coding bypasses the idea of replacing an input symbol with a specific code.
It replaces a stream of input symbols with a single floating point output number.
Algorithm
For Encoding:
low = 0.0 ; high = 1.0 ;
while not EOF do
range = high - low ;
read(c) ;
high = low + range * high_range(c) ;
low = low + range * low_range(c) ;
end do
output(low);
Where,
‘low’ and ‘high’ represent the current interval being encoded.
‘low_range(c)’ and ‘high_range(c)’ represent the range of probabilities assigned to
symbol c.
‘range’ represents the width of the current interval.
When encoding each symbol ‘c’, the interval [low, high] is adjusted based on the
probability range of c.
After encoding all symbols, the final ‘low’ value is outputted, representing the encoded
fraction.
For Decoding:
r = input_number
Repeat
Search c such that r falls in its range
output(c);
r = r - low_range(c);
r = r / (high_range(c) - low_range(c));
Until EOF or the length of the message is reached.
Where,
r represents the value being decoded.
In each step, the algorithm finds the symbol c whose range includes r.
Symbol c is outputted.
r is adjusted based on the interval corresponding to c.
r is rescaled to fit within the new interval.
This process repeats until the end of the encoded message or the desired message
length is reached.
Visit: www.collegpt.com
www.collegpt.com collegpt@gmail.com