Data Compression: Transform Coding in Practice 2 / 50 Last Lecture Last Lectures: Orthogonal Block Transforms
Total Page:16
File Type:pdf, Size:1020Kb
Transform Coding in Practice Last Lecture Last Lectures: Basic Concept Transform Coding Transform reduces linear dependencies (correlation) between samples before scalar quantization For correlated sources: Scalar quantization in transform domain is more efficient encoder decoder 0 u0 q0 q0 u0 α0 β0 forward entropy entropy 0 inverse s u1 q1 b q1 u1 s0 transform α1 coding decoding β1 transform . γ −1 . 0 −1 A uN−1 qN−1 γ qN−1 uN−1 A αN−1 βN−1 Encoder (block-wise) Decoder (block-wise) −1 Forward transform: u = A · s Entropy decoding: fqk g = γ (b) Scalar quantization: q = α (u ) 0 k k k Inverse quantization: uk = βk (qk ) 0 −1 0 Entropy coding: b = γ( fqk g ) Inverse transform: s = A · u Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 2 / 50 Last Lecture Last Lectures: Orthogonal Block Transforms Transform matrix has property: A−1 = AT (special case of unitary matrix: A−1 = (A∗)T) 2 b0 3 2 3 6 b1 7 6 7 6 7 6 7 6 b2 7 −1 T 6 b b b ··· b 7 A = 6 7 A = A = 6 0 1 2 N−1 7 6 . 7 6 7 4 . 5 4 5 bN−1 −1 T Basis vectors bk (rows of A, columns of A = A ) form an orthonormal basis Geometric interpretation: Rotation (and potential reflection) in N-dimensional signal space Why Orthogonal Transforms ? 0 2 0 2 Same MSE distortion in sample and transform space: jju − ujj2 = jjs − sjj2 Minimum MSE in signal space can be achieved by minimization of MSE for each individual transform coefficient Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 3 / 50 Last Lecture Last Lectures: Bit Allocation and High-Rate Approximations Bit Allocation of Transform Coefficients Optimal bit allocation: Pareto condition @ Dk (Rk ) = −λ = const =) high rates: Dk (Rk ) = const @Rk High-Rate Approximation High-rate distortion rate function for transform coding with optimal bit allocation 1 1 2 2 −2R 2 Y 2N 2 Y 2N D(R) =" ~ · σ~ · 2 with "~ = "k ; σ~ = σk k k High-rate transform coding gain GT and energy compaction measure GEC D (R) "2 · σ2 σ2 1 PN−1 σ2 G = SQ = S S ; G = S = N k=0 k T 2 2 EC 2 q DTC (R) "~ · σ~ σ~ N QN−1 2 k=0 σk Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 4 / 50 Last Lecture Last Lectures: Karhunen Loève Transform (KLT) Design criterion: Orthogonal transform A that yields uncorrelated transform coefficients 2 2 3 σ0 0 ··· 0 6 0 σ2 ··· 0 7 T 6 1 7 2 CUU = A · CSS · A = 6 . 7 =) CSS · bk = σ · bk 6 . 7 k 4 . 5 2 0 0 ··· σN−1 Eigenvector equation for all basis vectors bk (rows of transform matrix A) Rows of KLT matrix A are the unit-norm eigenvectors of CSS 2 Transform coefficient variances σk are the eigenvalues of CSS 2 2 b0 3 2 σ0 0 ··· 0 3 2 6 b1 7 6 0 σ ··· 0 7 6 7 6 1 7 A = 6 . 7 C UU = 6 . 7 6 . 7 6 . .. 7 4 . 5 4 . 5 2 bN−1 0 0 ··· σN−1 Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 5 / 50 Last Lecture Last Lectures: Maximum Energy Compaction and Optimality High-Rate Approximation for KLT and Gauss-Markov High-rate operational distortion-rate function N−1 2 2 2 N −2R DN (R) = " · σS · (1 − % ) · 2 High-rate transform coding gain: Increases with transform size N N N 2 1−N 1 1 G = G = (1 − % ) N =) G = T EC T 1 − %2 For N ! 1, gap to fundamental lower bound reduces to space-filling gain (1.53 dB) On Optimality of KLT KLT yields uncorrelated transform coefficients and maximizes energy compaction GEC KLT is the optimal transform for stationary Gaussian sources Other sources: Optimal transform is hard to find (iterative algorithm) Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 6 / 50 Signal-Independent Unitary Transforms Transform Selection in Practice Optimal Unitary Transform Stationary Gaussian sources: KLT General sources: Not straightforward to determine (typically KLT close to optimal) Signal dependent (may change due to signal instationarities) Adaptive Transform Selection Determine transform in encoder, include transform specification in bitstream Increased side information may lead to sub-optimal overall coding efficiency Simple variant: Switched transforms (e.g., in H.266/VVC) Signal-Independent Transforms Choose transform that provides good performance for variety of signals Not optimal, but often close to optimal for typical signal Most often used design in practice Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 7 / 50 Signal-Independent Unitary Transforms / Walsh-Hadamard Transform Walsh-Hadamard Transform For transform sizes N that are positive integer powers of 2 1 AN=2 AN=2 h i AN = p with A1 = 1 : 2 AN=2 −AN=2 Examples: Transform matrices for N = 2, N = 4, and N = 8 2 1 1 1 1 1 1 1 1 3 1 1 1 A2 = p 6 1 −1 1 −1 1 −1 1 −1 7 2 1 −1 6 7 6 1 1 −1 −1 1 1 −1 −1 7 6 7 2 3 1 6 1 −1 −1 1 1 −1 −1 1 7 1 1 1 1 A8 = p 6 7 8 6 1 1 1 1 −1 −1 −1 −1 7 1 6 1 −1 1 −1 7 6 7 A4 = p 6 7 6 1 −1 1 −1 −1 1 −1 1 7 4 4 1 1 −1 −1 5 6 7 4 1 1 −1 −1 −1 −1 1 1 5 1 −1 −1 1 1 −1 −1 1 −1 1 1 −1 Very simple orthogonal transform (only additions, subtractions, and final scaling) Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 8 / 50 Signal-Independent Unitary Transforms / Walsh-Hadamard Transform Basis Functions of the WHT (Example for N = 8) b0 b4 b1 b5 b2 b6 b3 b7 Media coding: Walsh-Hadamard transform with strong quantization Piece-wise constant basis vectors yield subjectively disturbing artifacts Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 9 / 50 Signal-Independent Unitary Transforms / Fourier Transform Discrete Version of the Fourier Transform The Fourier Transform Fundamental transform used in mathematics, physics, signal processing, communications, ... Integral transform representing signal as integral of frequency components Forward and inverse transform are given by 1 1 Z Z X (f ) = Fx(t) = x(t) · e−2πift dt () x(t) = F −1x(t) = X (f ) · e2πift df −∞ −∞ 2πift Basis functions are complex exponentials bf (t) = e Discrete Version of the Fourier Transform Fourier transform for finite discrete signals Could also be useful for coding of discrete signals Can be derived using sampling and windowing Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 10 / 50 Signal-Independent Unitary Transforms / Fourier Transform Important Properties of the Fourier Transform n o Linearity: F a · h(t) + b · g(t) = a · H(f ) + b · G(f ) n o 1 f Scaling: F h(a · t) = · H jaj a n o −2πit0f Translation: F h(t − t0) = e · H(f ) n o 2πitf0 Modulation: F e · h(t) = H(f − f0) n o Duality: F H(t) = h(−f ) n o Z 1 Convolution: F h(t) ∗ g(t) = F g(τ) h(t − τ) dτ = H(f ) · G(f ) −∞ n o Multiplication: F h(t) · g(t) = H(f ) ∗ G(f ) Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 11 / 50 Signal-Independent Unitary Transforms / Fourier Transform The Dirac Delta Function Dirac Delta Function Not a function in traditional sense Dirac delta distribution Can be thought of function with the following properties 1 +1 : x = 0 Z δ(x) = and δ(x) dx = 1 0 : x 6= 0 −∞ Important Properties Z 1 Sifting: h(t) δ(t − t0) dt = h(t0) −∞ Z 1 Convolution: h(t) ∗ δ(t − t0) = h(τ) δ(t − t0 − τ) dτ = h(t − t0) −∞ 1 ! 1 Z 1 X X Sampling: h(t) δ(t − k · t0) dt = h(k · t0) −∞ k=−∞ k=−∞ Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 12 / 50 Signal-Independent Unitary Transforms / Fourier Transform Selected Fourier Transform Pairs Dirac delta function δ(t − T ) complex exponential F δ(t − T ) T t f x(t) = δ(t − T ) X (f ) = e−2πifT = cos(2πfT ) + i sin(2πfT ) Dirac comb шT (t) Dirac comb ШT (f ) 1 T T 1 t 1 f X X шT (t) = δ(t − kT ) ШT (f ) = δ(f − k=T ) k=−∞ k=−∞ Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 13 / 50 Signal-Independent Unitary Transforms / Fourier Transform Selected Fourier Transform Pairs rectangular window rectT (t) Sinc filter F rectT (f ) T 2 T t f 1 : jtj ≤ T =2 1 rectT (t) = F rect (f ) = sin(πfT ) = T sinc(fT ) 0 : jtj > T =2 T πf Gaussian g(t) Gaussian G(f ) t f 2 1 2 g(t) = e−π·t with σ2 = G(f ) = e−π·f = g(f ) t 2π Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 14 / 50 Signal-Independent Unitary Transforms / Discrete Fourier Transform Derivation of Discrete Fourier Transform: (1) Sampling of Signal continuous signal s(t) Fourier transform S(f ) t f × (multiplication) ∗ (convolution) Dirac comb ш0(t) Dirac comb Ш0(f ) t f = = sampled signal s(t) ш0(t) Fourier transform S(f )∗Ш0(f ) t f Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 15 / 50 Signal-Independent Unitary Transforms / Discrete Fourier Transform Derivation of Discrete Fourier Transform: (2) Time Restriction sampled signal s(t) ш0(t) Fourier transform S(f )∗Ш0(f ) t f × (multiplication) ∗ (convolution) rectangular window r(t) Sinc filter R(f ) t f = = finite sampled signal s(t) ш0(t) r(t) Fourier transform S(f )∗Ш0(f )∗R(f ) t f Heiko Schwarz (Freie Universität Berlin) — Data Compression: Transform Coding in Practice 16 / 50 Signal-Independent Unitary Transforms / Discrete Fourier Transform Derivation of Discrete Fourier Transform: (3) Sampling of Spectrum finite sampled signal s(t) ш0(t) r(t) Fourier transform S(f )∗Ш0(f )∗R(f ) t f ∗ (convolution) × (multiplication) Dirac comb ш1(t) Dirac comb Ш1(f ) t f = = periodic sampled signal s(t) ш0(t) r(t) ∗ ш1(t) Fourier transform [S(f )∗Ш0(f )∗R(f )] Ш1(f ) t f Heiko Schwarz (Freie Universität Berlin) — Data Compression: