Beruflich Dokumente
Kultur Dokumente
Vector Quantization
Lecture Notes 8
Vector Quantization
2
IMAGE COMPRESSION AND PACKET VIDEO
Vector Quantization
Vector Quantization
4
IMAGE COMPRESSION AND PACKET VIDEO
Distance Measure
■ Ideally distance measure should be related to
perceived quality
– Utah state VQ uses Percent error due to science
application
– MSE is a common measure:
» square of the Euclidean distance between two vectors
d (X , Xˆ ) = ∑ (xi − xˆi )
1 n 2
n i =1
– Weighted MSE is also used:
d (X , Xˆ ) = ∑ wi (xi − xˆi )
1 n 2
n i =1 5
6
IMAGE COMPRESSION AND PACKET VIDEO
VQ Transmitter Diagram
Original
Image
X k
Form Image Minimize distortion Channel
Vectors d (X , Xˆ i )
Codebook
X i , i = 1,K , N c
ˆ
VQ Receiver Diagram
k Xk
Channel Table
Look-up
Codebook
Xˆ i , i = 1,K , N c
8
IMAGE COMPRESSION AND PACKET VIDEO
VQ and Clustering
20 0
15 0
10 0
50
0
0 50 1 00 1 50 2 00 2 50
9
VQ Basics
VQ Basics
11
LBG Algorithm
■ Start with:
– a set of training vectors
– initial codebook Xˆ i , i = 1,K, N c
– distortion measure d
– fractional distortion change threshold ε
■ Initialize:
– iteration counter l to 1
– average distortion over all training vectors, D(0)
to a very large number
15
LBG Algorithm
LBG Algorithm
17
LBG Algorithm
18
IMAGE COMPRESSION AND PACKET VIDEO
LBG Algorithm
Distance Measures
■ Distance Measures can be of any form
■ Typical is the MSE:
k −1
d (x, xˆ ) = ∑ xi − xˆi
2
i =0
Centroid Calculation
Centroid of an Image
22
IMAGE COMPRESSION AND PACKET VIDEO
Distortion Limit
23
Codebook Initialization
Codebook Initialization
■ Random Codes
– Use a random initial codebook where the first Nc
vectors (or any widely spaced Nc vectors) of the
training set are chosen as the initial codebook.
25
Codebook Initialization
■ Splitting
– Centroid for the entire training set is found, and
this single codeword is then split (perturbed by
a small amount) to form two codewords
– LBG algorithm is applied to get an optimum
codebook of size 2
– design continues: optimum code of one stage is
split to form an initial code for the next stage
until Nc codevectors are generated.
26
IMAGE COMPRESSION AND PACKET VIDEO
Codebook Initialization
31
32
IMAGE COMPRESSION AND PACKET VIDEO
Li Lj
∆′i , j = ∑ d ( xi (l ), cent ( Ri ∪ R j )) + ∑ d ( x j (l ), cent ( Ri ∪ R j )) ≥ ∆ i , j
l =1 l =1
33
34
IMAGE COMPRESSION AND PACKET VIDEO
Training Vectors
x1 = (-0.37, 0.99) x7 = (-0.6, 0.18)
x2 = (-0.64, -0.12) x8 = (0.14, 1.76)
x3 = (-0.83, 0.61) x9 = (0.71, -0.35)
x4 = (-0.71, -1.22) x10 = (0.3, 0.8)
x5 = (-0.29, -0.95) x11 = (0.3, 1.07)
x6 = (1.1, 0.52) x12 = (0.38, -0.33)
$0
Start with a uniform quantizer codebook A
S S S S
( x$1 , x$2 , x$3 , x$4 ) = 1 , 2 , 3 , 4 ,
2,2 2,−2 − 2,2 − 2,−2
35
Goal
36
IMAGE COMPRESSION AND PACKET VIDEO
LBG Example
x j ∈ Si , if d ( x j , x$i ) ≤ d ( x j , x$m )
for all m ≠ i
S1 = [ x6 , x8 , x10 , x11]
S2 = [ x2 , x9 ]
S3 = [ x1, x3 , x7 ]
S4 = [ x4 , x5 , x12 ]
Choose ε = 0.001
When [( Dm −1 − Dm ) / Dm ] ≤ ε , halt the iterative process.
Dm is the average distortion at stage m. 37
38
IMAGE COMPRESSION AND PACKET VIDEO
New Codebook
x$( S1) = [( x6 + x8 + x10 + x11) / 4] = (0.46,104
. )
x$( S2 ) = [( x2 + x9 ) / 2] = (0.67,−0.23)
x$( S3 ) = [( x1 + x3 + x7 ) / 3] = ( −0.6,0.59)
x$( S4 ) = [( x4 + x5 + x12 ) / 3] = ( −0.46,−0.83)
This is the new codebook A$1.
If any Si = 0, just use the old codeword .
m=1
Find P ( A$1), this leads to P( A$1) = P ( A$0 ), go to begining
of process ( A)
39
Codebook Iteration
No changes in partition.
Compute D1 , the total distortion.
1 12
D1 = ∑ min d ( x j , xˆ ) = 0.1
12 j =1 xˆ∈Aˆ1
2.02 − 0.1
[( D0 − D1 ) / D1 ] = = 19 > ε
0 .1
Set m = 2. Repeat the process from ( A).
40
IMAGE COMPRESSION AND PACKET VIDEO
Codebook Iteration
41
42
IMAGE COMPRESSION AND PACKET VIDEO
Codebook Design - Tree Structured
Codebooks
Intermediate Codevectors
ˆ (1) ˆ (1)
X (Level 1)
X 1
2
Intermediate
ˆ (2) ˆ (2) ˆ (2) ˆ (2) Codevectors
X
X 1
X 2 X 3
4
(Level 2)
ˆ (3)
X ˆ (3)
X ˆ (3)
X ˆ (3)
X ˆ (3)
X ˆ (3) ˆ (3)
X ˆ (3)
X
1 2 3 4 5 X 6 7 8
Final Codevectors
(Level 3)
44
IMAGE COMPRESSION AND PACKET VIDEO
45
Branches Number
Technique per node of nodes Computations Storage
Bi-tree 2 6 O(12n) 126n
Quad-tree 4 3 O(12n) 84n
Oct-tree 8 2 O(16n) 72n
Full Search 64 1 O(64n) 64n
46
IMAGE COMPRESSION AND PACKET VIDEO
VQ Tree Structures
48
IMAGE COMPRESSION AND PACKET VIDEO
49
Mean/Residual VQ (M/RVQ)
■ M/RVQ represents a prediction type of compressor
■ Prediction is made for the original image from a
limited set of data
■ Residual image is formed by taking the difference
between the predicted and original image
■ Data used for the prediction is encoded using a
scalar quantizer
■ residual image is encoded using a Vector Quantizer
– Many image vectors exhibit similar variations about
different mean levels
50
IMAGE COMPRESSION AND PACKET VIDEO
Mean/Residual VQ (M/RVQ)
51
Mean/Residual VQ (M/RVQ)
52
IMAGE COMPRESSION AND PACKET VIDEO
Mean/Residual VQ (M/RVQ)
Residual VQ address
+
Form Σ VQ
Vector
-
Mean Value
Mean
53
Interpolative/Residual VQ (I/RVQ)
Interpolative/Residual VQ (I/RVQ)
Interpolative/Residual VQ (I/RVQ)
x -x x (m,n)
x (m,n) Lossy Lossless
Encoder
x
Σ Encoder
Data MUX
58
IMAGE COMPRESSION AND PACKET VIDEO
Threshold, T Buffer
Threshold Level
Curve
Constant
FIFO Rate
Threshold Entropy
Encoder Buffer
Variable
Rate
59
- Residual
+
Form Σ log VQ VQ-1 Σ
Vector
- VQ address
Mean
Mean Value
60
IMAGE COMPRESSION AND PACKET VIDEO
VQ Codebook 4x4x256
cod e b oo k
62
IMAGE COMPRESSION AND PACKET VIDEO
VQ Example
■ Training Image
VQ Codebooks
65
Classified VQ (CVQ)
■ A number of different codebooks are developed
– Each are designed to encode blocks of pixels that
contain a specific type of feature
■ The codebook used to encode a particular block is
determined by a classifier capable of
differentiating between different types of features
■ Assumption is made that numerous small code
books, each tuned to a particular class of vectors
can produce comparable quality to a single large
codebook
70
IMAGE COMPRESSION AND PACKET VIDEO
Classified VQ (CVQ)
71
Classified VQ (CVQ)
■ Example Classes:
– Shade Blocks (no significant gradient)
– Midrange Blocks (moderate gradient, no
definite edge)
– Horizontal edge blocks
– Vertical edge blocks
– 45 degree or 135 degree edge blocks
– Mixed Blocks (no discernible orientation)
72
IMAGE COMPRESSION AND PACKET VIDEO
Classified VQ (CVQ)
73
Finite-State VQ (FSVQ)
■ VQ with memory
■ Each state represents a separate codebook
■ Similar to CVQ
– Codebook selection is based on the next state function
rather than a block classifier
■ Next state function is a mapping of the current state
to another state with a new codebook
■ Adjacent blocks of pixels are often similar, and we
can use the correlation to pick the next codebook.
■ FSVQ works for small block sizes.
74
IMAGE COMPRESSION AND PACKET VIDEO
Finite-State VQ (FSVQ)
Finite-State VQ (FSVQ)
76
IMAGE COMPRESSION AND PACKET VIDEO
Finite-State VQ (FSVQ)
78
IMAGE COMPRESSION AND PACKET VIDEO
Trellis Codes
■ Goal:
– Lossily compress data vectors of length n
– Desired compression Rate is R codebits per data sample
– k is a positive integer such that N = 2 kR is an integer
– n is a multiple of k
– m is a integer m = n
k
– S is a positive integer
– Pick any trellis with S states, m stages, and N outgoing
branches per state.
– Attach to each of the N outgoing branches from each state a
kR-bit address so that N branches have distinct labels.
79
81
83
84