760 likes | 986 Views
Multimedia Compression (2). Mei-Chen Yeh 03/23/2009. Review. Entropy Entropy coding Huffman coding Arithmetic coding. Lossless!. Outline. Revisiting Information theory Lossy compression Quantization Transform coding. Encoder. Decoder. source. s=r Lossless s ≠ r Lossy.
E N D
Multimedia Compression (2) Mei-Chen Yeh 03/23/2009
Review • Entropy • Entropy coding • Huffman coding • Arithmetic coding Lossless!
Outline • Revisiting Information theory • Lossy compression • Quantization • Transform coding
Encoder Decoder source s=r Lossless s≠r Lossy Performance measures Distortion reconstruction 1 Rate 2 • Lossless coding • Rate • Lossy coding • Rate • Distortion
Lossy compression • Goals • Minimize the rate • Keep the distortion small • Tradeoffs between the best of both worlds • Rate-distortion theory • Provides theoretical bounds for lossy compression
Distortion (1) • Suppose we send a symbol xi, receive yi • d(xi, yi) ≥ 0 • d(xi, yi) = 0 for xi= yi • Average distortion • D = ∑x∑yp(xi, yi)d(xi, yi) • Distortion measurement?
Distortion (2) decibels (分貝) • User feedbacks • Subjective and may be biased • Some popular criteria: • Mean square error (mse) • Average of the absolute difference • Signal-to-noise ratio (SNR) • Peak-signal-to-noise ratio (PSNR)
Information theory revisited (1) • Information: reduction in uncertainty #1: predict the outcome of a coin flip #2: predict the outcome of a die roll Next #1: You observe the outcome of a coin flip #2: You observe the outcome of a die roll Which has more uncertainty? #2 #2 Which provides more information?
Information theory revisited (2) • Entropy • The average self-information • The average amount of information provided per symbol • The uncertainty an observer has before seeing the symbol • The average number of bits needed to communicate each symbol
Conditional entropy • Example: two random variables X and Y X : College major Y : Likes “XBOX” Yes No 0 H(Y|X=CS) =? 1 H(Y|X=Math) =?
Conditional entropy • The conditional entropy H(Y|X) H(Y|X) = 0.5H(Y|X=Math)+0.25H(Y|X=CS)+0.25H(Y|X=H.) H(Y|X) = 0.5*1 + 0.25*0 + 0.25*0 = 0.5
Joint probability conditional probability
Conditional entropy H(X) = 1.5 H(Y) = 1 H(Y|X) = 0.5 H(X|Y) = 1 ≤ • H(X|Y) • The amount of uncertainty remaining about X, given we know the value Y • H(X|Y) vs. H(X)
Average mutual information The amount of information that X and Y convey about each other! Mutual information Average mutual information
Average mutual information • Properties • 0 ≤ I(X; Y) = I(Y; X) • I(X; Y) ≤ H(X) • I(Y; X) ≤ H(Y)
Lossy compression Lower the bit rate R by allowing some acceptable distortion D of the signal
Types of lossy data compression Given R, minimize D Given D, minimize R
Rate distortion theory Calculates the minimum transmission bit-rate R for a required reconstruction quality The results do not depend on a specific coding method.
Rate distortion function With the assumption of statistical independence between distortion and reconstructed signal Represents trade-offs between distortion and rate Definition: The lowest rate at which the source can be encoded while keeping the distortion less than or equal to D* Shannon lower bound
Example: Rate distortion function for the Gaussian source No compression system exists that performs outside the gray area! • A zero mean Gaussian pdf with variance σx2 • Distortion: the MSE measure • D = E[(X-Y)2] • The rate distortion function is:
For more information: Khalid Sayood. Introduction to Data Compression, 3rd edition, Morgan Kaufmann, 2005.
Outline • Revisiting Information theory • Lossy compression • Quantization • Transform coding
Quantization • A practical lossy compression technique • The process of representing a large–possibly infinite–set of values with a much smaller set
Example Use -10, -9, …,0, 1, …, 10 (21 values) to represent real numbers (infinite values) 2.47 => 2 3.1415926 => 3 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 Loss of information! The reconstruction value 3 could be 2.95, 3.16, 3.05, …
Scalar quantization • Inputs and outputs are scalars • Design of a scalar quantizer • Construct intervals (Encoder) • Assign codewords to intervals (Encoder) • Select reconstruction values (Decoder) -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
Scalar quantization (cont.) • Input-output map Output Input -∞ ∞ v Decision boundaries Reconstruction levels
Example: Quantization for image compression 64 196 8-bit per pixel [0 255] 1-bit per pixel {0, 128, 255} 2-bit per pixel {0, 64, 128, 196, 255} 3-bit per pixel (8 intervals)
Quantization problem (1) • Fixed-length coding Given an input pdf fx(x) and the number of levels M in the quantizer, find the decision boundaries {bi} and the reconstruction levels {yi} so as to minimize the distortion.
Quantization problem (2) • Variable-length coding Given a distortion constraint find the decision boundaries {bi} and the reconstruction levels {yi}, andbinary codesthat minimize the rate while satisfying the constraint.
Vector Quantization SLOW FAST K L How to generate the codebook? Operate on blocks of data The VQ procedure:
Why VQ? Samples may be correlated! Example: height and weight of individuals
2-d Vector Quantization Quantization rule Quantization regions The quantization regions are no longer restricted to be rectangles!
Codebook Design 3 2.5 2 1.5 y 1 0.5 0 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 x The Linde-Buzo-Gray Algorithm (also known as k-means)
LBG Algorithm Training set
Problems of LBG No guarantee that the procedure will converge to the optimal solution! Sensitive to initial points Empty-cell
The Empty Cell Problem No update in an empty region End up with an output point that is never used
More… • LBG has problems when clusters have different • Sizes • Densities • Non-globular shapes
Differing Sizes LBG (3 Clusters) Original Points
Different Densities LBG (3 Clusters) Original Points
Non-globular Shapes Original Points LBG (2 Clusters)
Use of LBG for Image Compression Use 4x4 blocks of pixels Codebook size 16 Codebook size 64 Codebook size 256 Codebook size 1024
Outline • Revisiting Information theory • Lossy compression • Quantization • Transform coding and the baseline JPEG
To compact most of the information into a few elements! Slide credit: Bernd Girod
Transform coding Transform Quantization Binary coding • Three steps • Divide a data sequence into blocks of size N and transform each block using a reversible mapping • Quantize the transformed sequence • Encode the quantized values
Transforms of interest • Data-dependent • Discrete Karhunen Lòeve transform (KLT) • Data-independent • Discrete cosine transform (DCT) • Sub-band coding • Wavelet transform
KLT • Also known as Principal Component Analysis (PCA), or the Hotelling transform • Transforms correlated variables into uncorrelated variables • Basis vectors are eigenvectors of the covariance matrix of the input signal • Achieves optimum energy concentration • Disadvantages • Dependent on signal statistics • Not separable