Lecture 6-Lossy Image Compression Techniques
Lecture 6-Lossy Image Compression Techniques
Sudipta Mahapatra
1
Lossy Image Compression
Theory of Quantization
2
Outline
• Quantization
• Scalar and Vector Quantization
• Uniform and non-uniform quantization
• Rate-Distortion Function and the Source
Coding Theorem
3
Why to go for Lossy Compression
5
Quantization
• The process of representing a set of values with
a much smaller set.
• Example: Set of numbers between -10 to 10 .
• Represent using the nearest integer.
• [-10 to 10] is mapped to [-10, …, 0, …, 10].
• Result in loss of information.
6
Quantization
– Encoder mapping – involves generating a definite
codeword for all the symbols that map into a
particular interval.
– Decoder – Generates a reconstructed value for every
codeword generated by the encoder.
Input Code Output
Codes 000 -3.5
001 -2.5
010 -1.5
011 -0.5
100 0.5
000 001 010 011 100 101 110 111 101 1.5
110 2.5
111 3.5
7
Quantizer Input Output mapping
Uniform Quantisation: All the intervals are of the same size; equal to
the spacing of decision boundaries, ) .
1. Midrise Quantizer (# of intervals, L is odd; does not include zero).
2. Midtread quantizer (L is even; includes zero as an o/p level, useful in control
systems and audio coding schemes-need to represent silence intervals )
(1) (2)
8
9
10
Uniform quantization of a
Uniformly distributed Source
# levels=M; Input uniformly distributed in [-Xmax,Xmin].
X max
M
Distortion (mean squared quantization error or msqe),
2
M / 2 i
2i 1 1
2 x
2
dx 2 / 12.
1
( i 1)
2 2 X max
(2)
11
Quantization error
Uniform quantization of a
Uniformly distributed Source
Input lies in the interval [-Xmax, Xmax];
Quantization error les in the interval [- /2, /2]; As the input is
uniform, the error is also uniform.
Thus, msqe=the second moment
of a random variable uniformly
distributed in the interval and is
given by
2 /2
q (1 / ) q 2 dq 2 / 12. Quantization error
/2
2
Signal power, q (2 X max ) 2 / 12 ? As =2Xmax/M,
2 2
SNR(dB) 10 log10 ( s / q ) 6.02 log 2 M dB 6.02ndB.
12
Quantizer design – Rate & Distortion
• Although quantization is a simple process, the
design of the quantizer greatly influences on
the amount of compression and the loss
incurred.
• Encoder design involves construction of
intervals.
• Decoder design involves selection of
reconstruction values.
• The encoder-decoder pair is called a quantizer.
13
Rate & Distortion
● Assume that the input x is modelled by a random
variable X with a pdf fx(x).
● # of intervals=M; the end-point of the intervals are
known as the decision boundaries.
● Decision boundaries: bi i 0
M
● Reconstruction levels: yi i 1
M
19
Quantizer Performance
• Determined by its distortion measure.
• Let be a continuous-valued variable and sˆ Q ( s )
be the quantized variable.
• Quantization error, ŝ
• Distortion, D = E[] ŝ
• We should design and so that the distortion D
should be minimized.
20
• Two different approaches for optimal quantizer
design namely
● Lloyd-Max Quantizers
● Entropy-constrained Quantizers
21
• Minimize D = E[] w.r.t and , subjected to the
constraint that the source entropy, is a constant; L
may vary.
22
• In fixed-length coding, the rate R for quantizers
with L states is given by
23
Design of Lloyd-Max Quantizers
24
Design of Lloyd-Max Quantizers
di
s P(s) r r
ri di 1
, 1 i L, d i
i i 1
di , 1 i L
2
P ( s )
di 1
27
• Lloyd-Max quantizers perform coarser quantization
wherever the pdf is low.
- =θ
0 otherwise
30
Fig: Typical Quantizer Characteristics for L even (=8)
31
Fig: Typical Quantizer Characteristics for L odd (=7)
32
Rate-Distortion Function
• Shannon’s Coding Theorem on noiseless channels
considers the channel, as well as the encoding
process to be lossless.
34
R-D Function
36
Source Coding Theorem
• There exists a mapping from the source symbols
to code words such that for a given distortion D,
R(D) bits/symbol are sufficient to enable source
reconstruction with an average distortion
arbitrarily close to D.
37
Example
• Lena Colour Image Quantized image (2-bit)
Original image Scalar Quantized Image
38
What you should be able to do at this point:
1. Define quantization.
2. Distinguish between scalar and vector quantization.
3. Distinguish between uniform and non-uniform quantization.
4. Define quantization error and optimum scalar quantizer design
criteria.
5. Design a Lloyd-Max quantizer.
6. Define rate-distortion function.
7. State the source coding theorem.
8. Determine the minimum possible rate for a given SNR to encode
a quantized Gaussian signal.
39
Assignments