Professional Documents
Culture Documents
VQ Wavelet-SPIHT
3 4
JPEG VQ
5 6
1
CuuDuongThanCong.com https://fb.com/tailieudientucntt
SPIHT Original
7 8
9 10
30
where m is the maximum value of a pixel possible. SPIHT coded Barbara
28
For gray scale images (8 bits per pixel) m = 255. 26
24 Properties:
• PSNR is measured in decibels (dB): 22 - Increasing
– .5 to 1 dB is said to be a perceptible difference. 20 - Slope decreasing
– Decent images start at about 25-30 dB.
02
13
23
33
42
52
65
73
83
92
0.
0.
0.
0.
0.
0.
0.
0.
0.
0.
11 12
2
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Warning: PSNR is not Everything PSNR Reflects Fidelity (1)
VQ VQ
PSNR 25.8
.63 bpp
12.8 : 1
13 14
15 16
• You’re given 16-bit integers (0-65545). • Now you have a string of those 8-bit integers
• Unfortunately, you only have space to store that use your representation.
8-bit integers (0-255). • Recreate the 16-bit integers as best you can!
• Come up with a representation of those 16-bit
integers that uses only 8 bits!
17 18
3
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Scalar Quantization Scalar Quantization Strategies
source image index of a
codebook
codeword • Build a codebook with a training set, then
0
i
1 always encode and decode with that fixed
.
.
.
codebook.
n-1 – Most common use of scalar quantization.
• Build a codebook for each image and
codebook decoded image transmit the codebook with the image.
0
1 • Training can be slow.
.
.
.
n-1
19 20
• Let the image be pixels x1, x2, … xT. • 512 x 512 image with 8 bits per pixel.
• 8 codewords.
• Define index(x) to be the index transmitted on boundary codeword
input x.
• Define c(j) to be the codeword indexed by j. 0 31 63 95 127 159 191 223 255
D = ∑i=1 (x i − c(index(x i ))
T 2
(Distortio n) Codebook
D
MSE = Index 0 1 2 3 4 5 6 7
T Codeword 16 47 79 111 143 175 207 239
21 22
23 24
4
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Example Improving Distortion
• Choose the codeword as a weighted average
• 512 x 512 image = 262,144 pixels
(the centroid).
index 0 1 2 3 4 5 6 7
input 0-31 32-63 64-95 96-127 128-159 160-191 192-223 224-255
frequency 25,000 95,000 85,000 10,000 10,000 10,000 18,000 9,144
pixel value 8 9 10 11 12 13 14 15
frequency 100 100 100 40 30 20 10 0
27 28
5
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Lloyd Algorithm Example
Initially c(0) = 2 and c(1) = 5
Choose a small error tolerance ε > 0.
Choose start codewords c(0),c(1),...,c(n-1).
Compute X(j) := {x : x is a pixel value closest to c(j)}. pixel value 0 1 2 3 4 5 6 7
Compute distortion D for c(0),c(1),...,c(n-1). frequency 100 100 100 40 30 20 10 0
Repeat:
Compute new codewords: X(0) = [0,3], X(1) = [4,7]
c' (j) := round( ∑ x ⋅p
x∈X(j)
x )
D(0) = 140 ⋅12 + 100 ⋅ 22 = 540; D(1) = 40 ⋅12 = 40
Compute X’(j) = {x : x is a pixel value closest to c’(j)}. D = D(0) + D(1) = 580
Compute distortion D’ for c’(0),c’(1),...,c’(n-1). c' (0) = round((100 ⋅ 0 + 100 ⋅ 1+ 100 ⋅ 2 + 40 ⋅ 3)/340) = 1
if |(D – D’)/D| < ε then quit, c' (1) = round((30 ⋅ 4 + 20 ⋅ 5 + 10 ⋅ 6 + 0 ⋅ 7)/60) = 5
else c := c’; X := X’, D := D’.
End{repeat}
31 32
Example Example
Example Example
6
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Example Scalar Quantization Notes
7
CuuDuongThanCong.com https://fb.com/tailieudientucntt