Quantization
Quantization
Yao Wang
Polytechnic University, Brooklyn, NY11201
http://eeweb.poly.edu/~yao
Outline
1
T=0.1
Q=0.25
0.5
-0.5
A2D_plot.m
-1
Q=(fmax-fmin)/L
Yellow dots indicate the partition levels (boundaries between separate quantization intervals)
Red dots indicate the reconstruction levels (middle of each interval)
1.2 fall between 0.75 and 1.5, and hence is quantized to 1.125
• Quantized sequence:
{1.125,-0.375,-0.375,0.375,1.125,1.125}
Q=0.25 Q=0.5
1.5 1.5
1 1
0.5 0.5
0 0
-0.5 -0.5
-1 -1
-1.5 -1.5
0 0.2 0.4 0 0.2 0.4
demo_sampling_quant.m
0.02
original at 16 bit
Original 0.015 quantized at 4 bit
Mozart.wav
0.01
0.005
Quantized
Mozart_q16.wav
0
-0.005
-0.01
2 2.002 2.004 2.006 2.008 2.01 2.012 2.014 2.016 2.018 2.02
4
x 10
0.02 0.02
original at 16 bit
quantized at 6 bit
original at 16 bit
0.015 quantized at 4 bit 0.015
0.01 0.01
0.005 0.005
0 0
-0.005 -0.005
-0.01 -0.01
2 2.002 2.004 2.006 2.008 2.01 2.012 2.014 2.016 2.018 2.02 2 2.002 2.004 2.006 2.008 2.01 2.012 2.014 2.016 2.018 2.02
4 4
x 10 x 10
Quantized Quantized
Mozart_q16.wav Mozart_q64.wav
Quantization levels : L
Partition values : bl
Partition regions : Bl = [bl −1 , bl )
Reconstruction values : g l
Quantized Index : Qi ( f ) = l , if f ∈ Bl
Quantizer value : Q( f ) = g l , if f ∈ Bl
Q ( f ) = gl , if f ∈ Bl
y =F [ x ]
|x|
log 1+µ
X max
= X max .sign[ x]
log[1 + µ ]
x =F −1[ y ]
X log(X 1+ µ ) y
= max 10 max − 1 sign(y)
µ
• Indirect Method:
– Instead of applying the above computation to each sample,
one can pre-design a quantization table (storing the partition
and reconstruction levels) using the above procedure. The
actual quantization process can then be done by a simple
table look-up.
– Applicable both for uniform and non-uniform quantizers
– How to find the partition and reconstruction levels for mu-law
quantizer
• Apply inverse mu-law mapping to the partition and
reconstruction levels of the uniform quantizer for y.
• Note that the mu-law formula is designed so that if x ranges
from (-x_max, x_max), then y also has the same range.
x =F −1[ y ]
Inverse µ-law
X log(X 1+ µ ) y
= max 10 max − 1 sign(y)
µ
-0.77 -0.13 0.13 0.77
1 1
0.5 0.5
0 0
-0.5 -0.5
-1 -1
-1.5 -1.5
0 0.2 0.4 0 0.2 0.4
0.01 0.01
0 0
Mozart_q32.wav Mozart_q64.wav
-0.01 -0.01
2 2.01 2.02 2 2.01 2.02
4 4
x 10 x 10
0.02 0.02
q32µ4 q32µ16
0.01 0.01
0
Mozart_q32_m4.wav 0
Mozart_q32_m16.wav
-0.01 -0.01
2 2.01 2.02 2 2.01 2.02
4 4
x 10 x 10
Evaluation of Quantizer Performance
(
SNR(dB) : SNR = 10 log10 σ x2 / σ q2 )
where N is the number of samples in the sequence.
1
σ x2 is the variance of the original signal, σ z2 = ∑ ( x(n)) 2
N n
codewords 00 01 10 11
x =F −1[ y ]
Inverse µ-law
X log(X 1+ µ ) y
= max 10 max − 1 sign(y)
codewords 00 01 10 11 µ
-0.77 -0.13 0.13 0.77
0 if x < 0.5
xˆ =
1 if x ≥ 0.5
0
-0.5
0 10 20 30 40 50 60