03.scalar Quantization and Prediction
03.scalar Quantization and Prediction
Outline
• Definitions
• Uniform quantization
• Optimal scalar quantization
• Predictive coding / DPCM
• Continuous source:
• The outcome of each random variable could be any real number
• Infinite number of bits required!
• Some error (distortion) must be tolerated to represent symbols with a finite number
of bits
• Scalar quantization:
• Discretize a scalar random variable
• Vector quantization:
• Discretize a vector random variable, e.g., a block of pixels at the same time
Quantization error
𝑒 =𝑦−𝑥 =𝑞 𝑥 −𝑥
• Originally PCM (Pulse Code Modulation) encoders were designed for the
digital transmission of telephone signals, and they included:
• sampling of the continuous time signal
• quantization of the samples
• and digital modulation
𝑎𝑘+1 − 𝑎𝑘 = Δ, for 𝑘 = 2, 3, … , 𝑀 − 1
• the reproduction levels in the granular region are the midpoints of the corresponding
quantization regions, i.e.:
1 Δ
𝑦𝑘 = 𝑎𝑘+1 + 𝑎𝑘 = 𝑎𝑘 + , for 𝑘 = 2, 3, … , 𝑀 − 1
2 2
Δ Δ
and the reproduction levels in the overload region are 𝑦1 = 𝑎2 − and 𝑦𝑀 = 𝑎𝑀 +
2 2
• Δ is called the quantization step of the uniform quantizer
Scalar quantization and prediction
MN907 – Multimedia Compression
2
𝑑 𝑥, 𝑦 = 𝑦 − 𝑥 = 𝑒2
+∞
𝔼 𝑒 2 = න 𝑞 𝑥 − 𝑥 2 𝑓𝑥 𝑥 𝑑𝑥
−∞
𝜎𝑒2 = 𝔼 𝑒 2 = න 𝑞 𝑥 −𝑥 2
𝑓𝑥 𝑥 𝑑𝑥 = න 𝑦𝑘 − 𝑥 2
𝑓𝑥 𝑥 𝑑𝑥
𝑘=1 𝑎𝑘 𝑘=1 𝑎𝑘
𝑀 𝑎𝑘+1
1
𝜎𝑒2 = න 𝑥 − 𝑦𝑘 2 𝑑𝑥
𝑀Δ
𝑘=1 𝑎𝑘 The quantization
Δ error is also a
𝑀 +
2 uniform random
1
= න 𝑒 2 𝑑𝑒 variable on the
𝑀Δ
𝑘=1 Δ Δ Δ
−
2 interval − , +
2 2
1 Δ3 Δ2
= 𝑀 =
𝑀Δ 12 12
• Let’s assume that the output symbols of the quantizer are coded with a
fixed length code with a bit rate 𝑅 = log 2 𝑀
• The error quantizer variance can be written as:
2 2
2
Δ 𝜎𝑥
𝜎𝑒 = = 2 = 𝜎𝑥2 2−2𝑅
12 𝑀
2 2
2
Δ 𝜎𝑥
𝜎𝑒 = = 2 = 𝜎𝑥2 2−2𝑅
12 𝑀
𝜎𝑥2
𝑆𝑁𝑅 = 10 log10 2 = 10 log10 22𝑅 ≅ 6.02 𝑅
𝜎𝑒
i.e. the distortion decreases by 6 dB for each additional bit spent.
Optimal quantization
• Problem: given an input signal with p.d.f. 𝑓𝑥 , find the quantizer that
minimizes the quantization error for a given rate
• Solve the optimization problem:
𝑀 𝑎𝑘+1
Optimal quantization
• Solve the optimization problem: 𝑎𝑘+1
𝑀
𝑦𝑘−1 +𝑦𝑘
• 𝑎𝑘∗ = Nearest neighbor condition
2
𝑎
𝑘 𝑎+1 𝑥𝑓𝑥 𝑥 𝑑𝑥
𝑦𝑘∗ = 𝑘
𝑎 Centroid condition
𝑘 𝑎+1 𝑓𝑥 𝑥 𝑑𝑥
𝑘
Lloyd-Max algorithm
1. Choose an initial set of 𝑀 values for the reproduction levels 𝑦𝑘
2. Optimize the partition for the given levels using the nearest-neighbor
rule, obtaining the thresholds 𝑎𝑘
3. Optimize the set of reproduction levels for the partition found above
using the centroid criterion, obtainig a new set of 𝑦𝑘
4. Repeat steps 2 and 3 until convergence is achieved
1 3
with 𝜖𝑥2 𝜎𝑥2 = ℝ 𝑓𝑥 (𝑥)𝑑𝑥
12
• 𝜖𝑥2 is called the shape factor, as it depends only on the shape of the input
pdf
• Some example values for 𝜖𝑥2 :
• 1 for uniform distribution
• 4.5 for Laplacian distribution
3𝜋
• ≅ 2.721 for Gaussian distribution
2
𝑀 𝑎𝑘+1
Minimize 𝜎𝑒2 = σ𝑘=1 𝑎 𝑦𝑘 − 𝑥 2
𝑓𝑥 𝑥 𝑑𝑥
𝑘
𝑎𝑘+1
where 𝑝𝑘 = 𝑃 𝑥 ∈ 𝐼𝑘 = 𝑎 𝑓𝑥 𝑥 𝑑𝑥
𝑘
Scalar quantization and prediction
MN907 – Multimedia Compression
• At high rates and for smooth pdf, the uniform quantizer is optimal
Predictive coding
• Due to correlation, the prediction residual assumes small values with high
probability, thus has a smaller variance with respect to the source
𝜎𝑥2
𝐺𝐷𝑃𝐶𝑀 = 2
𝜎𝑑
𝜎𝑥2
𝐺𝐷𝑃𝐶𝑀 𝑑𝐵 = 10 log10 2
𝜎𝑑
𝜎𝑥2 𝜎𝑧2 1 1
𝐺𝐷𝑃𝐶𝑀 = 2= 2 2
=
𝜎𝑑 1 − 𝜌 𝜎𝑧 1 − 𝜌2