Anda di halaman 1dari 7

TP4113 Kompresi Data

5-Metode Dictionary Kompresi Data

Dictionary-Based Compression

METODE DICTIONARY

KOMPRESI DATA
TP4113

Algoritma ini menggunakan suatu tabel referensi untuk menyimpan simbol yang akan dikodekan. Contoh: menggunakan Random House Dictionary of the English Language, 2nd Ed, Unabridged.
Contoh yg baik suatu dictionary based compression. 1/1 822/3 674/4 1343/60 928/75 550/32 173/46 421/2
no halaman no item dalam suatu halaman
Restyandito - 2

Restyandito, S.Kom, MSIS Restyandito,

Metode Dictionary Kompresi Data

Dictionary Based Compression


Pengkodean static dictionary :
A={a,b,c,d,r} Untuk mengkodekan abracadabra. code
000 001 010 011 100 101 110 111 entry a b c d r ab ac ad

Dictionary-Based Compression
Beberapa teknik Dictionary-based compression Dictionaryyg saat ini banyak digunakan dalam kompresi data yang bersifat lossles yaitu:
Winzip Winarj

String output yg dihasilkan 101100110111101100000.


Metode Dictionary Kompresi Data

Restyandito - 3

Metode Dictionary Kompresi Data

Restyandito - 4

Lempel-Ziv Coding
Algoritma ini tidak mengkodekan sebuah simbol sebagai bit streams, ttp mengkodekan beberapa variabel sebagai sebuah token. Masing-masing token disimpan dalam sebuah Masingtabel yang dimiliki oleh encoder maupun

Lempel-Ziv Coding
Dlm kamus terdapat sekitar 31.500 kata, dan menurut formula information content Shannon, sebuah kata dapat dikodekan dengan 18 buah bits. Dengan menggunakan LZ compression, berapa digit diperlukan untuk mengkodekan seluruh kata dalam kamus? Berapa rasio kompresi jika akan dikodekan kata MULTIMEDIA ?

decoder

Metode Dictionary Kompresi Data

Restyandito - 5

Metode Dictionary Kompresi Data

Restyandito - 6

Restyandito, S.Kom,MSIS

TP4113 Kompresi Data

5-Metode Dictionary Kompresi Data

Lempel-Ziv Coding
LATIHAN Suatu file teks akan dikompres. Jika rata-rata ratajumlah karakter per kata adalah 6, dan dictionary yang digunakan berisi 4096 buah kata, berapakah rasio kompresi yang diperoleh jika digunakan algoritma LZ.

Static vs. Adaptive Dictionary


Pendekatan Static
Kamus dibuat sebelum pengkodean. Dibutuhkan pengetahuan yang memadai mengenai source

Pendekatan Adaptive
Kamus dibuat pada saat proses pengkodean.

Metode Dictionary Kompresi Data

Restyandito - 7

Metode Dictionary Kompresi Data

Restyandito - 8

Lempel-Ziv-Welsh Coding
Algoritma LZW mengkodekan suatu teks secara dinamis. Sebagai inisialisasi, dictionary berisi set karakter yang digunakan untuk membuat suatu teks (mis ASCII) Selanjutnya dictionary diisi secara dinamis berdasarkan kata-kata yang ada dalam teks. kata-

Lempel-Ziv-Welsh Coding
Contoh: (dictionary index = 8 bit)
teknik kompresi LZW itu gampang
NUL SOH : DEL teknik kompresi LZW itu gampang 0 1 : 127 128 129 130 131 132

: 255

Metode Dictionary Kompresi Data

Restyandito - 9

Metode Dictionary Kompresi Data

Restyandito - 10

LZ77
A Universal Algorithm for Sequential Data Compression, diterbitkan dalam IEEE Compression, Transactions on Information Theory , 1977

LZ77
A; for(i=0; i <MAX-1; i ++)\ r for(j =i +1 ; j <MAX ; j++ ^ ^ ^ ^ ^ ^ ^

Sliding Windows Compression Struktur data berupa text windows yang dibagi
menjadi 2 bagian, terdiri dari teks yang sudah dikodekan, dan bagian dari teks yang akan dikodekan (look ahead buffer)

Text window 40 chars

Look-ahead buffer 10 chars

Frasa dalam teks inputan diganti dengan sebuah pointer yang ada pada dicitionary Ukuran normal text window : Beberapa ribu chr Ukuran normal look-ahead buffer : 10 ~100 chr lookMetode Dictionary Kompresi Data Restyandito - 12

Metode Dictionary Kompresi Data

Restyandito - 11

Restyandito, S.Kom,MSIS

TP4113 Kompresi Data

5-Metode Dictionary Kompresi Data

LZ77
A; for(i=0; i <MAX-1; i ++)\ r for(j =i +1 ; j <MAX ; j++ ^ ^ ^ ^ ^ ^ ^

LZ77
A; for(i=0; i <MAX-1; i ++)\ r for(j =i +1 ; j <MAX ; j++ ^ ^ ^ ^ ^ ^ ^

Token :
an offset to a phrase in the text window the length of the phrase ; and the first symbol in the look-ahead buffer that follows lookthe phrase.

r(i=0; i<M AX-1; i++)\r for(j=i+1; j<M AX ^ ^ ^ ^ ^

; j++)\r a[i] ^ ^

Geser token ke dalam text windows (5 karakter) Masukkan 5 simbol baru ke dalam look-ahead look-

buffer

<MAX^ dikodekan sebagai ( 14, 4,^) <MAX^ 4,


(The Data Compression Book - Mark Nelson )
Metode Dictionary Kompresi Data Restyandito - 13

Token berikutnya adalah (33, 3, +) Jika dalam text windows tidak ada yang match, maka token = (0,0,karakter)
Metode Dictionary Kompresi Data Restyandito - 14

LZ77
Untuk men-decode hasil kompresi cukup mensederhana:
1. 2. 3. 4.

LZ77
Men-decode token ( 14, 4,^) Men4,
Text window
A; f or (i=0 ; i <MAX -1 ; i++) \r for (j=i +1 ; j ^ ^ ^ ^ ^ <MAX ^

reads in a token outputs the indicated phrase shifts repeats

14

Men-decode token ( 33, 3,+) Men3,


r(i= 0 ; i< M A X -1 ; i+ + )\r fo r(j= i+ 1 ; j< M A X ^ ^ ^ ^ ; j+ ^

33
Metode Dictionary Kompresi Data Restyandito - 15 Metode Dictionary Kompresi Data Restyandito - 16

LZ77
(Data Compression: The Complete Reference David Salomon) Salomon)

LZ77
Contoh: CODING kuku-kuku kaki kakak kakekku kaku-kaku kok. kukukakukukukuku^kaki^kakak^kakekku^ka kuku^kaki^kakak^kakekku^kakuk uku^kaki^kakak^kakekku^kakukak ki^kakak^kakekku^kakukaku^kok. (11, 3,e) (20, 1,k) (19, 5,u) ( 0, 0,k)

Token :
an offset to a phrase in the text window (dari kanan ke kiri) the length of the phrase; and the first symbol in the look-ahead buffer that follows lookthe phrase.

Latihan
Kodekan kalimat di atas menggunakan LZ77 (Salomon) dimulai dengan huruf pertama!
Metode Dictionary Kompresi Data Restyandito - 17 Metode Dictionary Kompresi Data Restyandito - 18

Restyandito, S.Kom,MSIS

TP4113 Kompresi Data

5-Metode Dictionary Kompresi Data

LZ77
Contoh: DECODE
(11, 3,e) (20, 1,k) (19, 5,u) ( 0, 0,k) kukukuku^kaki^kakak^ kuku^kaki^kakak^kake uku^kaki^kakak^kakekk ki^kakak^kakekku^kaku

LZ77
Circular Queue struktur data dasar Larik berisi karakter yg ditambahkan diakhir Jika larik penuh, karakter pertama dihapus Contoh: (CQ 16 bytes)
kukuku kukukuku^kaki^k aukukuku^kaki^k kakakkuku^kaki^k Metode Dictionary Kompresi Data Restyandito - 20

Algoritma ini cocok untuk kasus-kasus dimana kasussuatu file dikompres sekali tetapi di-dekompres diberkali-kali berkaliMetode Dictionary Kompresi Data Restyandito - 19

LZSS
Dikembangkan oleh Storer dan Szymanski Memperbaiki LZ77 dalam hal:
menyimpan look-ahead-buffer dalam suatu circular look- ahead-

LZSS
Contoh binary tree
aku cincin gula energi cincin kamar gula harimau aku energi indah mandi indah harimau pakaian kamar mandi pakaian rahasia

queue

menyimpan search buffer (dictionary) dalam binary

search tree

membuat token dnegan dua buah field saja

Metode Dictionary Kompresi Data

Restyandito - 21

Metode Dictionary Kompresi Data

Restyandito - 22

LZSS
Contoh: search buffer (16B), look-ahead-buffer (5B) look- aheadaku^memakai^pakaian^di^kamar^mandi

LZSS
Contoh: search buffer (16B), look-ahead-buffer (5B) look- aheadaku^memakai^pakaian^di^kamar^mandi ku^m emakai^pakaian^di^kamar^mandi

encoder membuat tree yang terdiri dari 5 karakter


aku^m ku^me u^mem ^mema memak emakai m aka i a k a i ^ k a i ^ p a i ^pak i ^p aka ^p a k a offset 16 15 14 13 12 11 10 9 8 7 6 5 ian^d (6, 1)

Pohon diupdate dengan menghapus 1 string


aku^m offset 16

dan menambah 1 string baru


pa k ai 5

Metode Dictionary Kompresi Data

Restyandito - 23

Metode Dictionary Kompresi Data

Restyandito - 24

Restyandito, S.Kom,MSIS

TP4113 Kompresi Data

5-Metode Dictionary Kompresi Data

LZSS
Contoh:
LZSS is better than LZ77
"LZSS" ^
"^is^b"

LZSS
isi dari text window

LZSS uses a single bit as a prefix to every output token to indicate whether it is an offset/ length pair or a single symbol for output.
Matched phrase (0,position, length, character) Non-matched phrase (1,character) Non-

"ZSSi" ^ "is^be" "SS is" ^ "S^is^" "etter" "han L" ^ "s^bet" "r^tha" "n^LZ7" "ter^t" "than " ^ "tter^"

" ^bett" "bette" "^than"

If the text window size is 4096 characters, looklookahead buffer size is 16 characters,
Matched token needs 1+12+4+8=25 bits Non-matched token needs 1+8=9 bits Non-

"^LZ77" "an^LZ" "er^th"

Isi dari setiap simpul adalah pointer ke text window Restyandito - 25

Metode Dictionary Kompresi Data

Metode Dictionary Kompresi Data

Restyandito - 26

LZSS
Greedy vs. Optimal Baik LZ77 maupun LZSS disebut algoritma greedy :Keduanya tidak menganalisa input greedy stream untuk mencari kombinasi terbaik dari indeks dan karakter.
Contoh: dictionary frasa yang dikodekan Go^T Go To Statement o^S tat ^Stat Aturan: 25 bits utk index/offset pair 9 bits utk sebuah character
Metode Dictionary Kompresi Data Restyandito - 27

LZSS
first longest possible as greedy
Go T ^ o S ^ tat 25 25 25 75

best match as optimized

Go T o Stat

25 9 0 25 68

Metode Dictionary Kompresi Data

Restyandito - 28

LZSS
In the world of data compression, a few good heuristics are often more respected than a provably superior algorithm. The greedy heuristics in this case is definitely the choice of most compression programmers.

DISKUSI
Apakah besar text-windows dan look-uptextlook- uptable ada pengaruhnya terhadap hasil kompresi? Contoh:
sir_sid_eastman_easily_teases_sea_sick_seals

Metode Dictionary Kompresi Data

Restyandito - 29

Metode Dictionary Kompresi Data

Restyandito - 30

Restyandito, S.Kom,MSIS

TP4113 Kompresi Data

5-Metode Dictionary Kompresi Data

LZ78
Kelemahan algoritma LZ77
Keterbatasan text windows mengakibatkan banyak frasa yang terbuang. Ukuran frasa yang cocok terbatas sesuai dengan look-ahead buffer yang digunakan. look-

LZ78
Token berisikan:
suatu code yg memilih suatu frasa yang diberikan sebuah karakter yg mengikuti frasa tersebut Langkah-langkah LangkahMulai dengan sebuah null string pada posisi nol Simbol yg dikodekan dimasukkan ke dalam tabel secara urut Jika tabel telah berisi, dicari simbol yang sama, jika ditemukan masukkan offset dan simbol.
Metode Dictionary Kompresi Data Restyandito - 32

LZ88 tidak menggunakan konsep text windows


LZ77: dictionary ditentukan oleh text windows dari teks yang dibaca/dikodekan sebelumnya. LZ78: dictionary berupa daftar yg tak terbatas dari frasa yang dilihat sebelumnya
suatu code yg memilih suatu frasa yg diberikan Sebuah karakter yg mengikuti frasa tersebut
Metode Dictionary Kompresi Data Restyandito - 31

LZ78
Contoh: sir_sid_eastman_easily_teases_sea_sick_seals

LZ78
Contoh: sir_sid_eastman_easily_teases_sea_sick_seals

Metode Dictionary Kompresi Data

Restyandito - 33

Metode Dictionary Kompresi Data

Restyandito - 34

LZ78
Latihan: kuku-kuku kaki kakakku kaku-kaku kukukakuS = String C = Context N

LZP
Charles Bloom: Prinsip prediksi konteks
: simbol yg akan dikodekan : string yg biasanya mengikuti S : panjang C

Metode Dictionary Kompresi Data

Restyandito - 35

Metode Dictionary Kompresi Data

Restyandito - 36

Restyandito, S.Kom,MSIS

TP4113 Kompresi Data

5-Metode Dictionary Kompresi Data

LZP
Algoritma
1. It saves P and replace it in the index table with a fresh pointer Q pointing to S in the look-ahead lookbuffer. L is set to zero. 2. If P is not a null pointer, it compares the string pointed by P to S, set L to the match length. 3. If L = 0, the buffer is slid to the right one position and the first symbol of string S is written to the compressed stream as a raw ASCII code 4. If L > 0, the buffer is slid to the rigth L positions and the value of L is written on the compressed streams.
Metode Dictionary Kompresi Data Restyandito - 37 Metode Dictionary Kompresi Data

LZP

Restyandito - 38

LZY

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

Applications, Networks, Protocols and Standards, Standards,

Salomon, D, 2000, Data Compression, The Complete Reference, 2nd edition, Springer (p. 165-245) edition, 165-

Metode Dictionary Kompresi Data

Restyandito - 39

Metode Dictionary Kompresi Data

Restyandito - 40

TERIMAKASIH

Restyandito, S.Kom,MSIS

Anda mungkin juga menyukai