180 likes | 416 Views
Transform Coding. Mei-Chen Yeh 12/04/2009. Introduction. To compact most of the information into a few elements The weight-height example:. Discard y (2D->1D) and inverse transform. Transform. 68 °. Another example. Slide credit: Bernd Girod. Transform Coding. Three steps
E N D
Transform Coding Mei-Chen Yeh 12/04/2009
Introduction • To compact most of the information into a few elements The weight-height example: Discard y (2D->1D) and inverse transform Transform 68°
Another example Slide credit: Bernd Girod
Transform 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 Transform Quantization Binary coding
The Transform x θ • Forward transform • Inverse transform • Orthonormal transforms • A-1 = AT • Linearity: x is represented as a linear combination of “basis vectors” • Parseval’s Theorem holds: the total energy is preserved N-dimensional vector N-dimensional vector or NxN matrix or Transform
Two-dimensional transform • Separable transforms • Take the transform along one dimension, then repeat the operation along the other direction • Ex: rows -> columns, or columns -> rows • Forward transform • Backward transform NxN matrix NxN matrix NxN matrix
Transforms of interest • Data-dependent • Discrete Karhunen Lòeve transform (KLT) • Data-independent • Discrete cosine transform (DCT)
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
DCT (1) • Part of many standards (JPEG, MPEG, H.261, …) • The transform matrix C • Visualize the rows of C The frequency increases as we go from top to bottom!
DCT (2) • 2-D basis matrices of DCT Increased variation!
DCT (3) • Performs close to the optimum KLT in terms of compaction
Quantization and coding of transform coefficients (1) • The bit-rate allocation problem • Divide bit-rate R among transform coefficients such that resulting distortion D is minimized Transform Quantization Binary coding
Quantization and coding (2) • The optimal bit allocation • The zonal sampling • Compute σ2θk for each coefficient • Set Rk = 0 for all k • Sort {σ2θk}. Suppose σ2θ1 is the max. • Increment R1 by 1, divide σ2θ1 by 2. • Decrement Rb by 1. • If Rb=0, stop; • Otherwise, go to step 3 variance of the transform coefficient θk Rb = 72 bits Discarded!
Quantization and coding (3) • The threshold coding • Transform coefficients that fall below a threshold are discarded • Example: a 8x8 block The zigzag scan Sample quantization table Horizontal frequency → DC component vertical frequency → AC components noisy
Quantization table Example: Encode Remove mean, DCT Quantize Zigzag scan -26 -3 0 -3 -2 -6 2 -4 1 -4 1 1 5 1 2 -1 1 -1 2 0 0 −1 1 −1 2 0 0 0 0 0 −1 −1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Add EOF -26 -3 0 -3 -2 -6 2 -4 1 -4 1 1 5 1 2 -1 1 -1 2 0 0 −1 1 −1 2 0 0 0 0 0 −1 −1 EOF Entropy coding 010001010000101110000011101010011000101111100000……………
Quantization table Example: Decode 010001010000101110000011101010011000101111100000…………… Original block Entropy decoding -26 -3 0 -3 -2 -6 2 -4 1 -4 1 1 5 1 2 -1 1 -1 2 0 0 −1 1 −1 2 0 0 0 0 0 −1 −1 EOF Put into a block Reconstructed block Inverse DCT, Add mean Q-1