296.3Page 1 CPS 296.3:Algorithms in the Real World Data Compression: Lecture 2.5.

Slides:



Advertisements
Similar presentations
T.Sharon-A.Frank 1 Multimedia Compression Basics.
Advertisements

15-583:Algorithms in the Real World
Data Compression CS 147 Minh Nguyen.
Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
Lecture 6 Source Coding and Compression Dr.-Ing. Khaled Shawky Hassan
T h e U n i v e r s i t y o f B r i t i s h C o l u m b i a Bi-Level Image Compression EECE 545: Data Compression by Dave Tompkins.
Data Compression Michael J. Watts
Lecture04 Data Compression.
SWE 423: Multimedia Systems
School of Computing Science Simon Fraser University
CSc 461/561 CSc 461/561 Multimedia Systems Part B: 1. Lossless Compression.
SWE 423: Multimedia Systems
CSCI 3 Chapter 1.8 Data Compression. Chapter 1.8 Data Compression  For the purpose of storing or transferring data, it is often helpful to reduce the.
Spatial and Temporal Data Mining
1 Lempel-Ziv algorithms Burrows-Wheeler Data Compression.
Computer Science 335 Data Compression.
Compression & Huffman Codes Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Fundamentals of Multimedia Chapter 7 Lossless Compression Algorithms Ze-Nian Li and Mark S. Drew 건국대학교 인터넷미디어공학부 임 창 훈.
2015/7/12VLC 2008 PART 1 Introduction on Video Coding StandardsVLC 2008 PART 1 Variable Length Coding  Information entropy  Huffman code vs. arithmetic.
Lossless Compression in Multimedia Data Representation Hao Jiang Computer Science Department Sept. 20, 2007.
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.
©Brooks/Cole, 2003 Chapter 15 Data Compression. ©Brooks/Cole, 2003 Realize the need for data compression. Differentiate between lossless and lossy compression.
Yehong, Wang Wei, Wang Sheng, Jinyang, Gordon. Outline Introduction Overview of Huffman Coding Arithmetic Coding Encoding and Decoding Probabilistic Model.
Spring 2015 Mathematics in Management Science Binary Linear Codes Two Examples.
Data Compression Arithmetic coding. Arithmetic Coding: Introduction Allows using “fractional” parts of bits!! Used in PPM, JPEG/MPEG (as option), Bzip.
Basics of Compression Goals: to understand how image/audio/video signals are compressed to save storage and increase transmission efficiency to understand.
Huffman Coding Vida Movahedi October Contents A simple example Definitions Huffman Coding Algorithm Image Compression.
8. Compression. 2 Video and Audio Compression Video and Audio files are very large. Unless we develop and maintain very high bandwidth networks (Gigabytes.
Chapter 2 Source Coding (part 2)
Advanced Algorithms Piyush Kumar (Lecture 10: Compression) Welcome to COT5405 Source: Guy E. Blelloch, Emad, Tseng …
Algorithms in the Real World
Noiseless Coding. Introduction Noiseless Coding Compression without distortion Basic Concept Symbols with lower probabilities are represented by the binary.
15-853Page :Algorithms in the Real World Data Compression II Arithmetic Coding – Integer implementation Applications of Probability Coding – Run.
Algorithm Design & Analysis – CS632 Group Project Group Members Bijay Nepal James Hansen-Quartey Winter
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.
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.
1 Source Coding and Compression Dr.-Ing. Khaled Shawky Hassan Room: C3-222, ext: 1204, Lecture 5.
1 Classification of Compression Methods. 2 Data Compression  A means of reducing the size of blocks of data by removing  Unused material: e.g.) silence.
Lossless Compression CIS 465 Multimedia. Compression Compression: the process of coding that will effectively reduce the total number of bits needed to.
Huffman Code and Data Decomposition Pranav Shah CS157B.
CS Spring 2011 CS 414 – Multimedia Systems Design Lecture 6 – Basics of Compression (Part 1) Klara Nahrstedt Spring 2011.
Lecture 4: Lossless Compression(1) Hongli Luo Fall 2011.
Parallel Data Compression Utility Jeff Gilchrist November 18, 2003 COMP 5704 Carleton University.
CS654: Digital Image Analysis Lecture 34: Different Coding Techniques.
Lecture 7 Source Coding and Compression Dr.-Ing. Khaled Shawky Hassan
Lossless Compression(2)
Multi-media Data compression
Chapter 7 Lossless Compression Algorithms 7.1 Introduction 7.2 Basics of Information Theory 7.3 Run-Length Coding 7.4 Variable-Length Coding (VLC) 7.5.
Index construction: Compression of documents Paolo Ferragina Dipartimento di Informatica Università di Pisa Reading Managing-Gigabytes: pg 21-36, 52-56,
Page 1KUT Graduate Course Data Compression Jun-Ki Min.
Prof. Paolo Ferragina, Algoritmi per "Information Retrieval" Basics
15-853Page :Algorithms in the Real World Data Compression III Lempel-Ziv algorithms Burrows-Wheeler Introduction to Lossy Compression.
Page 1 Algorithms in the Real World Lempel-Ziv Burroughs-Wheeler ACB.
Submitted To-: Submitted By-: Mrs.Sushma Rani (HOD) Aashish Kr. Goyal (IT-7th) Deepak Soni (IT-8 th )
Data Compression Michael J. Watts
Textbook does not really deal with compression.
Compression & Huffman Codes
Data Compression.
Algorithms in the Real World
Algorithms in the Real World
Huffman Coding, Arithmetic Coding, and JBIG2
Data Compression CS 147 Minh Nguyen.
Why Compress? To reduce the volume of data to be transmitted (text, fax, images) To reduce the bandwidth required for transmission and to reduce storage.
CSE 589 Applied Algorithms Spring 1999
CPS 296.3:Algorithms in the Real World
Presentation transcript:

296.3Page 1 CPS 296.3:Algorithms in the Real World Data Compression: Lecture 2.5

296.3Page 2 Summary so far Model generates probabilities, Coder uses them Probabilities are related to information. The more you know, the less info a message will give. More “skew” in probabilities gives lower Entropy H and therefore better compression Context can help “skew” probabilities (lower H) Average length l a for optimal prefix code bound by Huffman codes are optimal prefix codes Arithmetic codes allow “blending” among messages

296.3Page 3 Encoding: Model and Coder The Static part of the model is fixed The Dynamic part is based on previous messages – allows probability distribution to change The “optimality” of the code is relative to the probabilities. If they are not accurate, the code is not going to be efficient Dynamic Part Static Part Coder Message s  S Codeword Model {p(s) | s  S} Compress |w|  i M (s) = -log p(s)

296.3Page 4 Decoding: Model and Decoder The probabilities {p(s) | s  S} generated by the model need to be the same as generated in the encoder. Note: consecutive “messages” can be from different message sets, and the probability distribution can change Decoder Message s  S Codeword Dynamic Part Static Part Model {p(s) | s  S} Uncompress

296.3Page 5 Codes with Dynamic Probabilities Huffman codes: Need to generate a new tree for new probabilities. Small changes in probability typically make small changes to the Huffman tree. “Adaptive Huffman codes” update the tree without having to completely recalculate it. Used frequently in practice Arithmetic codes: Need to recalculate the f(m) values based on current probabilities. Can be done with a balanced tree.

296.3Page 6 Compression Outline Introduction: Lossy vs. Lossless, Benchmarks, … Information Theory: Entropy, etc. Probability Coding: Huffman + Arithmetic Coding Applications of Probability Coding: PPM + others –Transform coding: move to front, run-length, … –Context coding: fixed context, partial matching Lempel-Ziv Algorithms: LZ77, gzip, compress,... Other Lossless Algorithms: Burrows-Wheeler Lossy algorithms for images: JPEG, MPEG,... Compressing graphs and meshes: BBK

296.3Page 7 Applications of Probability Coding How do we generate the probabilities? Using character frequencies directly does not work very well (e.g. 4.5 bits/char for text). Technique 1: transforming the data –Run length coding (ITU Fax standard) –Move-to-front coding (Used in Burrows-Wheeler) –Residual coding (JPEG LS) Technique 2: using conditional probabilities –Fixed context (JBIG…almost) –Partial pattern matching (PPM)

296.3Page 8 Run Length Coding Code by specifying message value followed by the number of repeated values: e.g. abbbaacccca => (a,1),(b,3),(a,2),(c,4),(a,1) The characters and counts can be coded based on frequency, ensures only a few bits of overhead for low counts such as 1. Run length coding exploits context to skew probabilities.

296.3Page 9 Facsimile ITU T4 (Group 3) Standard used by all home Fax Machines ITU = International Telecommunications standards body Run length encodes sequences of black+white pixels Fixed Huffman Code for all documents. e.g. Since alternate black and white, no need to specify – but use different codewords anyway. Why?

296.3Page 10 Facsimile ITU T4 (Group 3) Transform: (run length) –input : binary string –output : interleaving of run lengths of black and white pixels Probabilities: (on the output of the transform) Static probabilities of each run length based on large set of test documents. Coding: Huffman coding

296.3Page 11 Move to Front Coding Transforms message sequence into sequence of integers, that can then be probability coded Like run-length, takes advantage of temporal locality Probability distribution is dynamic Start with values in a total order: e.g.: [a,b,c,d,…] For each message –output the position in the order –move to the front of the order. e.g.: c => output: 3, new order: [c,a,b,d,e,…] a => output: 2, new order: [a,c,b,d,e,…] Probability code the output, assuming a bias for small numbers.

296.3Page 12 BZIP Transform 0: Embedded run length: AAAAAAA  AAAA\3 Transform 1: (Burrows Wheeler) – covered later –input : character string (block) – 100KBto 900KB –output : reordered character string Transform 2: (move to front) –input : character string –output : MTF numbering Transform 3: (run length) –input : MTF numbering –output : sequence of run lengths Probabilities: (on run lengths) Dynamic based on counts for each block. Coding: Originally arithmetic, but changed to Huffman in bzip2 due to patent concerns

296.3Page 13 Residual Coding Typically used for message values that represent some sort of amplitude: e.g., gray-level in an image, or amplitude in audio. Basic Idea: guess next value based on current context. Output difference between guess and actual value. Use probability code on the output. Consider compressing a stock value over time.

296.3Page 14 JPEG-LS JPEG Lossless (not to be confused with lossless JPEG) Recently completed standardization process. Codes in Raster Order. Uses 4 pixels as context: Tries to guess value of * based on W, NW, N and NE. Works in two stages NW W NNE *

296.3Page 15 JPEG LS: Stage 1 Uses the following equation: Averages neighbors and captures edges. e.g. 40 3*  *  * 

296.3Page 16 JPEG LS: Stage 2 Uses 3 gradients (differences): NE-N, N-NW, and NW-W Classifies each into one of 9 “roughly equiprobable” regions. This gives 9 3 =729 contexts, of which only 365 are needed because of symmetry. Each context has a bias term that is used to adjust the previous prediction After correction, the residual between guessed and actual value is found and coded using a Golomb-like code. (Golomb codes are similar to Gamma codes. Small values have shorter codes.)

296.3Page 17 JPEG LS Transform: (residual) –input : gray-level image (8 bits/pixel) –output : difference from guess at each pixel Probabilities: (on the differences) Static probabilities based on golomb code --- something like p(n) = c/n 2. Coding: Golomb code

296.3Page 18 Using Conditional Probabilities: PPM Use previous k characters as the context. –Makes use of conditional probabilities Base probabilities on counts: e.g., if seen th 12 times followed by e 7 times, then the conditional probability p(e|th) = 7/12. Need to keep k small so that dictionary does not get too large (typically less than 8). Note that 8-gram Entropy of English is about 2.3bits/char while PPM does as well as 1.7bits/char

296.3Page 19 PPM: Prediction by Partial Matching Problem: What do we do if we have not seen the context followed by the character before? –Cannot code 0 probabilities! The key idea of PPM is to reduce context size if previous match has not been seen. –If character has not been seen before with current context of size 3, try context of size 2, and then context of size 1, and then no context Keep statistics for each context size < k

296.3Page 20 PPM: Changing between context How do we tell the decoder to use a smaller context? Send an escape message. Each escape tells the decoder to reduce the size of the context by 1. The escape can be viewed as special character, but needs to be assigned a probability. –Different variants of PPM use different heuristics for the probability.

296.3Page 21 PPM: Example Contexts ContextCountsContextCountsContextCounts EmptyA = 4 B = 2 C = 5 $ = 3 ABCABC C = 3 $ = 1 A = 2 $ = 1 A = 1 B = 2 C = 2 $ = 3 AC BA CA CB CC B = 1 C = 2 $ = 2 C = 1 $ = 1 C = 1 $ = 1 A = 2 $ = 1 A = 1 B = 1 $ = 2  k=2 String = ACCBACCACBA $ means escape, values from PPMC

296.3Page 22 PPM: Other important optimizations If context has not been seen before, automatically escape (no need for an escape symbol since decoder knows previous contexts) Also, can exclude certain possibilities when switching down a context. This can save 20% in final length! For example, to code an A, send two escapes $, then exclude possibility that character is C in zero context list (use a count of 0 for C.) It is critical to use arithmetic codes since the probabilities are small.