Anda di halaman 1dari 18

Chapter 5: Lossy Compression

Algorithms
Multimedia Systems (ITEC 305)
Dr. Abir Akram EL ABED
Introduction
Lossless compression algorithms do not deliver compression ratios that are
high enough
Most multimedia compression algorithms are lossy
What is lossy compression?
Compressed data is not the same as the original data, but a close
approximation of it
Yields a much higher compression ratio than that of lossless compression
2
A general
compression
system
model
Lossy Compression: Source Coding
Techniques
3
Source coding is based on changing the content of the original signal
Compression rates may be high but at a price of loss of information
Good compression rates may be achieved with source encoding with
(occasionally) lossless or (mostly) little perceivable loss of information

There are three broad methods that exist:
1) Transform Coding
Transformation from one domain: time (e.g. 1D audio,video:2D imagery
over time) or Spatial (e.g. 2D imagery) domain to the frequency domain via
Discrete Cosine Transform (DCT) Heart of JPEG and MPEG Video,
MPEG Audio
Fourier Transform (FT) MPEG Audio

2) Differential Encoding

3) Vector Quantisation
Distortion Measures
4
The three most commonly used distortion measures in image compression
are:

1) Mean Square Error (MSE)
2




where x
n
, y
n
, and N are the input data sequence, reconstructed data
sequence, and length of the data sequence respectively

2) Signal to noise ratio (SNR), in decibel units (dB),



where is the average square value of the original data sequence
and is the MSE

3) Peak signal to noise ratio (PSNR),

2 2
1
1
( )
N
n n
n
x y
N
o
=
=

2
x
o
2
d
o
2
10 2
10log
x
d
SNR
o
o
=
2
10 2
10log
peak
d
x
PSNR
o
=
Quantization
5
Reduce the number of distinct output values to a much
smaller set

Main source of the loss in lossy compression

Three different forms of quantization:
1) Uniform: midrise and midtread quantizers

2) Nonuniform: companded quantizer

3) Vector Quantization

1) Uniform Scalar
Quantization
6
A uniform scalar quantizer partitions the domain of
input values into equally spaced intervals, except
possibly at the two outer intervals

Output or reconstruction value to each interval =
midpoint of the interval
Length of each interval = step size ()

Two types of uniform scalar quantizers:

1) Midrise quantizers have even number of output
levels
= 1 =>

= .

2) Midtread quantizers have odd number of output
levels, including zero as one of them
= 1 =>

= +.

Midrise quantizers
Midtread quantizers
1) Uniform Scalar Quantization
7
A uniform scalar quantizer partitions the domain of
input values into equally spaced intervals, except
possibly at the two outer intervals

Output or reconstruction value to each interval =
midpoint of the interval
Length of each interval = step size ()

Two types of uniform scalar quantizers:

1) Midrise quantizers have even number of output
levels
= 1 =>

= .

2) Midtread quantizers have odd number of output
levels, including zero as one of them
= 1 =>

= +.

Midrise quantizers
Midtread quantizers
2) Companded quantizer
8
Companded quantization is nonlinear

A compander consists of a compressor function G, a
uniform quantizer, and an expander function G
1


The two commonly used companders are the -law and A-
law companders

Companded
quantization
3) Vector Quantization (VQ)
9
According to Shannons original work on information theory, any compression
system performs better if it operates on vectors or groups of samples rather than
individual symbols or samples
Form vectors of input samples by simply concatenating a number of consecutive
samples into a single vector
Instead of single reconstruction values as in scalar quantization, in VQ code
vectors with n components are used
A collection of these code vectors form the codebook
Basic vector
quantization
procedure
Vector Quantisation
Encoding/Decoding
10
Search Engine:
Group (Cluster) data into vectors
Find closest code vectors
Vector Quantisation Image Coding
Example
11
Consider Vectors of 2x2 blocks, and only allow 8 codes in
table
9 vector blocks present in above
9 vector blocks, so only one has to be vector quantised
here
Resulting code book for above image
A small block of
images and intensity
values
Transform Coding
12
The rationale behind transform coding:

If Y is the result of a linear transform T of the input vector X in
such a way that the components of Y are much less
correlated, then Y can be coded more efficiently than X.

If most information is accurately described by the first few
components of a transformed vector, then the remaining
components can be coarsely quantized, or even set to
zero, with little signal distortion.

Discrete Cosine Transform (DCT) will be studied first
Spatial Frequency and DCT
13
Spatial frequency indicates how many times pixel values change across an
image block
DCT formalizes this notion with a measure of how much the image contents
change in correspondence to the number of cycles of a cosine wave per block
Role of DCT is to decompose the original signal into its DC and AC
components
Role of IDCT is to reconstruct (re-compose) the signal

Definition of DCT:
Given an input function f(i, j) over two integer variables i and j (a piece of an
image)
2D DCT transforms it into a new function F(u, v), with integer u and v running
over the same range as i and j. The general definition of the transform is:



i, u = 0, 1, . . . ,M 1; j, v = 0, 1, . . . ,N 1; and constants C(u) and C(v) are
determined by




1 1
0 0
2 ( ) ( ) (2 1) (2 1)
( , ) cos cos ( , )
2 2
M N
i j
C u C v i u j v
F u v f i j
M N
MN
t t

= =
+ +
=

2
0,
( ) 2
1 .
if
C
otherwise


=
=

2D Discrete Cosine Transform (2D DCT)





where i, j, u, v = 0, 1, . . . , 7

2D Inverse Discrete Cosine Transform (2D
IDCT)

The inverse function is almost the same, with the roles of f(i, j)
and F(u, v) reversed, except that now C(u)C(v) must stand inside
the sums:




where i, j, u, v = 0, 1, . . . , 7. 14
7 7
0 0
( ) ( ) (2 1) (2 1)
( , ) cos cos ( , )
4 16 16
i j
C u C v i u j v
F u v f i j
t t
= =
+ +
=

7 7
0 0
( ) ( ) (2 1) (2 1)
( , ) cos cos ( , )
4 16 16
u v
C u C v i u j v
f i j F u v
t t
= =
+ +
=

1D Discrete Cosine Transform (1D DCT):






where i = 0, 1, . . . , 7, u = 0, 1, . . . , 7.


1D Inverse Discrete Cosine Transform (1D
IDCT):



where i = 0, 1, . . . , 7, u = 0, 1, . . . , 7.
15
7
0
( ) (2 1)
( ) cos ( )
2 16
i
C u i u
F u f i
t
=
+
=

7
0
( ) (2 1)
( ) cos ( )
2 16
u
C u i u
f i F u
t
=
+
=

1
D

D
C
T

b
a
s
i
s

f
u
n
c
t
i
o
n
s

16
Graphical Illustration of
8 8 2D DCT basis
17
E
x
a
m
p
l
e
s

o
f

1
D

D
i
s
c
r
e
t
e

C
o
s
i
n
e

T
r
a
n
s
f
o
r
m
:

(
a
)

A

D
C

s
i
g
n
a
l

f
1
(
i
)
,

(
b
)

A
n

A
C

s
i
g
n
a
l

f
2
(
i
)
,

(
c
)

f
3
(
i
)

=

f
1
(
i
)
+
f
2
(
i
)
,

a
n
d

(
d
)

a
n

a
r
b
i
t
r
a
r
y

s
i
g
n
a
l

f
(
i
)
.
.

18
(a)
(b)
(c)
(d)