Sei sulla pagina 1di 4

TP4113 Kompresi Data

4-Metode Aritmetika Kompresi Data

Review

METODE ARITMETIKA

LATIHAN: Serangkaian karakter A = { a1 , a2 , a3 } memiliki probabilitas P(a1)=0,95 P(a2)=0,02 P(a3)=0,03 Dapatkah diperoleh hasil kompresi yang maksimal?

KOMPRESI DATA
TP4113

Restyandito, S.Kom, MSIS Restyandito,


Metode Aritmetika Kompresi Data Restyandito - 2

Arithmetic Coding
Huffman codes have to be an integral number of bits long, while the entropy value of a symbol is almost always a faction number, theoretical possible compressed message cannot be achieved.
For example, if a statistical method assign 90% probability to a given character, the optimal code size would be 0.15 bits.
Metode Aritmetika Kompresi Data Restyandito - 3

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. floatingArithmetic coding is especially useful when dealing with sources with small alphabets, such as binary sources, and alphabets with highly skewed probabilities.
Metode Aritmetika Kompresi Data Restyandito - 4

Arithmetic Coding
Karakter
^(spasi) A B E G I L S T

Arithmetic Coding
0.0 0.1 0.2 ^ A 0.2 0.3 B E 0.4 0.5 G I 0.6 L 0.8 S 0.9 T 1.0
0.258

Probabilitas
1/10 1/10 1/10 1/10 1/10 1/10 2/10 1/10 1/10

Range
0,00 < r < 0,10 0,11 < r < 0,20 0,21 < r < 0,30 0,31 < r < 0,40 0,41 < r < 0,50 0,51 < r < 0,60 0,61 < r < 0,80 0,81 < r < 0,90 0,91 < r < 1,00

0.25

0.256
0.25724

0.2572

0.25 I 0.26

0.256

0.2572

L
0.2576

Jika kita akan mengkodekan kan BILL GATES


Metode Aritmetika Kompresi Data Restyandito - 5

0.3

0.26

0.258

0.2576
Restyandito - 6

Metode Aritmetika Kompresi Data

Restyandito, S.Kom,MSIS

TP4113 Kompresi Data

4-Metode Aritmetika Kompresi Data

Arithmetic Coding
Karakter
B I L L ^(spasi) G A T E S
Metode Aritmetika Kompresi Data

Arithmetic Coding
Hasil akhir, penamaan tag, 0,2572167752 merupakan kode unik yang berisi informasi BILL GATES GATES Berapapun nilai antara 0,2572167752 hingga 0,2572167756 dapat dijadikan tag untuk meng-enkodekan pesan, dan dapat mengdi de-kodekan secara unik de-

Batas Bawah
0.2 0.25 0.256 0.2572 0.25720 0.257216 0.2572164 0.25721676 0.257216772 0.2572167752

Batas Atas
0.3 0.26 0.258 0.2576 0.25724 0.257220 0.2572168 0.2572168 0.257216776 0.2572167756
Restyandito - 7

Metode Aritmetika Kompresi Data

Restyandito - 8

Arithmetic Coding
0.00

Arithmetic Coding
0.00 0.656
0.7712 0.7712

Simbol 1 2 3

Probabilitas 0,80 0,02 0,18

Range [0,00-0,80] [0,80-0,82] [0,82-1,00]


0.80 2 0.82 3 1.00
Restyandito - 9

0.7712

0.773504

2 0.656 3 0.80 0.80


0.77408 0.773504
Restyandito - 10

Jika kita akan meng-encode the message 1321


Metode Aritmetika Kompresi Data

0.77408

Metode Aritmetika Kompresi Data

Arithmetic Coding
Hasil Encoding:
Karakter 1 3 2 1 Batas Bawah 0.0 0.0 0.656 0.7712 0.7712 Batas Atas 1.0 0.8 0.800 0.77408 0.773504
0.0 0.1

Arithmetic Decoding
^ A 0.2 B 0.3 E G 0.5 I 0.6
0.4 0.2

^ A B E G I

0.25

0.256

^ A B E G I

^ A B E G

0.25720 0.25724

^ A B E G I L S

0.25 0.26

0.256

0.2572 0.2576

I L S

L
0.8 0.9

L S
0.3 T

Tx (1312) =

0.7712 + 0.773504 = 0.772352 2


Restyandito - 11

0.258

L S T

T 1.0

0.258 T

0.2576 T
Restyandito - 12

Metode Aritmetika Kompresi Data

Metode Aritmetika Kompresi Data

0,2572167752

Restyandito, S.Kom,MSIS

TP4113 Kompresi Data

4-Metode Aritmetika Kompresi Data

Algoritma Encoding
LATIHAN: Kodekanlah UKDW! Menggunakan arithmetic coding, jika diketahui probabilitas untuk masingmasingmasing karakter sbb: k = 0,3 ; d = 0,3 ; w = 0,2 ; u = 0,1 ; ! = 0,1 Low = 0.0 ; high =1.0 ; while not EOF do range = high - low ; read(c) ; high = low + rangehigh_range(c) ; range low = low + rangelow_range(c) ; range enddo output(low);

Metode Aritmetika Kompresi Data

Restyandito - 13

Metode Aritmetika Kompresi Data

Restyandito - 14

Algoritma Decoding
r = input_code 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 r equal 0

Kode Biner Pada Arithmetic Coding


Problem:
Representasi biner untuk beberapa nilai (tags) pecahan sangat panjang Semakin panjang sequence, semakin tinggi tingkat presisi yang dibutuhkan

Solusi:
Synchronized rescaling and incremental encoding. encoding.
Metode Aritmetika Kompresi Data Restyandito - 16

Metode Aritmetika Kompresi Data

Restyandito - 15

Kode Biner Pada Arithmetic Coding


If the upper bound and the lower bound of the interval are both less than 0.5, then 0.5, rescaling the interval and transmitting a 0 bit. If the upper bound and the lower bound of the interval are both greater than 0.5, then 0.5, rescaling the interval and transmitting a 1 bit. Mapping rules: E1 : [0,0.5) [0,1); E1 ( x) = 2 x E2 : [0.5,1) [0,1);
Metode Aritmetika Kompresi Data

Kode Biner Pada Arithmetic Coding


0.00 0.00 0.312
0.3568 0.0848 0.1696

0.3568 0.3568

0.312

0.6784 0.3392

0.09632 0.19264 0.38528 0.77056 0.5424 0.38528 0.504256 0.54112

E2 ( x) = 2( x 0.5)
Restyandito - 17

0.80 2 2 0.656 0.6 0.54812 0.82 3 3 1.00 0.80 0.6


Metode Aritmetika Kompresi Data

0.54112 0.504256
Restyandito - 18

Restyandito, S.Kom,MSIS

TP4113 Kompresi Data

4-Metode Aritmetika Kompresi Data

karakter 1 3 rescale 2 rescale rescale rescale rescale rescale 1 EOF

bts.bawah 0 0 0,656 0,312 0,5424 0,0848 0,1696 0,3392 0,6784 0,3568 0,3568

bts.atas 1 0,8 0,8 0,6 0,54812 0,09632 0,19264 0,38528 0,77056 0,54112 0,50426

kode
Proses decoding pada bit stream dimulai dengan 1100011 1100011 jumlah bits yg diperlukan untuk membuat simbol unik bits. log 2 0.02 = 6 bits.
binary 110001 decimal 0,765625 0,9525 100011 0,546875 0,815 000110 001100 011000 110000 100000 0,5 0,777 0~0.8 0.8~0.82 range asli 0~0.8 0.82~1

1 1 0 0 0 1 1
Restyandito - 19

c 1 3 2

range baru (0.76525-0)/0.8=0.9525 0.656~0.8 0.312~0.6 0.5424~0.54816 0.0848~0.09632 0.1696~0.19264 0.3392~0.38528 0.6784~0.77056 rescale (0.546875-0.312)/(0.6-0.312)=0.815 rescale rescale rescale rescale rescale

Sembarang nilai biner diantara batas bawah dan atas.

0.3568~0.54112 (0.5-0.3568)/(0.54112-0.3568)=0.777

1
Restyandito - 20

Metode Aritmetika Kompresi Data

Metode Aritmetika Kompresi Data

BUKU ACUAN
Hallsal, F, 2001, Multimedia Communications Addison-Wesley (p. 134-136) Addison134-

Applications, Networks, Protocols and Standards, Standards,

Sayood, K, 2006, Introduction to Data Compression, Compression, Morgan Kaufmann Pub. (p. 81-113) 81Salomon, D, 2000, Data Compression, The Complete Reference, 2nd edition, Springer (p. 101-15) edition, 101-

TERIMAKASIH

Metode Aritmetika Kompresi Data

Restyandito - 21

Restyandito, S.Kom,MSIS

Potrebbero piacerti anche