HO05 MetodeDictionary
HO05 MetodeDictionary
Dictionary-Based Compression
METODE DICTIONARY Algoritma ini menggunakan suatu tabel referensi
untuk menyimpan simbol yang akan dikodekan.
KOMPRESI DATA Contoh: menggunakan Random House
TP4113 Dictionary of the English Language, 2nd Ed,
Unabridged.
‘Contoh yg baik suatu dictionary based compression….’
no no item dalam
halaman suatu halaman
Restyandito,
Restyandito, S.Kom, MSIS
Metode Dictionary Kompresi Data Restyandito - 2
Metode Dictionary Kompresi Data Restyandito - 3 Metode Dictionary Kompresi Data Restyandito - 4
Metode Dictionary Kompresi Data Restyandito - 5 Metode Dictionary Kompresi Data Restyandito - 6
Restyandito, S.Kom,MSIS
1
TP4113 – Kompresi Data 5-Metode Dictionary Kompresi Data
Metode Dictionary Kompresi Data Restyandito - 7 Metode Dictionary Kompresi Data Restyandito - 8
SOH
0
Sebagai inisialisasi, dictionary berisi set karakter teknik kompresi LZW itu gampang : :
teknik 128
berdasarkan kata-
kata-kata yang ada dalam teks.
itu 131
gampang 132
255
Metode Dictionary Kompresi Data Restyandito - 9 Metode Dictionary Kompresi Data Restyandito - 10
LZ77 LZ77
“ A Universal Algorithm for Sequential Data A; for(i=0; i <MAX-1; i ++)\ r for(j =i +1 ; j <MAX ; j++
Compression,” diterbitkan dalam IEEE
Compression,” ^ ^ ^ ^ ^ ^ ^
Metode Dictionary Kompresi Data Restyandito - 11 Metode Dictionary Kompresi Data Restyandito - 12
Restyandito, S.Kom,MSIS
2
TP4113 – Kompresi Data 5-Metode Dictionary Kompresi Data
LZ77 LZ77
A; for(i=0; i <MAX-1; i ++)\ r for(j =i +1 ; j <MAX ; j++ A; for(i=0; i <MAX-1; i ++)\ r for(j =i +1 ; j <MAX ; j++
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
Token :
r(i=0; i<M AX-1; i++)\r for(j=i+1; j<M AX ; j++)\r a[i]
^ ^ ^ ^ ^ ^ ^
LZ77 LZ77
Untuk men-
men-decode hasil kompresi cukup Men-
Men-decode token ( 14, 4,”
4,”^”)
sederhana: Text window
1. reads in a token
2. outputs the indicated phrase A; f or (i=0 ; i <MAX -1 ; i++) \r for (j=i +1 ; j
^ ^ ^ ^ ^
<MAX
^
3. shifts 14
4. repeats
Men-
Men-decode token ( 33, 3,”
3,”+”)
; j+
r(i= 0 ; i< M A X -1 ; i+ + )\r fo r(j= i+ 1 ; j< M A X ^
^ ^ ^ ^
33
Metode Dictionary Kompresi Data Restyandito - 15 Metode Dictionary Kompresi Data Restyandito - 16
LZ77 LZ77
(Data Compression: The Complete Reference – David Salomon)
Salomon) Contoh: CODING
Token : kuku-
kuku-kuku kaki kakak kakekku kaku-
kaku-kaku kok.
an offset to a phrase in the text window (dari kanan kuku–kuku^kaki^kakak^kakekku^ka (11, 3,”e”)
ke kiri)
–kuku^kaki^kakak^kakekku^kaku–k (20, 1,”k”)
the length of the phrase; and
(19, 5,”u”)
the first symbol in the look-
look-ahead buffer that follows uku^kaki^kakak^kakekku^kaku–kak
the phrase. ki^kakak^kakekku^kaku–kaku^kok. ( 0, 0,”k”)
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
3
TP4113 – Kompresi Data 5-Metode Dictionary Kompresi Data
LZ77 LZ77
Contoh: DECODE Circular Queue
struktur data dasar
(11, 3,”e”) kuku–kuku^kaki^kakak^ Larik berisi karakter yg ditambahkan diakhir
(20, 1,”k”) –kuku^kaki^kakak^kake Jika larik penuh, karakter pertama dihapus
(19, 5,”u”) uku^kaki^kakak^kakekk Contoh: (CQ 16 bytes)
( 0, 0,”k”) ki^kakak^kakekku^kaku kuku–ku
kuku–kuku^kaki^k
Algoritma ini cocok untuk kasus-
kasus-kasus dimana
auku–kuku^kaki^k
suatu file dikompres sekali tetapi di-
di-dekompres
berkali-
berkali-kali kakakkuku^kaki^k
Metode Dictionary Kompresi Data Restyandito - 19 Metode Dictionary Kompresi Data Restyandito - 20
LZSS LZSS
Dikembangkan oleh Storer dan Szymanski Contoh binary tree
Memperbaiki LZ77 dalam hal: aku
menyimpan look-
look-ahead-
ahead-buffer dalam suatu circular gula
cincin
queue energi
indah
membuat token dnegan dua buah field saja kamar
harimau pakaian
mandi
pakaian
rahasia
Metode Dictionary Kompresi Data Restyandito - 21 Metode Dictionary Kompresi Data Restyandito - 22
LZSS LZSS
Contoh: search buffer (16B), look-
look-ahead-
ahead-buffer (5B) Contoh: search buffer (16B), look-
look-ahead-
ahead-buffer (5B)
aku^memakai^pakaian^di^kamar^mandi aku^memakai^pakaian^di^kamar^mandi
aku^m offset 16
ku^me 15 ian^d Pohon diupdate dengan menghapus 1 string
u^mem 14
^mema 13 aku^m offset 16
memak 12 (6, 1)
emakai
m aka i
11
10 dan menambah 1 string baru
a k a i ^ 9
k a i ^ p 8 pa k ai 5
a i ^pak 7
i ^p aka 6
^p a k a 5
Metode Dictionary Kompresi Data Restyandito - 23 Metode Dictionary Kompresi Data Restyandito - 24
Restyandito, S.Kom,MSIS
4
TP4113 – Kompresi Data 5-Metode Dictionary Kompresi Data
LZSS LZSS
Contoh: LZSS is better than LZ77
isi dari
text window
LZSS uses a single bit as a prefix to every output
token to indicate whether it is an offset/ length
"LZSS^"
pair or a single symbol for output.
"^is^b" "ZSS^i"
Matched phrase (0,position, length, character)
" ^bett" "is^be" "SS^is" Non-
Non-matched phrase (1,character)
"bette" "S^is^" "tter^" If the text window size is 4096 characters, look-
look-
"^than" "etter" "s^bet" "ter^t" ahead buffer size is 16 characters,
"^LZ77" "an^LZ" "er^th" "han^L" "r^tha" "than^" Matched token needs 1+12+4+8=25 bits
"n^LZ7"
Non-
Non-matched token needs 1+8=9 bits
Isi dari setiap
simpul adalah
pointer ke text
window
Metode Dictionary Kompresi Data Restyandito - 25 Metode Dictionary Kompresi Data Restyandito - 26
LZSS LZSS
Greedy vs. Optimal
Baik LZ77 maupun LZSS disebut algoritma first longest possible as greedy
〝 Go T〞
^
: 25
greedy” :Keduanya tidak menganalisa input
“greedy” 〝 o S〞 : 25
stream untuk mencari kombinasi terbaik dari
^
〝 tat〞 : 25
indeks dan karakter. : 75
Metode Dictionary Kompresi Data Restyandito - 27 Metode Dictionary Kompresi Data Restyandito - 28
LZSS DISKUSI
Apakah besar text-
text-windows dan look-
look-up-
up-
• In the world of data compression, a few good table ada pengaruhnya terhadap hasil
heuristics are often more respected than a
provably superior algorithm.
kompresi?
• The greedy heuristics in this case is definitely the
choice of most compression programmers. 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
5
TP4113 – Kompresi Data 5-Metode Dictionary Kompresi Data
LZ78 LZ78
Kelemahan algoritma LZ77 Token berisikan:
Keterbatasan text windows mengakibatkan banyak suatu code yg memilih suatu frasa yang
frasa yang terbuang.
diberikan
Ukuran frasa yang cocok terbatas sesuai dengan
look- sebuah karakter yg mengikuti frasa tersebut
look-ahead buffer yang digunakan.
LZ88 tidak menggunakan konsep text windows Langkah-
Langkah-langkah
LZ77: dictionary ditentukan oleh text windows dari Mulai dengan sebuah null string pada posisi nol
teks yang dibaca/dikodekan sebelumnya. Simbol yg dikodekan dimasukkan ke dalam tabel
LZ78: dictionary berupa daftar yg tak terbatas dari secara urut
frasa yang dilihat sebelumnya Jika tabel telah berisi, dicari simbol yang sama,
suatu code yg memilih suatu frasa yg diberikan jika ditemukan masukkan offset dan simbol.
Sebuah karakter yg mengikuti frasa tersebut
Metode Dictionary Kompresi Data Restyandito - 31 Metode Dictionary Kompresi Data Restyandito - 32
LZ78 LZ78
Contoh: sir_sid_eastman_easily_teases_sea_sick_seals Contoh: sir_sid_eastman_easily_teases_sea_sick_seals
Metode Dictionary Kompresi Data Restyandito - 33 Metode Dictionary Kompresi Data Restyandito - 34
LZ78 LZP
Latihan: kuku-
kuku-kuku kaki kakakku kaku-
kaku-kaku Charles Bloom: Prinsip prediksi konteks
S = String : simbol yg akan dikodekan
C = Context : string yg biasanya mengikuti S
N : panjang C
Metode Dictionary Kompresi Data Restyandito - 35 Metode Dictionary Kompresi Data Restyandito - 36
Restyandito, S.Kom,MSIS
6
TP4113 – Kompresi Data 5-Metode Dictionary Kompresi Data
LZP LZP
Algoritma
1. It saves P and replace it in the index table with a
fresh pointer Q pointing to S in the look-
look-ahead
buffer. 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 Restyandito - 38
LZY
BUKU ACUAN
Metode Dictionary Kompresi Data Restyandito - 39 Metode Dictionary Kompresi Data Restyandito - 40
TERIMAKASIH
Restyandito, S.Kom,MSIS
7