# Lossy Compression - Transforms

Document Sample

```					IMAGE COMPRESSION AND PACKET VIDEO

Lossy Compression - Transforms

Lecture 5 Notes

1

IMAGE COMPRESSION AND PACKET VIDEO

Transform Coding
s   Why transform Coding?
– Purpose of transformation is to convert the data into a
form where compression is easier
s   Transformation yields energy compaction
– Facilitates reduction of irrelevant information
s   The transform coefficients can now be quantized
according to their statistical properties.
– This transformation will reduce the correlation between
the pixels (decorrelate X, the transform coefficients are
assumed to be completely decorrelated (Redundancy
Reduction).                                             2
IMAGE COMPRESSION AND PACKET VIDEO

How Do Transforms Work?

s   Basic Fourier Analysis
– Waveform is composed of simpler sinusoidal
functions
– Providing enough of the waveform is sampled,
component frequencies can be determined that
approximate the original waveform
s   The component frequencies are the basis of
the original waveform.
– Basis waveform changes with each type of
transform.                                         3

IMAGE COMPRESSION AND PACKET VIDEO

Fourier Series

s   Any periodic signal of period T can be
expanded into a trigonometric series of sine
and cosine functions as long as it obeys the
following:
– f(t) has finite number of maxima and minima
within T
– f(t) has finite number of discontinuities within
T, and
T
– The following is necessary: ∫0 f (t ) dt < ∞
4
IMAGE COMPRESSION AND PACKET VIDEO

What Does a Basis Imply?
s   A data set can be approximated by a combination of
simpler, well defined waveforms
s   Not all of the basis waveforms are important to image or
data reconstruction
small number of waveforms.
– Not all basis sets are equal in terms of compression
s   Analysis of the waveform is easier for some basis sets
than others
– DCT and Wavelets are computationally easier than Fourier and
KLT
– KLT is superior since each basis set is designed for the data
under analysis.                                               5

IMAGE COMPRESSION AND PACKET VIDEO

Examples Of Transform Basis

s   Fourier Transform Basis Vector
1                  1                 1                  1
0                  0                 0                  0
0

1

2

3

-1                 -1                -1                 -1
0    5             0   5             0    5             0   5
Real Basis        Real Basis         Real Basis        Real Basis
1                  1                 1                  1
0                  0                 0                  0
4

5

6

7

-1                 -1                -1                 -1
0    5             0   5             0    5             0   5
Real Basis        Real Basis         Real Basis        Real Basis
1                  1                 1                  1
0                  0                 0                  0
0

1

2

3

-1                 -1                -1                 -1
0    5             0   5             0    5             0   5
Img Basis         Img Basis          Img Basis         Img Basis
1                  1                 1                  1
0                  0                 0                  0
4

5

6

7

-1                 -1                -1                 -1
0    5             0   5             0    5             0   5
Img Basis         Img Basis          Img Basis         Img Basis

6
IMAGE COMPRESSION AND PACKET VIDEO

Examples Of Transform Basis

s   KLT Basis Vector

7

IMAGE COMPRESSION AND PACKET VIDEO

Examples Of Transform Basis

s   DCT Basis Vector

8
IMAGE COMPRESSION AND PACKET VIDEO

Examples Of Transform Basis

s   WHT Basis Vector

9

IMAGE COMPRESSION AND PACKET VIDEO

Energy Compaction

s   Most of the energy are concentrated in the
low frequency coefficients.
N −1
∑      F (u) for 1 − D case.
2
Energy =
u=0

s   Transform coding is relatively resistant to
channel errors,
– if one of the high frequency coefficients is
changed due to channel noise, the error will be
distributed when inverse transform is applied.
10
IMAGE COMPRESSION AND PACKET VIDEO

How Transform Coders Work

s   Divide the image into 2x1 blocks
– Typical transforms are 8x8 or 16x16

r  x1
x= 
 x2 

11

IMAGE COMPRESSION AND PACKET VIDEO

Joint Probability Distribution

s   Observe the
Joint
Probability
Distribution or
the Joint
Histogram

12
IMAGE COMPRESSION AND PACKET VIDEO

Correlated Pixels

F’
s   Since adjacent pixels x1                  x2

and x2 are highly             y2               σ y1   y1
σ x2
correlated the joint
probability p(x1 , x2) is          σ y2
x1
concentrated around the                        σ x1
line FF’ and variances
are equal σ x1 = σ x2
because they are the                           σ x1 = σ x2
samples of the same
F

image                                                           13

IMAGE COMPRESSION AND PACKET VIDEO

Pixel Correlation Map
s From Lena.tif
s Xave1 =
99.962341,
Xvar1 =
2774.619004
s Xave2 =
100.145386,
Xvar2 =
2761.542095
14
IMAGE COMPRESSION AND PACKET VIDEO

Rotated Pixels
s   Rotated 45
degrees
s   yave1 =
141.497531,
yvar1 =
5365.715541
s   yave2 =
0.129432, yvar2
= 170.445558

15

IMAGE COMPRESSION AND PACKET VIDEO

Karhunen-Loeve Transform (KLT)

s   It is the optimum transform in an energy-packing
sense.
– i.e., if a mean squared error (energy) criterion is
employed.
s   However it is image-dependent, requires
estimation of the image covariance matrix, and it
can not be implemented by a fast algorithm
– takes O(N2) operations to transform a 1-D, N-point
data
16
IMAGE COMPRESSION AND PACKET VIDEO

Discrete Fourier Transform (DFT)

s Well-known for its connection to spectral
analysis and filtering.
s Extensive study done on its fast
implementation (O(Nlog2N) for N-point DFT).
s Has the disadvantage of storage and
manipulation of complex quantities and
creation of spurious spectral components due to
the assumed periodicity of image blocks.

17

IMAGE COMPRESSION AND PACKET VIDEO

Discrete Cosine Transform (DCT)

s For conventional image data having
reasonably high inter-element correlation,
its performance is virtually
indistinguishable from KLT.
s Avoids the generation of the spurious
spectral components which is a problem
with DFT and has a fast implementation
which avoids complex algebra.
18
IMAGE COMPRESSION AND PACKET VIDEO

s   Although far from optimum in an energy-
packing sense for typical imagery, its
simple implementation (basis functions are
either -1 or +1) has made it widely popular.
subtracts
– Use of high speed signal processing has
reduced its use due to improvements with DCT.

19

IMAGE COMPRESSION AND PACKET VIDEO

Haar Transform

s Very fast transform.
s Useful in feature extraction, image coding,
and image analysis problems
s Energy Compaction is fair
s Example of a simple wavelet
– Used in StSciI HCOMPRESS program for
astronomical data.

20
IMAGE COMPRESSION AND PACKET VIDEO

Karhunen-Loeve Transform (KLT)

s The KLT basis functions are the eigenvectors of
the covariance matrix R
s Consider an image partitioned into blocks
(subimage)
– Each block is represented by the vector b of size N
s   The Covariance Matrix is given by:
[                Τ
R N × N = E (b − µb )(b − µb )   ]
N×N

21

IMAGE COMPRESSION AND PACKET VIDEO

Karhunen-Loeve Transform (KLT)

s If eigenvectors of R are arranged according
to decreasing eigenvalues (variance) then
we get a set of basis functions
s The KLT is optimal in the sense of
decorrelating and energy-packing.
– The plot on the next page compares Normalized
Mean Squared Error versus number of
coefficients retained for various transforms.

22
IMAGE COMPRESSION AND PACKET VIDEO
Truncation
Error For Various Transforms

23

IMAGE COMPRESSION AND PACKET VIDEO

Basis Image - Cosine Transform
s   Cosine Transform comes from the basis image:
         
cos πn  cos πm m, n ≥ 0
km kn        x         y
Ψmn ( x, y ) =                           
XY       X  Y

s   where:
 1 i=0
ki = 
 2 i>0

24
IMAGE COMPRESSION AND PACKET VIDEO

Basis Image - Cosine Transform

s The         basic Cosine Transform is:
F ( u, v ) =
4 C ( u ) C ( v ) n −1 n −1               (2 j + 1)uπ   (2 k + 1)vπ 
∑ ∑      f ( j , k ) cos              cos          
n2     j =0 k =0                      2n            2n     

s   where:
 1
                     for w = 0
C ( w) =  2
 1
           for w = 1,2,K , N − 1

25

IMAGE COMPRESSION AND PACKET VIDEO

Inverse Cosine Transform

s The inverse              cosine transform is defined as:
f ( j, k ) =
n −1 n −1                                (2 j + 1)uπ  (2 k + 1)vπ 
∑ ∑ C (u)C (v ) F (u, v ) cos                         cos         
u=0 v=0                                       2n           2n     

s   where:
 1
                     for w = 0
C ( w) =  2
 1
          for w = 1,2,K , N − 1

26
IMAGE COMPRESSION AND PACKET VIDEO

Basis Image - Cosine Transform

0      1    2   3    4 5      6        7
0
1
2
3
4
5
6
7
27

IMAGE COMPRESSION AND PACKET VIDEO

Transform Coding Block Diagram

Transmitter

Original
Image
f(j,k)                   F(u,v)                     F*(u,v)
Segment into                   Forward               Quantizer
nxn blocks                     transform             and Coder
Channel

Channel                                                                           Reconstructed
F*(u,v)                     f*(j,k)
Image
Inverse                   Combine
Decoder
Transform                 nxn blocks

28
IMAGE COMPRESSION AND PACKET VIDEO

Lossy Example: Transform Encoding
s Takes advantage of the ‘energy compaction’ that
occurs in the transform domain
s Operates on nxm sized blocks of pixel values (eg.
16x16 to 64x64)
s Uses threshold or zonal encoding of transform
coefficients
– Threshold: Coefficients below amplitude threshold are
– Zonal: Only coefficients with highest variance are kept
29

IMAGE COMPRESSION AND PACKET VIDEO

Lossy Example: Transform Encoding
TRANSMITTER

Zonal or
Transform       Threshold
Coding

DeCoding        Inverse
Transform

30
IMAGE COMPRESSION AND PACKET VIDEO

Pixel Transform Example
Original Pixels                                  Quantized Coefficients

55     55    109   109   109   109   109   109   75   -8   -6     -3    0     2     2     1
55     55    109   109   109   109   109   109   18   -7   -5     -2    0     1     2     1
55     55    109   109   109   109   109   109   0    0    0      0     0     0     0     0
55     55    109   109   109   109   109   109   -6   2    2      1     0     0     0     0
55     55    55    55    55    55    55    55    0    0    0      0     0     0     0     0
55     55    55    55    55    55    55    55    4    -1   -1     0     0     0     0     0
55     55    55    55    55    55    55    55    0    0    0      0     0     0     0     0
55     55    55    55    55    55    55    55    -3   1    1      0     0     0     0     0

Discrete Cosine Transform
Inverse DCT
Quantize
Unquantized Coefficients                        Reconstructed Pixels

602   -69   -50   -24   0     16    21    14    59   59    105   107   107   110   107   107
147   -63   -45   -22   0     15    19    12    56   59    105   108   107   108   106   107
0     0     0     0     0     0     0     0     56   62    105   110   107   107   106   107
-52   22    16    8     0     -5    -7    -4    57   64    100   108   107   106   103   102
0     0     0     0     0     0     0     0     54   50    61    58    55    56    59    60
34    -15   -11   5     0     3     4     3     55   52    56    56    54    55    57    55
0     0     0     0     0     0     0     0     55   55    56    57    54    54    56    55
-29   12    9     4     0     -3    -4    -2    52   55    56    59    54    53    56    55
31

IMAGE COMPRESSION AND PACKET VIDEO

Transform Coefficients Statistics

s The figures on the next pages give the
probability density for each coefficient for
an image, where the transform is done on
blocks of 8x8
s The DC coefficients has approximately a
Gaussian Distribution
s The higher Frequency Coefficients have a
Laplacian distribution with zero-mean
32
IMAGE COMPRESSION AND PACKET VIDEO

Histogram of First DCT Coefficient

33

IMAGE COMPRESSION AND PACKET VIDEO

Histogram of Second DCT Coefficient

34
IMAGE COMPRESSION AND PACKET VIDEO

Histogram for Third DCT Coefficient

35

IMAGE COMPRESSION AND PACKET VIDEO

Zonal Transform Compression

s Zonal Transform Compression implies that
we keep only those coefficients that are in
specific zones in the transform.
s Zonal Compression is also performed by
using different quantizers over the
transform coefficients
– 8-bit versus 7-bit, etc.

36
IMAGE COMPRESSION AND PACKET VIDEO

Zonal Transform Compression

s   Other strategies involve allocating bits to
the individual coefficients so to minimize
the total quantization error
– Assign bits in proportion to the log of the
coefficient variances.
– Variance at each coefficient location is found
by computing the corresponding coefficient
energy in each block, and then averaging over
all image blocks
37

IMAGE COMPRESSION AND PACKET VIDEO

Zonal Sampling
s   Discard components with smallest expected
energy:
u                               u
Keep                            Keep

v

transform Plane
s   Shape & Size of Zone may be changed
IMAGE COMPRESSION AND PACKET VIDEO

Zonal Sampling

s The low frequency coefficients are kept and the
s The idea behind zonal coding is that the human
eye can not perceive high frequencies (specially
diagonal) so it is possible to get rid of them.
– This depends on the number of high frequencies
– If a large number of high frequencies coefficients
are discarded, edges will be blurred.
39

IMAGE COMPRESSION AND PACKET VIDEO

Zonal Sampling

s Transform coefficients that are kept are
quantized since the dynamic range is now
changed.
s The discarding of coefficients is not an
efficient way of representing information

40
IMAGE COMPRESSION AND PACKET VIDEO

Zonal Coding

s   A better method would be not to discard as many
high frequency coefficients, but to quantize the low
frequency coefficients with 4-8 bit quantizers
because they carry the most of the energy or
information in the picture.
– The high frequency coefficients are quantized with
coarser quantizers of 0-3 bits.
– This process is called zonal coding and the array that
will provide the quantizer’s levels is given by the bit
assignment matrix.                                      41

IMAGE COMPRESSION AND PACKET VIDEO

Zonal Coding

s   Typical Bit assignment matrix for 8x8 array
(2.89 bits/pixel)
8     7     7      5     5      4     4      4
7     7     6      5     3      3     2      2
7     6     4      3     3      2     2      2
5     4     3      2     2      1     1      0
5     3     3      2     1      1     0      0
4     2     2      1     0      0     0      0
4     1     1      0     0      0     0      0
4     0     0      0     0      0     0      0
42
IMAGE COMPRESSION AND PACKET VIDEO

s   Since the information or the activity within
each block changes, it would be logical to
use several bit assignment matrices.
– If the subimage (subblock) has very little
information it is better to use a bit assignment
matrix with a small number of bits.
– If the subimage has a lot of information, it is
coded with a bit assignment matrix of large
number of bits.
43

IMAGE COMPRESSION AND PACKET VIDEO

s   Energy in the subimage is obtained by
totaling all the coefficients.
– This sum is used as a measure of energy or
activity in the image.

44
IMAGE COMPRESSION AND PACKET VIDEO

s Adaptive strategies will class a block into
one of several quantizer maps.
s Classification is based on the total variance
of the block (measure of block activity)
s This is a two pass process:
– Different classes are formed by computing
statistics of each block
– The statistics are used to select quantizers
which are applied during second pass
45

IMAGE COMPRESSION AND PACKET VIDEO

s Zonal compression can result in a fixed bit
rate output
s Variable bit rate approaches can take into
account the amount of buffer size when
selecting the quantizer.

46
IMAGE COMPRESSION AND PACKET VIDEO

Threshold Coding

s Retain Components which exceed threshold
s Transmit amplitude and location (run-length
coding) of components retained.
s Bit assignment and quantizer characteristic
as in zonal sampling

47

IMAGE COMPRESSION AND PACKET VIDEO

Threshold Sample Selection

s A threshold pass to zero out any coefficients
that fall below a limit could allow some
coefficients more bandwidth for
reconstruction
s Rather than send a map corresponding to
the few locations above the threshold, a run
length encoding can be used.

48
IMAGE COMPRESSION AND PACKET VIDEO

Threshold Sample Selection

s The value of L (the threshold) can vary
depending on buffer status or the busyness
of the blocks
s This technique is used in Scene Adaptive
Compression and JPEG

49

IMAGE COMPRESSION AND PACKET VIDEO

Transform Coding

s Problems with transform coders are,
computationally costly because of 2-D
transformation has to be performed.
s Adaptivity such as use several bit
assignment matrix will add to the
complexity of the system.

50
IMAGE COMPRESSION AND PACKET VIDEO

Quantization of Transform Coefficients
s An image is partitioned into subimages and each
subimage is transformed.
s The variances of the individual transform
coefficients are not the same.
– In fact in the case of DCT they are decreasing in a
zig-zag manner approximately.
s   The above fact could be exploited by allocating
different quantization bits to each coefficient in
accordance with the variance of the transform
coefficient.                                            51

IMAGE COMPRESSION AND PACKET VIDEO

Two-Dimensional Transform Coding

F               \$
F
Φ ∗ FΦ Τ
f                       Q

Transform        Quantizer

f\$                    \$
F
Φ Τ Θ ′Φ ∗
\$              Channel

52
IMAGE COMPRESSION AND PACKET VIDEO
Quantization
of the Transform Coefficients
s   Consider a subimage f and its transformation
F = Φf
s   Assuming the signal is discrete, each coefficient
is quantized; therefore the quantized coefficients
\$
are F
\$
– Also the reconstructed image is f
s   The error due to quantization is
e = f − f\$ = F − F
\$

53

IMAGE COMPRESSION AND PACKET VIDEO
Quantization
of the Transform Coefficients
s   The average mean square reconstruction
error (or distortion) is
N −1
σe =
2     1
N
{ }
E e Τe =
1
N
∑ σ τ2k
k =0
where   στ k
2
is the variance of the
quantization error in the kth spectral
(transform) coefficient.
s The goal is to assign different number of
bits to each coefficient
54
IMAGE COMPRESSION AND PACKET VIDEO
Quantization
of the Transform Coefficients
s Let us allocate Rk bits to the kth coefficient
N −1
with the constraint that the total bit is NR = ∑ Rk
k =0
and NR = R average bit rate.
N
s From the rate-distortion theory, the error
variance can be expressed as
σ τ k = θ ( Rk )σ k
2               2

where σ k is the spectral coefficient variance,
2

and θ ( Rk ) is the quantizer rate distortion
function for a unity variance input.                55

IMAGE COMPRESSION AND PACKET VIDEO
Quantization
of the Transform Coefficients
s   Typically,
θ (Rk ) = γ k 2 − 2 Rk
where γ k depends on the probability
density function of the signal and on the
quantizer.
s γ k = 1.0, 2.7 , 4.5 and 5.7 for Uniform,
Gaussian, Laplacian, and Gamma Pdfs,
respectively
56
IMAGE COMPRESSION AND PACKET VIDEO
Quantization
of the Transform Coefficients

s   We have to minimize
1   N −1
σe =
2
∑ σ τ2k
N   k =0

subject to the constraint that the total
number of bits is
N −1
NR =   ∑ Rk
k =0

57

IMAGE COMPRESSION AND PACKET VIDEO
Quantization
of the Transform Coefficients
s   We can do this using Lagrangian method where
the function that is minimized is given below.
– The function is differentiated with respect to Rk’s and
set to zero.
∂  1 N −1                            1 N −1  
 ∑       γ k σ k 2 − 2 Rk − λ  R − ∑ Rk   = 0
2
∂Rk  N k = 0                          N k =0  
1           σk
2
We obtain       Rk = R + log2            1N
2      N −1 2 
 ∏ σj
        
 j =0                   58
IMAGE COMPRESSION AND PACKET VIDEO

Hybrid Coders (Transform + DPCM)

s   Hybrid Coders are designed to exploit
advantages of the transform as well as the
DPCM coding systems.
– Each row of the picture is 1-D transformed, so
for example, 1-D transform the line J and the
line J-1.
– Predict coefficients of line J+1, based upon
coefficients of line J, as in DPCM
– Transmit prediction error signal.
59

IMAGE COMPRESSION AND PACKET VIDEO

Hybrid Coders (Transform + DPCM)

s Performance close to 2-D transform
s Simple Hardware implementation

Line J
F           Predict
Line J+1
Transmit Prediction Error

60

```
DOCUMENT INFO
Categories:
Stats:
 views: 28 posted: 1/11/2010 language: English pages: 30
How are you planning on using Docstoc?