Compression & Huffman Code

Slides:



Advertisements
Presentasi serupa
Kisi-kisi Jawaban UTS Semester Pendek Genap 2008/09.
Advertisements

Matematika Diskrit Suryadi MT Tree.
Kompresi Data Oleh Abdillah Irsyad El Nur Erieq Septian W
Algoritma dan Struktur Data
Algoritma dan Struktur Data
Kompresi Data.
Lecture 9 Single Linked List Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Modul-8 : Algoritma dan Struktur Data
CS3204 Pengolahan Citra - UAS
Pengantar Multimedia Pertemuan 4 Kompresi Data
Kompresi Citra KOMPRESI CITRA Nurfarida Ilmianah.
Pertemuan Struktur Data *Pohon Ekspresi *
2. Introduction to Algorithm and Programming
Algoritma Greedy (lanjutan)
Alg&Pemrog 2B Sistem Komputer Variable  Variable dapat didefinisikan sebagai bagian dari memory untuk menyimpan nilai yang telah ditentukan.  Setiap.
Chapter 1-a FLOW CHART.
Game Theory Purdianta, ST., MT..
Desain dan Analisis Algoritma
5. Pohon Merentang Minimum
BLACK BOX TESTING.
Pertemuan 23 Minimum Cost Spanning Tree
1 Pertemuan 09 Perangkat Keras dalam Komunikasi Data Matakuliah: H0174/Jaringan Komputer Tahun: 2006 Versi: 1/0.
Representasi data multimedia
KOMPRESI DAN TEKS.
Pertemuan 13 Graph + Tree jual [Valdo] Lunatik Chubby Stylus.
REPRESENTASI DATA MULTIMEDIA
Mata kuliah :K0362/ Matematika Diskrit Tahun :2008
9.3 Geometric Sequences and Series. Objective To find specified terms and the common ratio in a geometric sequence. To find the partial sum of a geometric.
Binary Search Tree. Sebuah node di Binary Search Tree memiliki path yang unik dari root menurut aturan ordering – Sebuah Node, mempunyai subtree kiri.
INFORMATION THEORY & BASIC TECHNIQUE
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- to-Relational Mapping.
Agung Toto Wibowo Universitas Telkom
Algoritma Greedy (lanjutan)
Jaringan Nirkabel Bab #5 – Enkoding Sinyal.
Jartel, Sukiswo Sukiswo
Kompresi Gambar Klasifikasi Kompresi Teknik Kompresi 1.
KOMUNIKASI DATA Materi Pertemuan 8.
Universitas Islam Indonesia
Konsep Pemrograman 3
KOMUNIKASI DATA Materi Pertemuan 9.
KOMUNIKASI DATA Materi Pertemuan 3.
Pengantar Multimedia Pertemuan 4 Kompresi Data
TEKNIK KOMPRESI LOSSLESS TEXT
Terminology The terminology between original image and image compression Compression Ratio Bit per pixel.
Meminimalkan Kebutuhan Memori dalam Merepresentasikan Citra Digital
Algoritma dan Struktur Data Lanjut
Greedy Pertemuan 7.
Branch and Bound Lecture 12 CS3024.
KOMPRESI DATA DAN TEKS Sindy Nova.
PENGANTAR KOMPUTER & TI 1A
Kode Hamming.
KOMUNIKASI DATA S. Indriani L, M.T
CPU ARITHMATIC.
Algoritma dan Struktur Data Lanjut
STRUKTUR DATA 2014 M. Bayu Wibisono.
Teknik Informatika - Universitas Muhammadiyah Malang (UMM)
CSG3F3/ Desain dan Analisis Algoritma
Pertemuan 09 Perangkat Keras dalam Komunikasi Data
Kompresi Teks File.
Pertemuan 18 Optimalisasi Kode dan Mewarnai Graph I
Algorithms and Programming Searching
Desain dan Analisis Algoritma
Chapter 5 Teknik Kompresi
Teknik Modulasi Pertemuan 07
Self-Organizing Network Model (SOM) Pertemuan 10
Pertemuan 2 Representasi Digital Sinyal Multimedia
KOMPRESI DATA : ALGORITMA HUFFMAN.
Simultaneous Linear Equations
Oleh : Rahmat Robi Waliyansyah, M.Kom.
Transcript presentasi:

Compression & Huffman Code

Teknik Kompresi Definisi Benefit Reduksi ukuran data (jumlah bit yang dibutuhkan untuk merepresentasikan data) Benefit Mengurangi storage yang dibutuhkan Mengurangi cost/latency/bandwidth transmisi

Sources of Compressibility Redundancy Recognize repeating patterns Exploit using: Dictionary Variable Length Encoding Human Percetion Less sensitive to some information Can discard less important data

Type of Compression Lossless Lossy Preserves all information Exploits redundancy in data Applied to general data Lossy May lose some information Exploits redundancy & human perception Applied to audio, image, video

Effectiveness of Compression Metrics Bits per byte (8 bits) 2 bits / byte  ¼ original size 8 bits / byte  no compression Percentage 75% compression  ¼ original size

Effectiveness of Compression Depends on data Random data  hard Example: 1001110100  ? Organized data  easy Example: 1111111111  110 Corollary No universally best compression algorithm

Effectiveness of Compression Lossless Compression is not always possible If compression is always possible (alternative view) Compress file (reduce size by 1 bit) Recompress output Repeat (until we can store data with 0 bits)

Lossless Compression Techniques LZW (Lempel-Ziv-Welch) compression Build pattern dictionary Replace patterns with index into dictionary Run length encoding Find & compress repetitive sequences Huffman codes Use variable length codes based on frequency

Huffman Code Approach Principle Variable length encoding of symbols Exploit statistical frequency of symbols Efficient when symbol probabilities vary widely Principle Use fewer bits to represent frequent symbols Use more bits to represent infrequent symbols

‘bad’ dikodekan sebagai ‘001000011’ Fixed-length code Karakter a b c d e f ---------------------------------------------------------------- Frekuensi 45% 13% 12% 16% 9% 5% Kode 000 001 010 011 100 111 ‘bad’ dikodekan sebagai ‘001000011’ Pengkodean 100.000 karakter membutuhkan 300.000 bit.

Variable-length code (Huffman code) Karakter a b c d e f ------------------------------------------------------------------------ Frekuensi 45% 13% 12% 16% 9% 5% Kode 0 101 100 111 1101 1100 ‘bad’ dikodekan sebagai ‘1010111 ’ Pengkodean 100.000 karakter membutuhkan (0,45  1 + 0,13  3 + 0,12  3 + 0,16  3 + 0,09  4 + 0,05  4)  100.000 = 224.000 bit Nisbah pemampatan: (300.000 – 224.000)/300.000  100% = 25,3%

Huffman Code Data Structures Binary (Huffman) tree Represents Huffman code Edge  code (0 or 1) Leaf  symbol Path to leaf  encoding Example A = “0”, B = “101”, C = “100”

Huffman Code Algorithm Overview Encoding Calculate frequency of symbols in file Create binary tree representing “best” encoding Use binary tree to encode compressed file For each symbol, output path from root to leaf Size of encoding = length of path Save binary tree

Huffman Code – Creating Tree Algorithm Place each symbol in leaf Weight of leaf = symbol frequency Select two trees L and R (initially leafs) Such that L, R have lowest frequencies in tree Create new (internal) node Left child  L Right child  R New frequency  frequency( L ) + frequency( R ) Repeat until all nodes merged into one tree

Contoh: Karakter a b c d e f -------------------------------------------------------Frekuensi 45 13 12 16 9 5

Huffman EnCode Example B = 101 C = 100 D = 111 E = 1101 F = 1100 Input DAD Output (111)(0)(111) = 1110111

Huffman Decode Decoding Read compressed file & binary tree Use binary tree to decode file Follow path from root to leaf

Huffman DeCode Example B = 101 C = 100 D = 111 E = 1101 F = 1100 Input 10101000 Output ...................????

Huffman Code Properties Prefix code No code is a prefix of another code Example Huffman(“I”)  00 Huffman(“X”)  001 // not legal prefix code Can stop as soon as complete code found No need for end-of-code marker

Huffman Code Properties Greedy algorithm Chooses best local solution at each step Combines 2 trees with lowest frequency Still yields overall best solution Optimal prefix code Based on statistical frequency Kompleksitas algoritma Huffman: O(n log n)

Practise Diketahui serangkaian kalimat sbb: “aku suka kamu dan kita sama sama suka ada di dalam kampus uns maka aku dan kamu ada disini” Susun huffman code berdasarkan kalimat diatas. Gambarkan tree-nya!