CPE 531
DIGITAL SIGNAL
PROCESSING
LECTURE 3
Quantization and Encoding
DEPARTMENT OF COMPUTER ENGINEERING
UNIVERSITY OF ILORIN
Review of Analogue-to-digital conversion (ADC)
Focus in
this lecture
Figure 3.1 Block diagram of ADC
Filtering and Sampling: the analog signal is converted into a discrete-time continuous amplitude signal
through sampling (using a sample and hold (S/H) circuit) after being filtered (anti-aliasing – to be discussed
later).
Quantizing: the amplitude of each signal sample is quantized into one of the 2𝐵 levels, where B is the
number of bits used to represent a sample in the ADC.
Encoding: The discrete amplitude levels are encoded into distinct binary Words of length B bits.
Introduction to Quantizing
• After sampling, which converts a time-varying voltage signal into a
discrete-time signal quantization replaces each real number with an
approximation from a finite set of discrete values.
• Most commonly, these discrete values are represented as fixed-
point words. Though any number of quantization levels is possible,
common word-lengths are 8-bit (256 levels), 16-bit (65,536 levels)
and 24-bit (16.8 million levels).
• Quantization is representing the sampled values of the amplitude by
a finite set of levels, which means converting a continuous-
amplitude sample into a discrete-time signal. A device or
algorithmic function that performs quantization is called a quantizer
Figure 3.2 Examples of quantization
Illustration of Quantizing
Analog signal before undergoing sampling and quantizing Quantizing the analog signal after sampling
Figure 3.3 Illustrating quantizing
Quantization example
Resultant quantized signal
which is the digital form for
the given analog signal
Figure 3.4: This is also called as Stair-case waveform, in accordance with its shape
Quantization levels
• Both sampling and quantization result in the loss of information. The quality of a quantizer
output depends upon the number of quantization levels used. The discrete amplitudes of the
quantized output are called as representation levels or reconstruction levels. The spacing
between the two adjacent representation levels is called a quantum or step-size.
• Quantizing a sequence of numbers produces a sequence of quantization errors which is
sometimes modeled as an additive random signal called quantization noise because of its
stochastic behavior. The more levels a quantizer uses, the lower is its quantization noise
power.
Mathematical representation of
Quantization levels
Suppose the value of X[n] sampled values ranges over the interval 𝑋𝑚𝑖𝑛 , 𝑋𝑚𝑎𝑥 . The spacing
between adjacent quantization levels or step size (ADC resolution) is:
𝑋𝑚𝑎𝑥 − 𝑋𝑚𝑖𝑛 𝑋𝑚𝑎𝑥 − 𝑋𝑚𝑖𝑛
∆= =
𝐿 2𝑁
Where L = quantization levels
N = binary bits used to represent the value of X[n]
The quantization level at any point q, denoted 𝑋𝑞 can be expressed as:
𝑋𝑞 = 𝑋𝑚𝑖𝑛 + 𝑖 ∆, 𝑤ℎ𝑒𝑟𝑒 𝑖 = 0,1, … , 𝐿 − 1
𝑋 − 𝑋𝑚𝑖𝑛
𝑖≈
∆
Quantization levels and errors
Quantization
errors
(approximated)
Figure 3.5 Quantization of two bits for sampled sinusoidal signal, Thin gray line-
, quantization level, thick black line-, sampled signal and blue circles marks-o, quantized signal
Quantization noise
The simplest way to quantize a signal is to choose the digital amplitude value closest to the
original analog amplitude.
Figure 3.6 This example shows the original analog signal (green), the quantized signal (black dots), the signal
reconstructed from the quantized signal (yellow) and the difference between the original signal and the reconstructed
signal (red).
Explanation of Quantization noise
As seen in Figure 3.6, The difference between the original signal
and the reconstructed signal is the quantization error and, in this
simple quantization scheme, is a deterministic function of the input
signal.
The difference between an input value and its quantized value
(such as round-off error) is referred to as quantization error which
constitutes quantization noise.
Types of Quantization
There are two types of Quantization:
1.Uniform Quantization and 2. Non-uniform Quantization.
Uniform Quantization: The type of quantization in which the
quantization levels are uniformly spaced
Non-uniform Quantization: The type of quantization in which the
quantization levels are unequal and mostly the relation between
them is logarithmic, is termed as a.
Forms of Uniform Quantization
There are two forms of uniform quantization:
1.Mid-Rise form and 2. Mid-Tread form.
Figure 3.7 : a) Mid-Rise form b) Mid-Tread form
Comparing the Forms of Uniform
Quantization
Mid-Rise Uniform Quantization Mid-Tread Uniform
Quantization
The Mid-Rise form is so called The Mid-tread form is so called
because the origin lies in the because the origin lies in the
middle of a raising part of the middle of a tread of the stair-case
stair-case like graph. like graph.
The quantization levels in this The quantization levels in this
type are even in number. type are odd in number.
Both the mid-rise and mid-tread type of uniform quantizers are
symmetric about the origin.
Practical application of quantization:
Pulse code modulation (PCM)
Pulse-code modulation (PCM) is a method used to digitally represent
sampled analog signals. It is the standard form of digital audio in computers, compact
discs, digital telephony and other digital audio applications.
In a PCM stream, the amplitude of the analog signal is sampled at uniform intervals,
and each sample is quantized to the nearest value within a range of digital steps.
Figure 3.8 Identifying PCM under various modulation techniques
Companding in PCM:
The word Companding is a combination of Compressing and
Expanding, which means that it does both.
This is a non-linear technique used in PCM which compresses
the data at the transmitter and expands the same data at the
receiver. The effects of noise and crosstalk are reduced by
using this technique.
Types of Companding in PCM:
There are two types of Companding techniques:
A-law Companding Technique µ-law Companding Technique
Uniform quantization is achieved at A = 1, Uniform quantization is achieved at µ = 0,
where the characteristic curve is linear and where the characteristic curve is linear and
no compression is done. no compression is done.
A-law has mid-rise at the origin. Hence, it µ-law has mid-tread at the origin. Hence, it
contains a non-zero value. contains a zero value.
A-law companding is used for PCM µ-law companding is used for speech and
telephone systems. music signals.
Illustration of PCM:
Assign
closest level
Sample and hold
Figure 3.9 Illustration of PCM
Class exercise for PCM:
Using a 2-bit coding resolution in this 4-level quantization scheme, try
to assign codes to the quantized signal
Figure 3.10 Exercise for coding PCM
Class exercise for PCM:
Time to work on the class exercise
Solution to class exercise
Figure 3.11 Resulting code for the PCM Illustration
Illustration of PCM: comparing
quantization levels
Figure 3.12 a) Quantized signal with low quantization levels b) Quantized signal with high quantization levels
As the number of quantization levels is increased, the quantization error is
reduced and the quantized signal gets more similar to the original signal
References
https://slideplayer.com/slide/13774234/
https://www.tutorialspoint.com/digital_communication/digital_communication_qua
ntization.htm#
Castillo, P. C. A., Brennan, M. J., de Almeida, F. C. L., de Lima, F. K., de Sousa Obata, D.
H., & Paschoalini, A. T. An Investigation Into The Effects Of Signal Distortion On The
Accuracy Of Time Delay Estimation For Leak Detection In Buried Plastic Water Pipes.
https://en.wikipedia.org/wiki/Pulse-code_modulation