CSCI 3280 Tutorial 6. Outline  Theory part of LZW  Tree representation of LZW  Table representation of LZW.

Slides:



Advertisements
Similar presentations
Source Coding Data Compression A.J. Han Vinck. DATA COMPRESSION NO LOSS of information and exact reproduction (low compression ratio 1:4) general problem.
Advertisements

IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture3.
Huffman Encoding Dr. Bernard Chen Ph.D. University of Central Arkansas.
Greedy Algorithms (Huffman Coding)
Lecture 10 : Huffman Encoding Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University Lecture notes : courtesy.
Lempel-Ziv-Welch (LZW) Compression Algorithm
Algorithms for Data Compression
Lecture 6 Source Coding and Compression Dr.-Ing. Khaled Shawky Hassan
Compression & Huffman Codes
Algorithm Programming Some Topics in Compression Bar-Ilan University תשס"ח by Moshe Fresko.
Lempel-Ziv Compression Techniques Classification of Lossless Compression techniques Introduction to Lempel-Ziv Encoding: LZ77 & LZ78 LZ78 Encoding Algorithm.
CSc 461/561 CSc 461/561 Multimedia Systems Part B: 1. Lossless Compression.
Lempel-Ziv Compression Techniques
Compression & Huffman Codes Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Lempel-Ziv-Welch (LZW) Compression Algorithm
Lempel-Ziv Compression Techniques
Data Compression Basics & Huffman Coding
1 Lossless Compression Multimedia Systems (Module 2) r Lesson 1: m Minimum Redundancy Coding based on Information Theory: Shannon-Fano Coding Huffman Coding.
Lossless Compression Multimedia Systems (Module 2 Lesson 3)
Data Compression Algorithms for Energy-Constrained Devices in Delay Tolerant Networks Christopher M. Sadler and Margaret Martonosi In: Proc. of the 4th.
Compression Algorithms
Text Compression Spring 2007 CSE, POSTECH. 2 2 Data Compression Deals with reducing the size of data – Reduce storage space and hence storage cost Compression.
Data Structures Arrays both single and multiple dimensions Stacks Queues Trees Linked Lists.
Source Coding-Compression
Information and Coding Theory Heuristic data compression codes. Lempel- Ziv encoding. Burrows-Wheeler transform. Juris Viksna, 2015.
Page 110/6/2015 CSE 40373/60373: Multimedia Systems So far  Audio (scalar values with time), image (2-D data) and video (2-D with time)  Higher fidelity.
Fundamental Structures of Computer Science Feb. 24, 2005 Ananda Guna Lempel-Ziv Compression.
Fundamental Structures of Computer Science March 23, 2006 Ananda Guna Lempel-Ziv Compression.
1 Strings CopyWrite D.Bockus. 2 Strings Def: A string is a sequence (possibly empty) of symbols from some alphabet. What do we use strings for? 1) Text.
Multimedia Specification Design and Production 2012 / Semester 1 / L3 Lecturer: Dr. Nikos Gazepidis
Multimedia Data Introduction to Lossless Data Compression Dr Sandra I. Woolley Electronic, Electrical.
Compression.  Compression ratio: how much is the size reduced?  Symmetric/asymmetric: time difference to compress, decompress?  Lossless; lossy: any.
The LZ family LZ77 LZ78 LZR LZSS LZB LZH – used by zip and unzip
Huffman Coding. Huffman codes can be used to compress information –Like WinZip – although WinZip doesn’t use the Huffman algorithm –JPEGs do use Huffman.
Lossless Compression CIS 465 Multimedia. Compression Compression: the process of coding that will effectively reduce the total number of bits needed to.
Fundamental Data Structures and Algorithms Margaret Reid-Miller 24 February 2005 LZW Compression.
Huffman Coding Yancy Vance Paredes. Outline Background Motivation Huffman Algorithm Sample Implementation Running Time Analysis Proof of Correctness Application.
CS430 © 2006 Ray S. Babcock LZW Coding Lempel-Ziv-Welch.
Data Compression Reduce the size of data.  Reduces storage space and hence storage cost. Compression ratio = original data size/compressed data size.
CS654: Digital Image Analysis Lecture 34: Different Coding Techniques.
Lecture 7 Source Coding and Compression Dr.-Ing. Khaled Shawky Hassan
Data Compression 황승원 Fall 2010 CSE, POSTECH 2 2 포항공과대학교 황승원 교 수는 데이터구조를 수강하 는 포항공과대학교 재학생 들에게 데이터구조를 잘해 야 전산학을 잘할수 있으니 더욱 열심히 해야한다고 말 했다. 포항공과대학교 A 데이터구조를.
CS 1501: Algorithm Implementation LZW Data Compression.
Lempel-Ziv-Welch Compression
1 Huffman Codes. 2 ASCII use same size encoding for all characters. Variable length codes can produce shorter messages than fixed length codes Huffman.
Compression techniques Adaptive and non-adaptive.
CSE 143 Lecture 22 Huffman slides created by Ethan Apter
Prof. Paolo Ferragina, Algoritmi per "Information Retrieval" Basics
Huffman code and Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
Lampel ZIV (LZ) code The Lempel-Ziv algorithm is a variable-to-fixed length code Basically, there are two versions of the algorithm LZ77 and LZ78 are the.
LZW (Lempel-Ziv-welch) compression method The LZW method to compress data is an evolution of the method originally created by Abraham Lempel and Jacob.
15-853Page :Algorithms in the Real World Data Compression III Lempel-Ziv algorithms Burrows-Wheeler Introduction to Lossy Compression.
CS 1501: Algorithm Implementation
Design & Analysis of Algorithm Huffman Coding
HUFFMAN CODES.
Data Compression.
Assignment 6: Huffman Code Generation
Information and Coding Theory
Lempel-Ziv-Welch (LZW) Compression Algorithm
Applied Algorithmics - week7
Lempel-Ziv Compression Techniques
Information of the LO Subject: Information Theory
Lempel-Ziv-Welch (LZW) Compression Algorithm
Lempel-Ziv-Welch (LZW) Compression Algorithm
Data Compression If you’ve ever sent a large file to a friend, you may have compressed it into a zip archive like the one on this slide before doing so.
Chapter 8 – Binary Search Tree
Lempel-Ziv Compression Techniques
Table 3. Decompression process using LZW
Lempel-Ziv-Welch (LZW) Compression Algorithm
Presentation transcript:

CSCI 3280 Tutorial 6

Outline  Theory part of LZW  Tree representation of LZW  Table representation of LZW

Introduction  What is LZW?  Lossless compression method  Lempel-Ziv-Welch  Based on LZ78

Basic idea  Assume repetition of phase usually occurs  Use a code to represent one phase  Build a dictionary of phases that we met  If a phase is found in dictionary, use the code  If not found, add it to dictionary and give it a code  Very high compression ratio if lots of repetition

Algorithm  But how to handle byte stream?  The algorithm is similar to lecture note!  However, each node have maximum number of 256 child nodes. R ….. R AssignmentLecture

R a b a b c d ba ENCODER SIDE: R c d …. Tree Structure Example

R a b a b c d ba ENCODER SIDE: R c d output: 97, b 256 …. Tree Structure Example

R a b a b c d ba ENCODER SIDE: R c d output: 97,98 b 256 …. 257 a Tree Structure Example

R a b a b c d ba ENCODER SIDE: R c d output: 97,98,256 b 256 …. 257 a 258 c Tree Structure Example

R a b a b c d ba ENCODER SIDE: R c d output: 97,98,256,99 b 256 …. 257 a 258 c 259 d Tree Structure Example

R a b a b c d ba ENCODER SIDE: R c d output: 97,98,256,99,100Encode complete! b 256 …. 257 a 258 c 259 d Tree Structure Example

R ba DECODE SIDE: R c d …. output: input: 97,98,256,99,100 Tree Structure Example

R ba DECODE SIDE: R c d …. output: a input: 97,98,256,99,100 Tree Structure Example

R ba DECODE SIDE: R c d …. output: a b input: 97,98,256,99,100 Last string Last string = a b 256 Tree Structure Example

R ba DECODE SIDE: R c d …. output: a b a b input: 97,98,256,99,100 Last string Last string = b b a Tree Structure Example

R ba DECODE SIDE: R c d …. output: a b a b c input: 97,98,256,99,100 Last string Last string = a b b a 258 c Tree Structure Example

R ba DECODE SIDE: R c d …. output: a b a b c d input: 97,98,256,99,100 Last string Last string = c b a 258 c 259 d Tree Structure Example

Algorithm  Now let’s see a table structure example

IN: a b c c c d c c d CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII-255 :: OUT: Prefix Char. Search Code Saved NULL Table Structure Compression

IN: a b c c c d c c d CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII-255 :: OUT: Prefix Char. Search Code Saved NULL Table Structure Compression ‘a’ “a” 97 “a” ‘b’ “ab” 256 “ ab ” 97

IN: a b c c c d c c d CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII “ ab ” OUT: 97, Prefix Char. Search Code Saved NULL ‘b’ “b” 98 ‘b’ ‘c’ “bc” 257 “ bc ” 98 Table Structure Compression

IN: a b c c c d c c d CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII “ ab ” 257 “ bc ” OUT: 97, 98, Prefix Char. Search Code Saved NULL ‘c’ “c” 99 ‘c’ “cc” 258 “ cc ” 99 Table Structure Compression

IN: a b c c c d c c d CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII “ ab ” 257 “ bc ” 258 “ cc ” OUT: 97, 98, 99, Prefix Char. Search Code Saved NULL ‘c’ “c” 99 ‘c’ “cc” 258 ‘cc’ ‘d’ “ccd” 259 “ ccd ” 258 Table Structure Compression

IN: a b c c c d c c d CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII “ ab ” 257 “ bc ” 258 “ cc ” 259 “ ccd ” OUT: 97, 98, 99, 258, Prefix Char. Search Code Saved NULL ‘d’ “d” 100 ‘d’ ‘c’ “dc” 260 “ dc ” 100 Table Structure Compression

IN: a b c c c d c c d CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII “ ab ” 257 “ bc ” 258 “ cc ” 259 “ ccd ” 260 “ dc ” OUT: 97, 98, 99, 258, 100, Prefix Char. Search Code Saved NULL ‘c’ “c” 99 ‘c’ “cc” 258 ‘cc’ ‘d’ “ccd” 259 Table Structure Compression

IN: 97, 98, 99, 258, 100, 259 CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII-255 OUT: cW pW C C dict(pW)+C 97 a Table Structure Decompression

IN: 97, 98, 99, 258, 100, 259 CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII-255 OUT: a “ab” 256 b cW pW C C dict(pW)+C 98 97‘b’ “ab” Table Structure Decompression

IN: 97, 98, 99, 258, 100, 259 CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII “ ab ” OUT: a b “bc” 257 c cW pW C C dict(pW)+C 99 98‘c’ “bc” Table Structure Decompression

IN: 97, 98, 99, 258, 100, 259 CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII “ ab ” 257 “ bc ” OUT: a b c “cc” 258 c cW pW C C dict(pW)+C ‘c’ “cc” exception Table Structure Decompression

IN: 97, 98, 99, 258, 100, 259 CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII “ ab ” 257 “ bc ” 258 “ cc ” OUT: a b c c c “ccd” 259 d cW pW C C dict(pW)+C ‘d’ “ccd” Table Structure Decompression

IN: 97, 98, 99, 258, 100, 259 CODEEntry 0NUL : 97a 98b 99c 100d :: 255ASCII “ ab ” 257 “ bc ” 258 “ cc ” 259 “ ccd ” OUT: a b c c c d “dc” 260 c c d cW pW C C dict(pW)+C ‘c’ “dc” Table Structure Decompression

 Handling of exception case:  Usually C is the first char of current word(cW)  In exception C is the first char of previous word(pW)

Exercise  Encode and decode with tree structure. (This helps to better understand that in exception case, why C must be the first char of pW.)  My understanding to the exercise question: To encounter exception case, cW must be construct along pW branch, otherwise we will not encounter exception case, so the first char of cW and pW is the same char.