Why do we need compression? EE565 Advanced Image Processing Copyright Xin Li 2009-2012 1  Why do we need image compression? -Example: digital camera (4Mpixel)

Slides:



Advertisements
Similar presentations
Sampling and Pulse Code Modulation
Advertisements

Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
Bounds on Code Length Theorem: Let l ∗ 1, l ∗ 2,..., l ∗ m be optimal codeword lengths for a source distribution p and a D-ary alphabet, and let L ∗ be.
SIMS-201 Compressing Information. 2  Overview Chapter 7: Compression Introduction Entropy Huffman coding Universal coding.
Chapter 6 Information Theory
Compression & Huffman Codes
Lecture 6: Huffman Code Thinh Nguyen Oregon State University.
2015/6/15VLC 2006 PART 1 Introduction on Video Coding StandardsVLC 2006 PART 1 Variable Length Coding  Information entropy  Huffman code vs. arithmetic.
Spatial and Temporal Data Mining
Compression & Huffman Codes Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Losslessy Compression of Multimedia Data Hao Jiang Computer Science Department Sept. 25, 2007.
EE569 Digital Video Processing
Fundamentals of Multimedia Chapter 7 Lossless Compression Algorithms Ze-Nian Li and Mark S. Drew 건국대학교 인터넷미디어공학부 임 창 훈.
T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid.
2015/7/12VLC 2008 PART 1 Introduction on Video Coding StandardsVLC 2008 PART 1 Variable Length Coding  Information entropy  Huffman code vs. arithmetic.
Noise, Information Theory, and Entropy
ELG5126 Source Coding and Data Compression
Software Research Image Compression Mohamed N. Ahmed, Ph.D.
Speech coding. What’s the need for speech coding ? Necessary in order to represent human speech in a digital form Applications: mobile/telephone communication,
©2003/04 Alessandro Bogliolo Background Information theory Probability theory Algorithms.
Context-Based Adaptive Entropy Coding Xiaolin Wu McMaster University Hamilton, Ontario, Canada.
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)
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.
Computer Vision – Compression(2) Hanyang University Jong-Il Park.
296.3Page 1 CPS 296.3:Algorithms in the Real World Data Compression: Lecture 2.5.
CS Spring 2011 CS 414 – Multimedia Systems Design Lecture 7 – Basics of Compression (Part 2) Klara Nahrstedt Spring 2011.
EE591U Wavelets and Filter Banks Copyright Xin Li Roadmap to Lossy Image Compression JPEG standard: DCT-based image coding First-generation wavelet.
EE465: Introduction to Digital Image Processing 1 Data Compression: Advanced Topics  Huffman Coding Algorithm Motivation Procedure Examples  Unitary.
Lossless Compression CIS 465 Multimedia. Compression Compression: the process of coding that will effectively reduce the total number of bits needed to.
COMPRESSION. Compression in General: Why Compress? So Many Bits, So Little Time (Space) CD audio rate: 2 * 2 * 8 * = 1,411,200 bps CD audio storage:
Compression video overview 演講者:林崇元. Outline Introduction Fundamentals of video compression Picture type Signal quality measure Video encoder and decoder.
Huffman coding Content 1 Encoding and decoding messages Fixed-length coding Variable-length coding 2 Huffman coding.
Computer Vision – Compression(1) Hanyang University Jong-Il Park.
Chapter 17 Image Compression 17.1 Introduction Redundant and irrelevant information  “Your wife, Helen, will meet you at Logan Airport in Boston.
Advances in digital image compression techniques Guojun Lu, Computer Communications, Vol. 16, No. 4, Apr, 1993, pp
EE565 Advanced Image Processing Copyright Xin Li Image Denoising Theory of linear estimation Spatial domain denoising techniques Conventional Wiener.
Source Coding Efficient Data Representation A.J. Han Vinck.
Lecture 4: Lossless Compression(1) Hongli Luo Fall 2011.
CS654: Digital Image Analysis Lecture 34: Different Coding Techniques.
1 Source Coding and Compression Dr.-Ing. Khaled Shawky Hassan Room: C3-222, ext: 1204, Lecture 10 Rate-Distortion.
Digital Image Processing Lecture 22: Image Compression
Lossless Compression(2)
STATISTIC & INFORMATION THEORY (CSNB134) MODULE 11 COMPRESSION.
ELE 488 F06 ELE 488 Fall 2006 Image Processing and Transmission ( ) Image Compression Review of Basics Huffman coding run length coding Quantization.
Image Processing Architecture, © Oleh TretiakPage 1Lecture 4 ECE-C490 Winter 2004 Image Processing Architecture Lecture 4, 1/20/2004 Principles.
Chapter 8 Lossy Compression Algorithms. Fundamentals of Multimedia, Chapter Introduction Lossless compression algorithms do not deliver compression.
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.
CS Spring 2012 CS 414 – Multimedia Systems Design Lecture 7 – Basics of Compression (Part 2) Klara Nahrstedt Spring 2012.
ECE 101 An Introduction to Information Technology Information Coding.
Page 1KUT Graduate Course Data Compression Jun-Ki Min.
EE465: Introduction to Digital Image Processing Lossless Image Compression 4 Recall: run length coding of binary and graphic images –Why does it not work.
Entropy vs. Average Code-length Important application of Shannon’s entropy measure is in finding efficient (~ short average length) code words The measure.
UNIT I. Entropy and Uncertainty Entropy is the irreducible complexity below which a signal cannot be compressed. Entropy is the irreducible complexity.
Image Processing Architecture, © Oleh TretiakPage 1Lecture 5 ECEC 453 Image Processing Architecture Lecture 5, 1/22/2004 Rate-Distortion Theory,
IMAGE PROCESSING IMAGE COMPRESSION
Compression & Huffman Codes
EE465: Introduction to Digital Image Processing
Digital Image Processing Lecture 20: Image Compression May 16, 2005
The Johns Hopkins University
Algorithms in the Real World
Context-based Data Compression
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.
UNIT IV.
CSE 589 Applied Algorithms Spring 1999
Image Transforms for Robust Coding
Speech coding.
Presentation transcript:

Why do we need compression? EE565 Advanced Image Processing Copyright Xin Li  Why do we need image compression? -Example: digital camera (4Mpixel) Raw data – 24bits, 5.3M pixels  16M bytes 4G memory card ($10-30)  250 pictures JPEG encoder raw image (16M bytes) compressed JPEG file (1M bytes) compression ratio=16  4000 pictures

EE565 Advanced Image Processing Copyright Xin Li Roadmap to Image Coding Introduction to data compression – A modeling perspective – Shannon’s entropy and Rate-Distortion Theory* (skipped) – Arithmetic coding and context modeling Lossless image compression (covered in EE465) – Spatially adaptive prediction algorithms Lossy image compression – Before EZW era: first-generation wavelet coders – After EZW era: second-generation wavelet coders – A quick tour of JPEG2000 New direction in image coding

EE565 Advanced Image Processing Copyright Xin Li Modeler’s View on Image Coding Spatial-domain models Transform-domain models Stationary process Non-Stationary process Conventional MED, GAP Stationary GGD Non-Stationary GGD Patch-based Transform models Least-Square Based Edge Directed Prediction First-generation Wavelet coders Second-generation Wavelet coders Next-generation coders Nonparametric (patch-based) Intra-coding in H.264

Two Regimes Lossless coding – No distortion is tolerable – Decoded signal is mathematically identical to the encoded one Lossy coding – Distortion is allowed for the purpose of achieving higher compression ratio – Decoded signal should be perceptually similar to the encoded one EE565 Advanced Image Processing Copyright Xin Li

5 Data Compression Basics (bits/sample) or bps weighting coefficients Shannon’s Source Entropy Formula X is a discrete random variable Discrete Source:

EE565 Advanced Image Processing Copyright Xin Li Code Redundancy Average code length: Theoretical bound Practical performance l i : the length of codeword assigned to the i-th symbol Note: if we represent each symbol by q bits (fixed length codes), Then redundancy is simply q-H(X) bps

How to achieve source entropy? EE565 Advanced Image Processing Copyright Xin Li Note: The above entropy coding problem is based on simplified assumptions are that discrete source X is memoryless and P(X) is completely known. Those assumptions often do not hold for real-world data such as images and we will discuss them later. entropy coding discrete source X P(X) binary bit stream

EE565 Advanced Image Processing Copyright Xin Li Two Goals of VLC design  –log 2 p(x)  For an event x with probability of p(x), the optimal code-length is, where  x  denotes the smallest integer larger than x (e.g.,  3.4  =4 ) Achieve optimal code length (i.e., minimal redundancy) Satisfy prefix condition code redundancy: Unless probabilities of events are all power of 2, we often have r>0

Prefix condition EE565 Advanced Image Processing Copyright Xin Li No codeword is allowed to be the prefix of any other codeword. 10 … … 1011 codeword 1 codeword

Coding Procedures for an N-symbol source – Source reduction List all probabilities in a descending order Merge the two symbols with smallest probabilities into a new compound symbol Repeat the above two steps for N-2 steps – Codeword assignment Start from the smallest source and work back to the original source Each merging point corresponds to a node in binary codeword tree EE565 Advanced Image Processing Copyright Xin Li Huffman Codes (Huffman’1952)

A Toy Example EE565 Advanced Image Processing Copyright Xin Li symbol x p(x) e o a i (iou) (aiou) compound symbols u (ou) e ou (ou) i (iou)a (aiou) Source reductionCodeword Assignment

Arithmetic Coding One of the major milestones in data compression (just like Lempel-Ziv coding used in WinZIP) The building block of almost all existing compression algorithms including text, audio, image and video Remarkably simple idea and ease of implementation (especially computational efficiency in the special case of binary arithmetic coding) EE565 Advanced Image Processing Copyright Xin Li

Basic Idea The input sequence will be mapped to a unique real number on [0,1] – The more symbols are coded, the smaller such interval (therefore it takes more bits to represent the interval) – The size of interval is proportional to the probability of the whole sequence Note that we still assume source X is memoryless – source with memory will be handled by context modeling techniques next EE565 Advanced Image Processing Copyright Xin Li

Example EE565 Advanced Image Processing Copyright Xin Li Input Sequence: SQUEEZ… Alphabet: {E,Q,S,U,Z} P(E)=0.429 P(Q)=0.142 P(S)=0.143 P(U)=0.143 P(Z)=0.143 P(SQUEEZ)= P(S)P(Q)P(U) P(E) 2 P(Z)

Example (Con’d) EE565 Advanced Image Processing Copyright Xin Li SQUEEZ… Symbol sequence Interval [ , ] Notes: P(X)  Any number between and will produce a sequence starting from SQUEEZ  How do we know when the sequence stops? I.e. how can encoder distinguish between SQUEEZ and SQUEEZE? The mapping of a real number to a binary bit stream is easy 0 1 First bit Second bit

Another Example EE565 Advanced Image Processing Copyright Xin Li Solution: Use a special symbol to denote end of block (EOB) For example: if we use “!” as EOB symbol, “eaii” becomes eaii!” In other words, we will assign a nonzero probability for EOB symbol.

Implementation Issues EE565 Advanced Image Processing Copyright Xin Li Witten, I. H., Neal, R. M., and Cleary, J. G. “Arithmetic coding for data compression”. Commun. ACM 30, 6 (Jun. 1987),

Arithmetic Coding Summary Based on the given probability model P(X), AC maps the symbol sequence to a unique number between 0 and 1, which can then be conveniently represented by binary bits You will compare Huffman coding and Arithmetic coding in your homework and learn how to use it in the computer assignment EE565 Advanced Image Processing Copyright Xin Li

Context Modeling Arithmetic coding (entropy coding) solves the problem under the assumption that P(X) is known In practice, we don’t know P(X) and have to estimate it from the data More importantly, the memoryless assumption with source X does not hold for real-world data EE565 Advanced Image Processing Copyright Xin Li

Probability Estimation Problem EE565 Advanced Image Processing Copyright Xin Li Given a sequence of symbols, how do we estimate the probability of each individual symbol? Forward solution: Backward solution (more popular in practice): Encoder counts the frequency of each symbol for the whole sequence and transmit the frequency table to the decoder as the overhead Both encoder and decoder count the frequency of each symbol on-the-fly from the causal past only (so no overhead is needed)

Examples P(0)P(1)N(0)N(1) start1/ /31/321 03/41/431 04/51/541 EE565 Advanced Image Processing Copyright Xin Li S={0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1} Forward approach: count 4 “1”s and 12 “0”s  P(0)=3/4, P(1)=1/4 For simplicity, we will consider binary symbol sequence (M-ary sequence is conceptually similar) Backward approach:

Backward Adaptive Estimation EE565 Advanced Image Processing Copyright Xin Li ,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0 T P(0)=.6 P(1)=.4 Example: The probability estimation will be based on the causal past with a specified window length T (i.e., assume source is Markovian) Such adaptive estimation is particularly effective for handling sequence with dynamically varying statistics

Now Comes Context Importance of context – Context is a fundamental concept to help us resolve ambiguity The best known example: By quoting Darwin "out of context" creationists attempt to convince their followers that Darwin didn't believe the eye could evolve by natural selection. Why do we need context? – To handle the memory in the source – Context-based modeling often leads to better estimation of probability models EE565 Advanced Image Processing Copyright Xin Li

Order of Context EE565 Advanced Image Processing Copyright Xin Li First order context “q u o t e” P(u)<<P(u|q) Note: Second order context“s h o c k w a v e” Context Dilution Problem: If source X has N different symbols, K-th order context modeling will define N K different contexts (e.g., consider N=256 for images)

Context-Adaptive Probability Estimation EE565 Advanced Image Processing Copyright Xin Li Thumb rule: in estimating probabilities, only those symbols with the same context will be used in counting frequencies 1D Example 0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1, zero-order (No) context P(0)=P(1)  1/2 first-order context P(1|0)=P(0|1)=1, P(0|0)=P(1|1)=0

2D Example (Binary Image) EE565 Advanced Image Processing Copyright Xin Li Zero-order context: P(0)=5/9, P(1)=4/9 First-order context:W-X P(X|W)=? W=0 (total 20): P(0|0)=4/5, P(1|0)=1/5 W=1 (total 16): P(0|1)=1/4, P(1|1)=3/4 Fourth-order context: NW N NE W X P(1|1111)=1

Data Compression Summary Entropy coding is solved by arithmetic coding techniques Context plays an important role in statistical modeling of source with memory (there exists a problem of context dilution which can be handled by quantizing the context information) Quantization of memoryless source is solved by Lloyd-Max algorithm EE565 Advanced Image Processing Copyright Xin Li

Quantization Theory (Rate-Distortion Theory) EE565 Advanced Image Processing Copyright Xin Li x Q x ^ Quantization noise: For a continuous random variable, distortion is defined by probability distribution function For a discrete random variable, distortion is defined by probabilities

Recall: Quantization Noise of UQ EE565 Advanced Image Processing Copyright Xin Li  -  /2  /2 1/  e f(e) Quantization noise of UQ on uniform distribution is also uniformly distributed Recall Variance of U[-  /2,  /2] is -A-A A

6dB/bit Rule of UQ EE565 Advanced Image Processing Copyright Xin Li Signal: X ~ U[-A,A] Noise: e ~ U[-  /2,  /2] Choose N=2 n (n-bit) codewords for X N=2 n (quantization stepsize)

Shannon’s R-D Function EE565 Advanced Image Processing Copyright Xin Li D R R-D function of source X determines the optimal tradeoff between Rate and Distortion R(D)=min R s.t. E[(X-X) 2 ]≤D ^

A Few Cautious Notes Regarding Distortion Unlike rate (how many bits are used?), definition of distortion is nontrivial at all Mean-Square-Error (MSE) is widely used and will be our focus in this class However, for image signals, MSE has little correlation with subjective quality (the design of perceptual image coders is a very interesting research problem which is still largely open) EE565 Advanced Image Processing Copyright Xin Li

EE565 Advanced Image Processing Copyright Xin Li Gaussian Random Variable X: a given random variable with Gaussian distribution N(0,σ 2 ) Its Rate-Distortion function is known as

Quantizer Design Problem EE565 Advanced Image Processing Copyright Xin Li For a memoryless source X with pdf of P(X), how to design a quantizer (i.e., where to put the L=2 K codewords) to minimize the distortion? Solution: Lloyd-Max Algorithm minimized MSE (we will study it in detail on the blackboard)

Rate Allocation Problem* EE565 Advanced Image Processing Copyright Xin Li Solution: Lagrangian Multiplier technique (we will study it in detail on the blackboard) LL LHHH HL Given a quota of bits R, how should we allocate them to each band to minimize the overall MSE distortion?

Gap Between Theory and Practice Information theoretical results offer little help in the practice of data compression What is the entropy of English texts, audio, speech or image? – Curse of dimensionality Without exact knowledge about the subband statistics, how can we solve the rate allocation problem? – Image subbands are nonstationary and nonGaussian What is the class of image data we want to model in the first place? – Importance of understanding the physical origin of data and its implication into compression EE565 Advanced Image Processing Copyright Xin Li