lloyd-max quantization schemes -...
TRANSCRIPT
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Lloyd-Max Quantization Schemes
Helmut KnaustDepartment of Mathematical Sciences
The University of Texas at El PasoEl Paso TX 79968-0514
January 6, 2011
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
1 Introduction
2 Basic Quantization Schemes
3 Lloyd-Max Quantization Setup
4 Lloyd-Max Quantization for “Raw” Images
5 Lloyd-Max Quantization for Transformed Images
6 Generalizations
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Learning Outcomes and Prerequisites
Learning Outcomes:
Students will reflect on the role of quantization in imagecompression.Students will improve their programming skills.
Prerequisites:Multi-variable CalculusSome knowledge of wavelet transforms and their use inimage compressionSome minimal statistics knowledge
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Learning Outcomes and Prerequisites
Learning Outcomes:Students will reflect on the role of quantization in imagecompression.
Students will improve their programming skills.Prerequisites:
Multi-variable CalculusSome knowledge of wavelet transforms and their use inimage compressionSome minimal statistics knowledge
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Learning Outcomes and Prerequisites
Learning Outcomes:Students will reflect on the role of quantization in imagecompression.Students will improve their programming skills.
Prerequisites:Multi-variable CalculusSome knowledge of wavelet transforms and their use inimage compressionSome minimal statistics knowledge
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Learning Outcomes and Prerequisites
Learning Outcomes:Students will reflect on the role of quantization in imagecompression.Students will improve their programming skills.
Prerequisites:
Multi-variable CalculusSome knowledge of wavelet transforms and their use inimage compressionSome minimal statistics knowledge
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Learning Outcomes and Prerequisites
Learning Outcomes:Students will reflect on the role of quantization in imagecompression.Students will improve their programming skills.
Prerequisites:Multi-variable Calculus
Some knowledge of wavelet transforms and their use inimage compressionSome minimal statistics knowledge
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Learning Outcomes and Prerequisites
Learning Outcomes:Students will reflect on the role of quantization in imagecompression.Students will improve their programming skills.
Prerequisites:Multi-variable CalculusSome knowledge of wavelet transforms and their use inimage compression
Some minimal statistics knowledge
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Learning Outcomes and Prerequisites
Learning Outcomes:Students will reflect on the role of quantization in imagecompression.Students will improve their programming skills.
Prerequisites:Multi-variable CalculusSome knowledge of wavelet transforms and their use inimage compressionSome minimal statistics knowledge
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Quantization
Quantization reduces ranges of values in a signal to asingle value, thereby reducing entropy.
Quantization is an integral part of lossy compressionalgorithms.
Quantization is usually employed after transformation.
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Quantization
Quantization reduces ranges of values in a signal to asingle value, thereby reducing entropy.
Quantization is an integral part of lossy compressionalgorithms.
Quantization is usually employed after transformation.
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Quantization
Quantization reduces ranges of values in a signal to asingle value, thereby reducing entropy.
Quantization is an integral part of lossy compressionalgorithms.
Quantization is usually employed after transformation.
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Basic Quantization Scheme: Thresholding
The most basic quantization technique is Thresholding:
Given a signal ~x = (xi) and a single threshold σ, we replacevalues as follows:
q(xi) =
{0 if |xi | ≤ σxi if |xi | > σ
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
The thresholding quantization function:
x
qHxL
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
The JPEG2000 Quantization Scheme
The Lossy JPEG2000 Quantization Scheme also has onefixed parameter, τ . After wavelet transformation, a “step”quantization
q(xi) = sgn(xi) · σ ·⌊|xi |σ
⌋is applied to each region with a parameter σ determined asfollows:
Τ
2 Τ
Τ 2 Τ
n = 1
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
The JPEG2000 Quantization Scheme
The Lossy JPEG2000 Quantization Scheme also has onefixed parameter, τ . After wavelet transformation, a “step”quantization
q(xi) = sgn(xi) · σ ·⌊|xi |σ
⌋is applied to each region with a parameter σ determined asfollows:
Τ
4Τ
2
Τ
2 Τ
Τ
Τ 2 Τ
n = 2
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
The JPEG2000 Quantization Scheme
The Lossy JPEG2000 Quantization Scheme also has onefixed parameter, τ . After wavelet transformation, a “step”quantization
q(xi) = sgn(xi) · σ ·⌊|xi |σ
⌋is applied to each region with a parameter σ determined asfollows:
Τ
8Τ
4Τ
4Τ
2
Τ
2
Τ
2 Τ
Τ
Τ 2 Τ
n = 3
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
The quantization function for a given region:
x
qHxL
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
For a fixed signal ~x and a fixed positive integer n, Lloyd-Maxquantization uses two sets of parameters:
Bin-boundaries ~L = (L1,L2, . . . ,Ln+1), withmin~x = L1 < L2 < · · · < Ln < Ln+1 = 1 + max~x ,and replacement values ~p = (p1,p2, . . . ,pn).
The quantization function replaces the x-values in the bin[Lj ,Lj+1) by the value pj :
q(xi) = pj , when xi ∈ [Lj ,Lj+1)
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
The goal is to choose ~L and ~p to minimize the resultingquantization error
E(~L, ~p) =m∑
i=1
|xi − q(xi)|2
This is a classical Calculus problem. Rewriting we obtain:
E(~L, ~p) =n∑
j=1
∑xi∈[Lj ,Lj+1)
(xi − pj)2
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
E(~L, ~p) =n∑
j=1
∑xi∈[Lj ,Lj+1)
(xi − pj)2
Since minima will occur only if all partial derivatives are equal to0, the following conditions need to be satisfied:
∂ E∂pj
=∑
xi∈[Lj ,Lj+1)
2(xi − pj) = 0⇔ pj =
∑xi∈[Lj ,Lj+1)
xi
#{i | xi ∈ [Lj ,Lj+1)}(1)
∂ E∂Lj
= 0 ⇔ Lj =12(pj−1 + pj) (2)
p j-1 L j p jxi
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
E(~L, ~p) =n∑
j=1
∑xi∈[Lj ,Lj+1)
(xi − pj)2
Since minima will occur only if all partial derivatives are equal to0, the following conditions need to be satisfied:
∂ E∂pj
=∑
xi∈[Lj ,Lj+1)
2(xi − pj) = 0⇔ pj =
∑xi∈[Lj ,Lj+1)
xi
#{i | xi ∈ [Lj ,Lj+1)}(1)
∂ E∂Lj
= 0 ⇔ Lj =12(pj−1 + pj) (2)
p j-1 L j p jxi
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
E(~L, ~p) =n∑
j=1
∑xi∈[Lj ,Lj+1)
(xi − pj)2
Since minima will occur only if all partial derivatives are equal to0, the following conditions need to be satisfied:
∂ E∂pj
=∑
xi∈[Lj ,Lj+1)
2(xi − pj) = 0⇔ pj =
∑xi∈[Lj ,Lj+1)
xi
#{i | xi ∈ [Lj ,Lj+1)}(1)
∂ E∂Lj
= 0 ⇔ Lj =12(pj−1 + pj) (2)
p j-1 L j p jxi
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
E(~L, ~p) =n∑
j=1
∑xi∈[Lj ,Lj+1)
(xi − pj)2
Since minima will occur only if all partial derivatives are equal to0, the following conditions need to be satisfied:
∂ E∂pj
=∑
xi∈[Lj ,Lj+1)
2(xi − pj) = 0⇔ pj =
∑xi∈[Lj ,Lj+1)
xi
#{i | xi ∈ [Lj ,Lj+1)}(1)
∂ E∂Lj
= 0 ⇔ Lj =12(pj−1 + pj) (2)
p j-1 L j p jxi
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
These equations can usually not be solved explicitly; instead atwo-step procedure is used repeatedly until a fixed point hasbeen (nearly?) reached:
Equations (1) are used to update the values ~p:
pnewj = ave
{xi | xi ∈ [Lj ,Lj+1)
}Equations (2) then yield new values for ~L:
Lnewj =
12(pnew
j−1 + pnewj ) , j = 2, . . . ,n
The values for L1 and Ln+1 are left unchanged.
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
These equations can usually not be solved explicitly; instead atwo-step procedure is used repeatedly until a fixed point hasbeen (nearly?) reached:
Equations (1) are used to update the values ~p:
pnewj = ave
{xi | xi ∈ [Lj ,Lj+1)
}
Equations (2) then yield new values for ~L:
Lnewj =
12(pnew
j−1 + pnewj ) , j = 2, . . . ,n
The values for L1 and Ln+1 are left unchanged.
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
These equations can usually not be solved explicitly; instead atwo-step procedure is used repeatedly until a fixed point hasbeen (nearly?) reached:
Equations (1) are used to update the values ~p:
pnewj = ave
{xi | xi ∈ [Lj ,Lj+1)
}Equations (2) then yield new values for ~L:
Lnewj =
12(pnew
j−1 + pnewj ) , j = 2, . . . ,n
The values for L1 and Ln+1 are left unchanged.
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
As an example, we apply the algorithm to a grayscale image,with n = 32. The initial bins are chosen at random.
Original image, entropy=7.65
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
As an example, we apply the algorithm to a grayscale image,with n = 32. The initial bins are chosen at random.
21 iterations, entropy=4.75, PSNR 40.7
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
As an example, we apply the algorithm to a grayscale image,with n = 32. The initial bins are chosen at random.
28 iterations, entropy=4.56, PSNR 40.0
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is the quantization function for the second run:
0 50 100 150 200 250x0
50
100
150
200
250
qHxL
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Quantization applied to “raw” images usually gives bad resultsin areas of gradual gray-value change (sky, water, etc.):
Original image:entropy=7.63
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Quantization applied to “raw” images usually gives bad resultsin areas of gradual gray-value change (sky, water, etc.):
n = 26:10 iterations, entropy=5.53, PSNR 45.1
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Quantization applied to “raw” images usually gives bad resultsin areas of gradual gray-value change (sky, water, etc.):
n = 25:18 iterations, entropy=4.35, PSNR 38.0
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Quantization applied to “raw” images usually gives bad resultsin areas of gradual gray-value change (sky, water, etc.):
n = 24:22 iterations, entropy=3.76, PSNR 34.7
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
We now compare step quantization to Lloyd-Max quantizationfor a transformed image:
We use the CDF97 wavelet transform once.For the step quantization we use τ = 16:
Original image (-128): entropy=7.74
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
We now compare step quantization to Lloyd-Max quantizationfor a transformed image:
We use the CDF97 wavelet transform once.For the step quantization we use τ = 16:
CDF97-transformed image
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
We now compare step quantization to Lloyd-Max quantizationfor a transformed image:
We use the CDF97 wavelet transform once.For the step quantization we use τ = 16:
Τ�2=8 Τ=16
Τ=16 2Τ=32
Step sizes for the quantization
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
We now compare step quantization to Lloyd-Max quantizationfor a transformed image:
We use the CDF97 wavelet transform once.For the step quantization we use τ = 16:
Quantized transform: entropy=2.75
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
We now compare step quantization to Lloyd-Max quantizationfor a transformed image:
We use the CDF97 wavelet transform once.For the step quantization we use τ = 16:
Reconstructed image: PSNR 32.44
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is the same example with Lloyd-Max quantization:
Original image (-128): entropy=7.74
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is the same example with Lloyd-Max quantization:
CDF97-transformed image
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is the same example with Lloyd-Max quantization:
n=24 n=10
n=11 n=6
Number of bins for the quantization
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is the same example with Lloyd-Max quantization:
Quantized transform: entropy=3.73
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is the same example with Lloyd-Max quantization:
Reconstructed image: PSNR=33.44
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Why is the entropy comparatively high after LM-quantization?Here are the histograms of the quantized transformed signals:
Step quantization Lloyd-Max quantization
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Lloyd-Max quantization can be generalized to higherdimensions.
The bin boundary conditions in Equations (2) now becomeVoronoi cell conditions.The update step given by Equations (1) still remains: Thenew replacement values are the average of the signalvalues in the Voronoi cell.
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
Here is a two-dimensional example:
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
The End...
Any Questions?
Helmut [email protected]
Introduction Basic Quantization Lloyd-Max “Raw” Images Transformed Images Generalizations
The End...
Any Questions?
Helmut [email protected]