Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
SOLUTIONS OF IMAGE CODING PROBLEMS
Prof. Ing. Ján Mihalík, PhD. Ing. Iveta Gladišová, PhD.
Laboratory of Digital Image Processing and Videocommunications Department of Electronics and Multimedia Communications
Faculty of Electrical Engineering and Informatics Technical University of Košice
Contents
1. QUANTIZATION .................................................................................... ……..1
1.1. Uniform Quantization …................................................................... ……..1
1.2. Non Uniform quantization …............................................................ ……..8
2. ENTROPY CODING............................................................................... ……25
3. IMAGE PREDICTIVE CODING….…….................................... …..............32
4. IMAGE TRANSFORM CODING................................................ …………..41
5. IMAGE HYBRID CODING……………..................................... …………..53
REFERENCES................................................................................ …………...64
1
1. QUANTIZATION
1.1. Uniform quantization Transfer characteristic of N-level (n-bit) uniform quantizer (UQ) is characterized by the fact that its quantization and decision levels are uniformly graded with quantization step ∆.
Assuming that input sequence of random samples is stationary with symmetric probability density function f(x) towards zero, and then mean square value of
quantization noise can be expressed through the sum of mean square value 1
2qσ of
granular quantization noise and 2
2qσ of overload quantization noise
1 2
2 2 2q q qσ = σ + σ ,
while
1
Ni2
2 2q
i 1 (i 1)
12 [x (i ) ] f (x)dx
2
∆
= − ∆
σ = − − ∆∑ ∫
and
2
2 2q
N2
(N 1)2 [x ] f (x)dx
2
∞
∆
−σ = − ∆∫ .
Optimal UQ (OUQ) is characterized by the fact that the resulting mean square
value of quantization noise2qσ is minimal.
The number of quantization levels N, respectively the number of bits n ( n2N = ) is determined by selecting the desired signal to noise ratio (SNR) at the output of OUQ using tables.
2
The dependence of number of bits n of OUQ on SNR for the three types of probability density function f (x) of input signal is shown in Tab.1.
Table 1. Gaussian f(x)
n[bit] 1 2 3 4 5 6 7 8 SNR[dB] 4,4 9,25 14,27 19,38 24,57 29,4 35,17 40,3
Laplace f(x) n[bit] 1 2 3 4 5 6 7 8
SNR[dB] 3,01 7,07 11,44 15,96 20,6 25,9 31,2 36,5 Modified gamma f(x)
n[bit] 1 2 3 4 5 6 7 8 SNR[dB] 1,77 4,95 8,78 13 17,49 21,75 26 30,5
The dependence of optimal normalized quantization step 0∆ of OUQ on
the number of bits n for three types of probability densities function f(x) of input signal is shown in Tab. 2.
Table 2. Gaussian f(x)
n[bit] 1 2 3 4 5 6 7 8
∆ o 1,596 0,996 0,586 0,355 0,188 0,12 0,06 0,032 Laplace f(x)
n[bit] 1 2 3 4 5 6 7 8
∆ o 1,414 1,087 0,731 0,456 0,281 0,17 0,09 0,05 Modified gamma f(x)
n[bit] 1 2 3 4 5 6 7 8
o ∆ 1,154 1,06 0,796 0,54 0,346 0,275 0,163 0,1
From Tab.2 it is possible to read the normalized quantization step xσ
∆=∆ .
3
Example 1.
Calculate the mean square value of quantization noise 2qσ on the output of single-
level quantizer assuming that the input sequence samples have uniform probability density function on the interval <K1 - ∆/2; K1 + ∆/2>. Optimize this quantizer further.
Solution
Transfer characteristic of single-level quantizer is shown in Fig.1. It is easy to see that the density of uniform probability distribution on interval <K1 - ∆/2; K1 + ∆/2>
will be: ∆
= 1)x(f .
Fig. 1. Transfer characteristic of single-level quantizer with uniform probability distribution.
Mean square value of quantization noise is calculated from
1 1
1 1
K / 2 K / 22 2 2 2 2 2q n
K / 2 K / 2
1E(q ) E[(X K)] (x K) f (x) dx (x 2xK K ) dx
+∆ +∆
−∆ −∆
σ = = − = − = − + =∆∫ ∫
4
1
1
K / 23 22
K / 2
x 2x KK x
3 2
+∆
−∆
= − +
.
After substitution and editing we get the expression:
12)KK(
22
12q
∆+−=σ ,
which is the resulting relation for our 2qσ quantizer. Dependency graph of 2qσ on
quantization level K of this quantizer is depicted on Fig. 2. Optimal single-level
quantizer has a quantization level for which 2qσ is minimal. This means looking for
a local minimum.
( )1opt
221
2q KK0
dK
12/)KK(d
dK
d=⇒=∆+−=
σ.
From the above it is clear that the quantization level of optimal single-level quantizer is given by the arithmetical average of border range of possible values
of input samples. Than 1222qmin ∆=σ .
Fig.2. Graph representing dependency of mean square value of quantization noise 2qσ
on quantization level K.
5
Example 2.
Calculate the mean square value of quantization noise 2qσ on the output of four-
level uniform quantizer with a transfer characteristic depicted in Fig. 3. We assume that the input sequence samples have Laplace probability density distribution, i.e.
2 x1f (x) e
2−= , zero mean value and unit variance.
Solution
To calculate the total 2qσ at first we calculate granular quantization noise and
overload quantization noise.
Generally, mean square value of quantization noise for the i-th interval will be
i 1 i 1
i i
i i
a a2 x2 2 2 2
q ia a
1(i) (x b ) f (x) dx (x 2xb b ) e dx
2
+ +−σ = − = − +∫ ∫ .
Fig. 3. Transfer characteristic of 4-level uniform quantizer.
6
For positive half axis, when xx = we calculate )i(2qσ using three integrals
i 1i 1
1
i i
aa 22 2x 2x
a a
1 x x 1I x e dx e (
2 22 2
++− −
= = − + +
∫ ,
i 1i 1i
2 i i
i i
aa2x 2x
a a
1 bI 2xb e dx e (xb
2 2
++− − = − = +
∫ ,
i 1 i 1
3i
i
a 2 a2 2x 2xii
aa
1 bI b e dx e
22
+ +− − = = − ∫ ,
then
i 1
i1 3 i
i
a2 22 2x iq 2
a
x x 1 b b(i) I I I e ( xb )
2 2 22 2
+−
σ = + + = − − − + + −
.
Mean square value of granular quantization noise
i 1
ii
i
2a i2 22 2q
i 1 i 1a (i 1)
12 (x b ) f (x) dx 2 x (i ) f (x) dx
2
+ ∆
= = − ∆
σ = − = − − ∆ ∑ ∑∫ ∫ ,
because the transfer characteristic of UQ is symmetrical towards beginning.
For i = 1:
∫∆
∆−− −∆+∆−−−∆−∆−=∆−0
20
22x22 )
2
1
228(e)
2
1
228(edxe
2
1)
2x( .
Similarly for i = 2:
∫∆
∆
∆−∆−− −∆+∆−−−∆−∆−=∆−2 2
22
22x22 )2
1
228(e)
2
1
228(edxe
2
1)
2
3x( .
7
Then
1
2 22 2 2 2q
2e ( 1) e ( 1)
4 42 2 2− ∆ − ∆∆ ∆ ∆ ∆ ∆σ = − − − − + − + .
The mean square value of the overload quantization noise
2
22 2 2 2q
2
32 (x ) f (x)dx e ( 1)
2 4 2
∞− ∆
∆
∆ ∆ ∆σ = − = + +∫ .
The total mean square value of quantization noise
1 2
22 2 2 2q q q
21 e
4 2 2− ∆∆ ∆ ∆σ = σ + σ = + − − .
Analyzed UQ will be optimal (OUQ) if 2qσ is minimal for ∆0. We calculate it from
the following equation
0e2e2
2
2
1
2
1
d
d 222q =∆+−−∆=
∆σ ∆−∆− ,
02
1
2
1)
2
1(e2 2 =−∆+−∆∆− .
Using iterative method we obtain the result 087,10 =∆ .
8
Example 3.
Using tables for OUQ optimize uniform quantizer for Gaussian, Laplace and modified gamma probability density functions, when the variance of input samples
42x =σ and their mean value is zero. At its output, we require SNR of
approximately 25 dB.
Solution
The number of bits n of OUQ can be determined from the desired SNR at its output.
a) For the Gaussian probability density function value n can be determined from Tab. 1. For the desired value of SNR the best corresponding SNR value is 24,57 dB, for this information n = 5 bits and the number of quantization
levels N = 25 = 32. Then from Tab. 2. we get value 188,00 =∆ . From this
value and from 24x ==σ calculate the un-normalized quantization step
376,0188,0.20x0 ==∆σ=∆ . Transfer characteristic of OUQ (n = 5bits,
∆0 = 0,376) can easily be obtained from general characteristic. To optimize for the next two probability distributions proceed analogically.
b) For Laplace probability density function we get: n = 6 bit, N = 26 = 64
levels, SNR= 25,90 dB, 170,00 =∆ , 340,00 =∆ .
c) For modified gamma probability density function we get: n = 7 bit, N = 128
levels, SNR = 26 dB, 163,00 =∆ , 326,00 =∆ .
1.2. Non uniform quantization
A typical feature of transfer characteristic of non uniform quantizer (NUQ) is the non uniform distribution of quantization and decision levels. Assuming a stationary sequence of random input samples the mean square value of quantization noise will be
9
( ) dx)x(fbxN
1i
a
a
2i
2q
1i
i
∑ ∫=
+
−=σ ,
where ai are decision levels and where −∞=ia , ∞=+1Na . Values bi are
quantization levels and f(x) is density probability function.
For optimal non uniform quantizer (ONUQ), the following system of nonlinear equations is applied
i 1
ii
i 1
i
a
aa
a
x f (x) dx
b
f (x) dx
+
+=∫
∫
, i=1, ...,N (1)
i i 1i
b ba
2−+= , i=2, ..., N (2)
Their exact solving process is complex, therefore they are often solved using iterative method: at first we define value b1, then for this b1 from equation (1) value a2 is clearly determined. Then value b2 from equation (2) is clearly determined. Similar process is used to get the equation
NN
N
a
a
x f (x) dx
b
f (x) dx
∞
∞=∫
∫
.
Since bN and aN are already known, this Eq. is used to control the accuracy of selected value of b1. If this is not fulfilled, a correction of chosen b1 is made and the process is repeated until a valid Eq. for bN is found.
10
For an approximate calculation of 2qσ
ONUQ (asymptotically) the term
3
3/12
2q dx)x(f
N12
1
≈σ ∫
∞
∞−.
is used very often. Eq. allows calculation of 2qσ without knowledge of ia or bi
levels respectively, only on the basis that f(x) and N are known.
Using companding method we get good approximation of ONUQ
(especially with higher N) without previously calculating ia and ib . Optimization
of this quantizer bases in finding a suitable compression or expansion
characteristics so that 2qσ is minimal (Fig.4). This requirement for some f (x) is
optimally satisfied by this compression characteristic
11 2 1 1 2
2
1
x1/ 3
VV
1/ 3
V
f (a) da
g(x) V (V V ) , x V ,V
f (a) da
= + − ∈∫
∫
,
while interval <V1, V2> is practically a range of possible values of random input samples.
Fig. 4. Block scheme of non uniform quantizer with companding.
uniform quantizer
compressor
expander
non uniform quantizer
11
In tables 3 to 7 we have normalized decision ia and quantization levels ib
of ONUQ (for variance 12x =σ , e.g. normalized tables). For selected probability
density functions there are transfer characteristics of ONUQ which are symmetric
to the beginning, that’s why the levels ia and ib are stated for the third quadrant
(negative quadrant). These levels of different 2xσ change in direct proportion with
the value of xσ . Furthermore, values 2qσ and SNR are given.
In Tab. 8, number of bits n of desired SNR on output of ONUQ are given.
Table 3 n=1 bit (N=2) , 2
xσ =1
i
Gaussian probability distribution
Laplace probability distribution
Modified gamma probability distribution
ia− ib− ia− ib− ia− ib− 1 ∞ 0,798 ∞ 0,707 ∞ 0,577 2 0 – 0 – 0 – 2qσ 0,3634 0,5 0,668
SNR [dB]
4,4 3,01 1,77
Table 4.
n=2 bit (N=4) , 2xσ =1
i
Gaussian probability distribution
Laplace probability distribution
Modified gamma probability distribution
ia− ib− ia− ib− ia− ib− 1 ∞ 1,51 ∞ 1,81 ∞ 2,108 2 0,9816 0,4528 1,102 0,395 1,205 0,302 3 0 – 0 – 0 – 2qσ 0,1175 0,1765 0,2326
SNR [dB]
9,25 7,53 6,33
12
Table 5.
Table 6.
n=4bit (N=16) , 2xσ =1
i
Gaussian probability distribution
Laplace probability distribution i
Modified gamma probability distribution
ia− ib− ia− ib− ia− ib− 1 ∞ 2,733 ∞ 4,316 ∞ 6,085 2 2,401 2,069 3,605 2,895 5,05 4,015 3 1,844 1,618 2,499 2,103 3,407 2,798 4 1,437 1,256 1,851 1,54 2,372 1,945 5 1,099 0,9424 1,317 1,095 1,623 1,3 6 0,7996 0,6568 0,91 0,726 1,045 0,791 7 0,5224 0,3881 0,566 0,407 0,588 0,386 8 0,2582 0,1284 0,266 1,126 0,229 0,072 9 0 – 0 – 0 – 2qσ 0,009497 0,0154 0,0196
SNR [dB]
20,22 18,12 17,07
n=3 bit (N=8) , 2xσ =1
i
Gaussian probability distribution
Laplace probability distribution
Modified gamma probability distribution
ia− ib− ia− ib− ia− ib− 1 ∞ 2,152 ∞ 2,994 ∞ 3,799 2 1,748 1,344 2,285 1,576 2,872 1,944 3 1,05 0,756 1,181 0,785 1,401 0,859 4 0,5006 0,2451 0,504 0,222 0,504 0,149 5 0 – 0 – 0 – 2qσ 0,03454 0,0548 0,0712
SNR [dB]
14,62 12,61 11,47
13
Table 7.
n=5bit (N=32) , 2xσ =1
i
Gaussian probability distribution
Laplace probability distribution
Modified gamma probability distribution
ia− ib− ia− ib− ia− ib− 1 ∞ 3,263 ∞ 5,768 ∞ 8,048 2 2,977 2,692 5,069 4,371 7,046 6,05 3 2,505 2,319 3978 3,586 5,444 4,888 4 2,174 2,029 3,305 3,025 4,404 3,907 5 1,908 1,788 2,804 2,583 3,633 3,296 6 1,682 1,577 2,398 2,214 3,022 2,747 7 1,482 1,387 2,055 1,896 2,517 2,287 8 1,299 1,212 1,756 1,616 2,089 1,892 9 1,13 1,049 1,49 1,365 1,72 1,548 10 0,9718 0,8947 1,25 1,136 1,397 1,245 11 0,821 0,7473 1,031 0,926 1,11 0,976 12 0,6761 0,605 0,829 0,732 0,857 0,737 13 0,5359 0,4668 0,642 0,551 0,63 0,523 14 0,3991 0,3314 0,467 0,382 0,429 0,334 15 0,2648 0,1981 0,302 0,222 0,252 0,169 16 0,132 0,06559 0,147 0,072 0,101 0,033 17 0 – 0 – 0 –
2qσ 0,002499 0,00414 0,0052
SNR[dB] 26,02 23,83 22,83 Table 8.
Gaussian f(x) n[bit] 1 2 3 4 5
SNR[dB] 4,4 9,3 14,62 20,22 26,02 Laplace f(x)
n[bit] 1 2 3 4 5 SNR[dB] 3,01 7,53 12,61 18,12 23,83
Modified gamma f(x) n[bit] 1 2 3 4 5
SNR[dB] 1,77 6,33 11,47 17,07 22,83
14
Example 4.
Optimize the non uniform quantizer with 4 levels by using the iterative method with accuracy of control equation equal to 0,05 for stationary sequence of random input samples with Laplace probability density function, with zero mean value and
variance 42x =σ .
Solution:
The objective is to find decision and quantization levels, that is transfer characteristic of 4 level ONUQ and calculate it’s SNR. Laplace probability density function will have this formula:
x2
2x
2
2x
e22
1e
1)x(f x
−σ
−=
σ= .
Because the Laplace probability density function with mean value zero is symmetric to the beginning, we just determine transfer characteristic in the third quadrant where |x| = - x, then:
i 1
i 1 i 1
i i ii
i 1 i 1i 1
i i
i
a2
x2a a x 22
a a aa a2a 2x x2 2a a
a
x 11 e ( )x f (x) dx x e dx 2 22 2b 2
1f (x) dx e dx e2 2
+
+ +
+ ++
−
= = =
∫ ∫
∫ ∫
. i= 1, 2.
Decision levels: −∞=1a , 1 22
b ba
2
+= , 0a3 = .
Algorithm of iterative method will begin with the choice of b1 = - 3. Then
15
2
12
a2
x2
a2
x2
x 1e ( )
2 2b 2 3
e
−∞
−∞
− = = −
.
After filling the boundaries and corresponding adjustment we will get this equation:
22
a22 a 1 3
e ( ) 02 22
− + = , where a2 = -1,59.
From equation:
2 1 22
b b b 3a 1,59
2 2
+ −= = = − we calculate b2 = -0,18, but also
3
22
3
2
a 02 2x x2 2
a 1.59a 0
2 2x x
2 2
a 1.59
x 1 x 1e ( ) e ( )2 2 2 2
b 2 2 0,18
e e
−
−
− − = = = −
In this equation all values are known and from that we can get the equation for controlling the choice of b1= -3. From Eq. we have
0))2
1
2
59,1(e
2
1(2)e1(18,0 2
259.1
2
259.1
=−−−−−−−−−
&
– 0,122 – 2(−0,219) =& 0
0,316 =& 0
16
As we can see, the accuracy is not higher than 0,05. So we correct the value chosen for b1 and repeat the whole procedure.
Let b1 = -3,6 , after analogous procedure as for b1 = -3 we will calculate new values for a2 = -2,18 and b2 = -0,76.
The equation for control will be:
0))2
1
2
18,2(e
2
1(2)e1(76,0 2
218.2
2
218.2
=−−−−−−−−−
&
−0,597 –2(−0,322) =& 0
0,047 =& 0,
from which we can see that accuracy is greater than 0,05. All calculated decision and quantization levels ONUQ are in the Tab. 9.
Table 9.
i
n=2 (N=4), 42x =σ
ia− ib−
1 ∞− - 3,6 2 - 2,18 - 0,76 3 0 0,76 4 2,18 3,6 5 ∞ -
The mean square value of quantization noise of this ONUQ
i 1 i 1
i ii
i i
2a a4 4 2 x2 2 2 2 2 2q q i
i 1 i 1 i 1a a
1(x b ) f (x) dx 2 (x 2b x b ) e dx
2 2
+ +
= = =σ = σ = − = − +∑ ∑ ∑∫ ∫ ,
17
which we will resolve with the help of another three integrals
∫+
+
+−==
1i
i
1i
i
a
a
a
a
2x2
2x
2
22
1 )2x22
x(edxe
22
1xI
∫+
+
+−=−=
1i
i
1i
i
a
a
a
a
iix
2
2x
2
2
i2 )b2xb(edxe22
1xb2I
∫+
+
==
1i
i
1i
i
a
a
a
a
2i
x2
2x
2
22i3 2
bedxe
22
1bI
Then
i 1
ii
i
a2 2 2x2 i2
q 1 2 3 i
a
x bI I I e ( 2x 2 b x 2b
2 2
+ σ = + + = − + − + +
With the help of 2qi
σ we will calculate
32
1 2
1 2
aa2 2 2q
a a
( (x b ) f (x)dx (x b ) f (x)dxσ = − + − =∫ ∫
∫ ∫−
∞− −
=+++=18.2 0
18.2
2
22x
2
22 )dxe
22
1)76,0x(dxe
22
1)6,3x((2
+
+−++−=
−
∞−
18.222x
2
2
2
76,026,3x6,32x2
2
x(e2
18
+−++−+
−
0
18.2
22x2
2
2
76,0276,0x76,02x2
2
x(e .
After filling the boundaries and after the adjustment
708,0)140,0214,0(22q =+=σ , where
dB52,7708,0
4log10log10SNR
2q
2x ==
σσ= .
Example 5.
Optimize the non uniform quantizer for the stationary sequence random input samples with Gaussian probability density function, zero mean value and variance
of input samples 92x =σ so that SNR on its output is more than 18 dB. Optimize by
using tables for ONUQ.
Solution
From Tab. 8. for design of ONUQ, we subtract for SNR > 18dB minimally n= 4bit (N= 24 =16 quantization levels). For this value of SNR = 20,22 dB.
For Gaussian probability density function again we subtract normalized values ia
and ib from Tab. 6. From these values and the given 39x ==σ we calculate un-
normalized values
iixi a3aa =σ= , iixi b3bb =σ= ,
which specify the transfer characteristic of ONUQ. The final results of ai, bi will be written in Tab. 10.
19
Table 10.
i
n=4 (N=16), 92x =σ
ia− ib−
1 ∞ 8,199 2 7,203 6,207 3 5,532 4,854 4 4,311 3,768 5 3,297 2,8272 6 2,3988 1,9704 7 1,5672 1,1643 8 0,7746 0,3852 9 0 –
Example 6
Optimize the non uniform quantizer with 4 levels using the companding method for the stationary sequence of random input samples with Laplace probability
density function f(a), with zero mean value and variance 42x =σ .
Solution
The structure of non uniform quantizer with compression of samples is in the Fig. 4. The objective is to find the optimal compression characteristic g(x), from which we can determine optimal values ai, bi. The practical range of available
values of input samples will be <-V0, V0>, where V0 = 5. 102.5x ==σ .
Optimal compression characteristic will be calculated using the equation for g(x), which we can adjust to this form
20
∫
∫
−
−+−=0
0
0
V
V
3/1
x
V
3/1
00
da)a(f
da)a(f
V2V)x(g , x ∈<−V0, V0>
After substitution for a
2
2a2
x
e22
1e
2
1)a(f x
−σ−
=σ
= , and for V0 = 10 we will
get
∫
∫
∫
∫
−
−
−
−
−
−
−
−
+−=
+−=10
10
a6
2
x
10
a6
2
10
10
3/1a
2
2
x
10
3/1a
2
2
dae
dae
2010
dae22
1
dae22
1
2010)x(g .
The compression characteristic is symmetric to the beginning, therefore we just calculate it in the first quadrant, where x ∈ (0, 10 >. Helpful integrals are
∫ ∫ ∫− −
−−=+=
x
10
0
10
x
0
a2
2a
2
2a
6
2
daedaedae
x6
2x
6
210
6
2
e23082,8)1e(2
6)e1(
2
6 −−−−=−−−= ,
∫ ∫−
−−==
10
10
10
0
a6
2a
6
2
68,7dae2dae .
21
Then
x6
2x6
2
e046,11046,1168,7
e23082,82010)x(g
−−
−=−+−=
is the optimal compression characteristic in the first quadrant. We can easily prove that in the third quadrant, where x ∈<−10, 0), is
x6
2
e046,11046,11)x(g +−= .
Next we calculate the quantization step of four levels uniform quantizer.
Because value V0 = 2Δ, the quantization step will be 52
10
2
V0 ===∆ .
With the help of compression characteristic in the first quadrant and quantization step we will calculate the decision level a4 result of ONUQ with companding.
From equation
∆=−=−
6
2a
44
e046,11046,11)a(g
we will get
55,2547,0ln2
6
046,11
5046,11ln
2
6
046,11
046,11ln
2
6a4 =−=−−=∆−−= .
We will get quantization levels b3 and b4 from expansion characteristic
22
h(y) = g-1(x), that is
046,11
y046,11ln
2
6)y(h
−−= y ∈ (0, 10>.
Then
09,1046,11
5,2046,11ln
2
6
046,11
2/046,11ln
2
6)
2(hb3 =−−=∆−−=∆= ,
82,4046,11
5,7046,11ln
2
6
046,11
2/3046,11ln
2
6)
2
3(hb4 =−−=∆−−=∆= .
In the Fig. 5. there is an illustrated process of obtaining transfer characteristic of ONUQ with companding (it’s one half characteristic in every quadrant), which is represented by levels a4, b3, b4 .
All decision and quantization levels of this ONUQ with companding are in Tab.11.
Table 11.
i
n=2 (N=4), 42x =σ
ia− ib−
1 ∞− - 4,82 2 - 2,55 - 1,09 3 0 1,09 4 2,55 4,82 5 ∞ -
23
Fig.5. The process of obtaining ONUQ transfer characteristic with companding.
For the calculation of mean square value of quantization noise we will use the results from the Example 4. Then given the symmetric progress of transfer characteristic of ONUQ with companding
∑ ∫ ∑ ∫= =
+ +
=−=−=σ4
1i
a
a
2
1i
a
a
2i
2i
2q
1i
i
1i
i
dx)x(f)bx(2dx)x(f)bx(
=
+++= ∫ ∫
−
∞− −
55,2 0
55,2
x2
22
x2
22 dxe
22
1)09,1x(dxe
22
1)82,4x(2
+
+−++−=
−
∞−
55,222x
2
2
)2
82,4282,482,42x2
2
x(e2
=
+−++−+
−
0
55,2
22x2
2
2
09,1209,1x09,12x2
2
x(e
OUQ
ONUQ
24
= 2(0,225 + 0,207) = 0,864.
Ratio dB66,6864,0
4log10log10SNR
2q
2x ==
σσ
= .
25
2. ENTROPY CODING
With variable-length coding we can reduce statistical redundancy of fixed length code, respectively the mean length of encoded word
i i
N
i 1
n p(b ) n∗
==∑ ,
where p(bi) is the probability of quantization level bi and ni is the length of encoded word corresponding to this level. Theoretically, according to Shannon’s theory of optimal coding, the minimal mean length of word is given by the zero order
entropy )X~
(H0 of quantizer, where
∑=
−=N
1ii2i0 )b(plog)b(p)X
~(H .
The most famous variable-length code is the Huffman’s code.
Efficiency of variable-length codes
*0
n
)X~
(H=η .
The digital signal we will characterize by the data rate or information rate.
Assuming the use of sampling frequency fs the data rate is
sf.nU = , [bit/sec].
Similarly the information rate
s1m f).X~
(MI −= , [bit/s].
where )x~(H 1m− is the entropy order m-1 of quantizer with m statistically
dependent quantization samples and can be calculated using the conditional probability of quantization samples.
In the case of statistically independent quantization samples is )x~(H)x~(H 01m =− .
26
Example 7.
Calculate the entropy of OUQ with n=3 bits and assume input stationary sequence of random samples with Laplace probability density function f(x), zero mean value
and variance 12x =σ . Next encode his quantization levels with the binary, Gray,
Huffman and Shannon-Fano codes and compare their efficiency.
Solution
We will calculate entropy of OUQ (N = 23 = 8) for statistically independent samples from the equation :
∑=
−=8
1ii2i0 )b(plog)b(p)x~(H .
We subtract 731,00 =∆ from the table for designing OUQ for Laplace probability
density function and n= 3 bit. Then we get un-normalized value
731,01.731,0x00 ==σ∆=∆ .
We can easily get the transfer characteristic of this OUQ from the general characteristic of OUQ.
We calculate the probability of quantization levels with the help of transfer characteristic of OUQ and Laplace probability density function
x2x
2
x
e2
1e
2
1)x(f x −σ
−=
σ= .
You just have to determine the probability of positive quantization levels, because transfer characteristic of OUQ is symmetric to the beginning. Then
∫ ∫∆
−− =−−===0
731,0
0
02731,0x25 322,0)ee(
2
1dxe
2
1dx)x(f)b(p ,
27
∫ ∫∆
∆
−−− =−−===2 462,1
731,0
2731,02462,1x26 115,0)ee(
2
1dxe
2
1dx)x(f)b(p ,
∫ ∫∆
∆
−−− =−−===3
2
193,2
462,1
2462,12193,2x27 041,0)ee(
2
1dxe
2
1dx)x(f)b(p ,
∫ ∫∞
∆
∞−∞−− =−−===
3 193,2
2193,2x28 0225,0)ee(
2
1dxe
2
1dx)x(f)b(p .
The final results are in Tab. 12.
Table 12.
bi b1 b2 b3 b4 b5 b6 b7 b8
p(bi) 0,0225 0,041 0,115 0,322 0,322 0,115 0,041 0,0225
While ∑=
=8
1ii 1)b(p must be confirmed.
Entropy of OUQ
∑=
++−=−=4
1i22i2i0 041,0log041,00225,0log0225,0(2)b(plog)b(p2)x~(H
bit395,2)322,0log322,0115,0log115,0 22 =++ .
In the process of fixed length coding, a codeword with constant length is added to every quantization level. The binary code (with number sign) and Gray code of OUQ are in Tab. 13.
28
The efficiency of this code:
80,03
395,2
n
)x~(H
n
)x~(H 0*
0 ====η .
Table 13.
Quantization Binary Gray
levels code code
b1 111 110
b2 110 111
b3 101 101
b4 100 100
b5 000 000
b6 001 001
b7 010 011
b8 011 010
In the process of variable-length coding shorter codewords are added to the quantization levels with bigger probability and longer codewords are added to the levels with smaller probability.
Acquisition of Huffman code for actual quantization levels are shown in Tab.14. Quantization levels b1 - b8 are sequenced according to the size of its own probability. If we merge the last two quantization levels b8 and b1 to one quantization level, we get a reduced number of these levels, e.g. 7. We execute the next reduction of quantization levels from 7 to 6 similarly to the first reduction and so on, until we have only 2 quantization levels, which we encode to 0 and 1. After that a reversed process follows, e.g. disjoining of quantization levels with adding the next bits.
29
Efficiency of code: *
0
n
)x~(H=η .
Mean length of codeword:
∑ ∑= =
∗ =++===8
1i
4
1iiiii bit486,2...)4.041,04.0225,0(2n)b(p2n)b(pn .
Then, the efficiency is: 96,0486,2
395,2 ==η .
Table 14.
The principle of acquisition of Shannon-Fano code is in Tab.15.
Quantization levels are sequenced according to the size of its own probability. The set of all quantization levels is divided into two subsets with approximately the same probability. We add the bit 0 to the quantization levels of first subset and bit 1 to the levels of quantization from second subset, as it’s in the first column (from left) of codewords. We divide the subsets of quantization levels into particular subsets with approximately the same probabilities, and we also add the bites 0 and 1. We end the process if the division of subsets is not possible anymore.
Quantization levels
Probability Making process of Huffman code Huffman code
30
Table 15.
From the tables it is clear, that in this case the Huffman and Shannon-Fano code are the same, and that’s why their efficiency is also the same.
Example 8.
Calculate the data rate and the information rate of digital signal if we assume the sampling frequency fs = 6,4 MHz, mean length of codeword n*= 4 bit and the quantization samples are independent. Their division of probability is in the table.
bi b1 až b6 b7 až b13 b14 až b16
p(bi) 0,11 0,04 0,02
Solution The data rate
s/Mbit6,2510.4,6.4f.nU 6s === .
The information rate
s1m f)x~(HI −= .
Shannon – Fano code Probability Quant. levels
31
For statistically independent quantization samples )x~(H)x~(H 01m =− , and
∑=
=++−=−=16
1i22i2i0 74,3...)04,0log04,0.711,0log11,0.6()b(plog)b(p)x~(H .
then s/Mbit94,2310.4,6.74,3f)x~(HI 6s0 === .
32
3. IMAGE PREDICTIVE CODING
Predictive coding (or DPCM – Different Pulse Code Modulation) is one of the most developed methods of effective image coding. Reducing the bit rate, respectively data compression is achieved primarily through here reduce statistical redundancy represented correlation of pel in the image. Typical properties prediction coding is: simple technical implementation, very small resistance to channel errors and considerable sensitivity to the statistical characteristic changes of input image. Block scheme of predictive coding and decoding system is shown in Fig. 6.
Fig.6 Block scheme of predictive system.
Optimization of PCS (Predictive Coding System) consists from optimizing the predictor, quantizer also encoder and means to minimize the mean square value of quantization noise (i.e. SNR is the maximum) for the determinate number of bits per pel and for the input image with the relevant statistical characteristic.
Signal to noise ratio - SNR - (in terms no-decibel) to output PCS we calculate:
2q
2xSNR
σσ= .
33
Following the extension equation of variance 2eσ i.e., mean square error of
predictor (apply the prediction gain 2e
2x /G σσ= ) we get
q2q
2e
2e
2x )SNR(.G.SNR =
σσ
σσ= .
This expression of overall SNR of PCS is equal multiplying prediction gain G and the SNR of quantizer (SNR)q (all in no-decibel terms).
Using exactly the same number of bits in the PCM and PCS, i.e.
PCMPCS mm = , will be
( ) ( )PCMPCS SNRGSNR =
what represents an increased quality of coding in PCS over the PCM.
If encoding quality is the same in the PCM and PCS, e.g. ( ) ( )PCMPCS SNRSNR = , then reduced redundancy
Gln1
mmR PCSPCM γ=−= [bits /sample]
For Gaussian and Laplace probability distribution is γ = 0.5 ln10, then
Glog2R = .
Example 9.
Analyze and optimize the possible modification of predictive coding systems (PCS) for image, which is modeled using a two-dimensional Gaussian-Markov field first order with zero mean value and autocorrelation function
( ) ( )'''' jjiiexpj,j,i,iR −β−−α−= , where constants 128,0=α , 0545,0=β and
so that ( )PCSSNR is equal approximately about 20 dB. Which of these
modifications achieves the highest data compression?
34
Solution
At first consider the case where the prediction of current pel of image used first previous pel on the same line. One, is the case of PCS with 1-dimensional optimal prediction in the horizontal direction (1D OPH) first order (s = 1). According to the relationship for prediction and for autocorrelation function along
the line ( i – i ′ = 0 ) form jj0545,0e)j,j(R ′−−=′ , it is possible to obtain the
following parameters of predictor:
- optimal prediction coefficient p10 = 0,9469 - prediction gain G = 9,67.
The number of bits optimized PCS determined from the following equation (constants 1=ψ , 10ln5,0=γ for Gaussian probability distribution)
( )[ ] ( )[ ]GlogSNRogl2GlnSNRln0,5ln10
1m PCSPCSPCS −=−=
(SNR)PCS = 20 dB which corresponds no-decibel value is equal 100, then
( ) bit026,27,9log100log2mPCS =−= .
We choose integer value bit2mPCS = which is also determined the number of bits
for quantizer of PCS.
Applying the optimal non uniform quantizer (ONUQ) and its corresponding transfer characteristic for Gaussian probability distribution, which is obtained from
reference tables for design ONUQ. Normalized quantization levels ib and decision
levels ia are calculated in Tab. 16, because the error samples entering in ONUQ
have variance 2eσ and
( )103,0
7,9
1
7,9
e
G
0,0R
Gσ
02x2
e ====σ=
Conversion of decision and quantization levels to un-normalized values was performed as follows:
35
iiiei a475,0a226,0aσa ===
iiiei b475,0b226,0bσb ===
In the middle of Tab.16 are the final decision and quantization level (ai, bi
are un-normalized values) of ONUQ and the end of table are the corresponding binary codewords with sign produced from the encoder PCS.
Reduced redundancy
( ) sample/bit973,17,9log2Glog2R h ===
at the same quality coding in PCM and reference PCS. It follows that using PCS instead of PCM we save 2 bit / sample.
Table 16.
Consider now the PCS with 1- dimensional optimal prediction in the vertical direction (1D OPV) first order (s = 1). Analogy with relations for
prediction and for autocorrelation function along the column (j – 'j = 0) form 'ii128,0' e)i,i(R
−−= it is possible to obtain the following parameters of predictor:
- optimal prediction coefficient p1o’ = 0,8798 - prediction gain G = 4,43.
Number of bits of PCS
Binary code with sign
36
( )[ ] sample/bit707,2]43,4log100[log2GlogSNRlog2m PCSPCS =−=−= .
Because mPCS must be integer, we choose mPCS = 3 bit.
Optimal PCS with 1D OPV (s = 1) is used ONUQ with n = mPCS = 3 bit. In
Tab. 17 are the normalized values of decision (ia ) and quantization (ib ) levels of
ONUQ for the Gaussian probability distribution. These are then converted, because the input of ONUQ is a sequence of error samples with variance
226,043,4
1
G
σσ
2x2
e === .
At the end of Tab. 17 is given a binary code encoder with sign for PCS.
Table 17.
Reduced redundancy of PCS is calculate from Eq.
( ) sample/bit293,143,4log2Glog2R v === .
Finally, consider the PCS with 2D optimal predictor. One can easily show that the prediction gain G = 42,45. Then the number of bits
( )[ ] ( ) bit744,045,42log100log2GlnSNRlog2m PCSPCS =−=−=
Binary code with sign
37
Choose an integer value bit1mPCS = . We make ONUQ optimization
(n = mPCS = 1 bit) analogically
iiiei a155,0a024,0aσa === ,
iiiei b155,0b024,0bσb === ,
while 024,045,42
1
G
σσ
2x2
e === .
Optimization results are in Tab. 18.
Similarly, reduced redundancy
( ) sample/bit256,345,42log2Glog2R h,v ===
at the same quality coding in PCM and PCS.
Table 18.
The comparison ( )hR , ( )vR , ( )h,vR shows that most data compression achieved with PCS with 2D predictor.
Binary code with sign
38
Example 10
Calculate the total energy of distortion in the decoded signal from predictive decoding system (PDS) which was caused by channel distortion b = 0,5 on one sample of encoded signal from the output of PCS.
Solution
On the output of PCS occurs prediction error samples be~e~ nn +=′ (Fig. 7)
with channel distortion “b”.
After that decoded samples are
bx~be~x~e~x~x~ nnnnnn +=++=′+=′ ,
with error also b. From this sample, the PDS calculated predictive sample
no11n x~px~ ′=′ + .
Then decoded another sample
( )bpx~bpe~x~bpe~x~p
e~bx~pe~x~pe~x~x~
o11no11n1no11nno1
1nno11nno11n1n1n
+=++=++=
=++=+′=+′=′
++++
+++++
has error equal p10b.
Error next decoded sample
( )bpx~bpe~x~bpe~x~p
e~bpx~pe~x~pe~x~x~
2o12n
2o12n2n
2o12n1no1
2no11no12n1no12n2n2n
+=++=++=
=++=+′=+′=′
+++++
+++++++
is equal p210b.
By analogy we calculated further error decoded samples and the error of
k-th sample is pk10b.
39
Fig.7. a) Channel distortion ”b” of prediction error samples b) distortion of decoded signal.
The above procedure shows that there is an expansion of channel distortion b of samples ne~′ on the output samples of prediction decoding system nx~′ (Fig.7b).
The total energy of distortion of decoded signal
( ) ( ) ( )∑∞
==+++=
0k
2ko1
222o1
2o1
2 pb...bpbpbB .
For the sum of geometric series we get
( ) ( )2o1
2o1
2ko1
k0k
2ko1
p1
1
p1
p1limp
−=
−−
=∞→
∞
=∑
, because p10 < 1.
40
Then
( ) 425,25,07,9Gbp1
1bB 22
2o1
2 ===−
=.
The size of this energy is proportional to the prediction gain G, that generally will depend on the type of predictor. Therefore design of predictors should not neglect the impact of channel errors on the decoded signal.
41
4. IMAGE TRANSFORM CODING
Transform coding uses the discrete orthogonal transform and PCM (Pulse Code
Modulation). Data compression is achieved mainly by suppressing irrelevant
spectral coefficients. Typical properties of transform coding are: high efficiency of
coding, complex technical implementation, small sensitivity to changes in the
statistical characteristics of input signals and distribution of quantization and
channel errors on the entire sample blocks. Important parameters of transform
coding system (TCS) that affect the coding efficiency are: type of discrete
orthogonal transform, the block size, selection and efficiency of quantization and
coding of spectral coefficients. Block scheme of TCS is at Fig. 8.
Fig. 8. Block scheme of transform coding system.
42
Mean square value of total distortion of encoded discrete stationary signal
with zero mean value in TCS is
2q
2s
2d σ+σ=σ ,
where σs2 is mean square value of distortion due to truncation of vector of spectral
coefficients Y to sY and σq2 is distortion due to quantization of vector sY , which
represents quantization noise. Then
∑=
−=J
1k
2y
2x
2s k
σM
1σσ and ∑
==
J
1k
2q
2q k
σM
1σ ,
where 2ykσ is variance of spectral coefficients, J is length of truncated vector sY
and 2qkσ is mean square value of quantization noise of k-th component of vector
sY . Assuming the use of ONUQ for quantization of components sY and
exponential model for calculation of 2qkσ , then we get modified expression
∑=
−=J
1k
2/n2y
2q
i
k10σ
M
1σ .
Optimize the TCS for some J and for average number of bits per sample
M/zmT = respectively bits per vector ∑=
==J
1kk .constnz means to minimize 2
dσ .
Result of this minimization are the optimal number of bits for individual
components of transformed vector Y , which is
σ−σ+= ∑
=
J
1i
2y
2yk ik
logJ
1log2
J
zn .
43
At first, in process of optimization of TCS we choose z or M/zmT = and
suitable J (which means neglecting of some last irrelevant spectral coefficients) for
which we calculate suitable nk (rounded to nearest integer number). We perform
calculating using certain z for several J. Optimal values n of individual ONUQ are
those for which (SNR)TCS is the biggest (respectively 2dσ is the smallest).
Assuming that we do not consider truncation of vector of spectral coefficients,
e.g. J = M , then 2sσ = 0 and for optimal TCS we get average number of bits per
component of vector Y
( )[ ]lnG N/Sln1
m TT −ψγ
= ,
where transform gain
M/1M
1i
2y
2x
iσ
σG
=
∏=
.
These equations are valid in general, that means even in the event of truncation of
vector spectral coefficients.
If we assume the same quality of coding in PCM and TCS, that means
( ) ( )TCSPCM SNRSNR = , then reduced redundancy
Gln γ
1m mR TPCM =−= ,
which is magnified by magnifying the transform gain G. If we introduce
substitution for γ =0,5ln10 (for Gaussian and Laplace probability density) and for
G too, we get
44
∑∏
=
=
σ
σ−=
σ
=M
1i2x
2y
M/1M
1i
2y
2x i
i
logM
2
σlog2R .
In case of equality TCSPCM m m = the TCS achieve higher quality of coding than
PCM and applies
( ) ( )PCMTCS SNRGSNR = .
In two-dimensional coding of correlated signals we achieve greater data
compression using two-dimensional transform coding system (2D TCS).
Mean square value of total distortion 2dσ of coded signal with 2D TCS we
calculate
∑∑∑∑= == =
+−='
km
'
km
J
1k
J
1m
2q2
J
1k
J
1m
2y2
2x
2d σ
M
1σ
M
1 σσ ,
where first two expressions represents the mean square value of distortion under
influence of two-dimensional truncation matrix Y of spectral coefficients from
size MxM to size JxJ and third expression represents is the mean square value of
distortion under influence of coding of truncated matrix sY of spectral coefficients
(e.g. quantization noise). Value 2qkmσ is mean square value of quantization noise of
(k,m)-th component of sY .
Optimal distribution of bits to matrix (block) of samples
∑ ∑= =
=='J
1k
J
1mkm .constn z
45
For certain 'J , M J< and Gaussian, respectively Laplace probability distribution,
then
σ−+= ∑∑
= =
'
ijkm
J
1i
J
1j
2y'
2y'
'
km logJJ
1 σlog2
JJ
zn
when 2dσ (total distortion) is minimal. In process of optimization of 2D TCS we
again firstly choose value z or 2T M/zm = and suitable 'J , J. For them we
calculate kmn (rounded to integer number). Calculation is performed for certain
„z“ for several 'J and J. Optimal values kmn of individual ONUQ are those, for
which SNR is the biggest.
Transform gain
∏∏= =
σ
σ=M
1i
M
1j
M/12y
2x
2
ij)(
G
Example 11.
Optimize TCS with Walsh-Hadamar transform (WHT) for image, which is
modeled by 2D discrete Gaussian-Markov field of first order with zero mean value
and autocorrelation function ( ) ( )'''' jjβiiαexpj,j,i,iR −−−−= while 128,0=α ,
0545,0=β so that (SNR)TCS will be approximately 20dB. Consider size of input
vector M=4, which means that quartets of image elements will form the
components of input vector to this TCS. After WHT, variances of spectral
coefficients have these values: 741,3σ2
1=y , 153,0σ2
2=y , 055,0σ2
3=y , 051,0σ2
y4= . Do
not consider truncation of block. At the end calculate reduced redundancy of this
system compared to the reference system PCM.
46
Solution
On the Fig.9 is structure of considered TCS and on Fig.10 is image divided into blocks of picture elements (M=4), from which are in block of segmentation created input vectors for this TCS.
Fig. 9. Block scheme of TCS with WHT (M=4).
Fig. 10. Image division to blocks of picture elements (M=4).
Segmentation Processor WHT
ONUQ Uniform Coder
PCM1
PCM2
PCM3
PCM4
MULTIPLEX
47
At first we determine average number of bits per sample for TCS to achieve desired (SNR)TCS , while for Gaussian probability distribution are constants 1=ψ
and 10ln5,0=γ . We know that 20dB corresponds to no-decibel value of 100.
Then
( )[ ] ( )[ ] [ ]Glog100log2GlogSNRlog2GlnSNRln0,5ln10
1m TCSTCST −=−=−= .
We get transform gain G from
( )996,4
2002,0
e
051,0.055,0.153,0.741,3
)0,0(R
)σ(
G0
4/14/1
4
1i
2y
2x
1
===σ
=∏
=
and then ( ) sample/bits603,2996,4log22mT =−=
Number of bits per vector
block/bits411,104.603,2Mmz T ===
but this value must be integer number so we choose: z = 11 bits/block
Next we find optimal distribution of number of bits per individual components
(spectral coefficients) of vector Y
−σ+= ∑
=
4
1i
2y
2yk ik
σlog4
1log2
4
zn
, where
J = M = 4, because do not consider truncation of blockY .
First we calculate constant
( ) 699,0051,0log055,0log153,0log741,3log4
1log
4
1 4
1i
2yi
−=+++=σ∑=
.
48
Number of bits of individual spectral coefficients (Y1, Y2, Y3, Y4) are:
( )[ ] ( ) bit294,5699,0741,3log24
11699,0σlog2
4
11n 2
y1 1=++=−−+=
[ ] ( ) bit518,2699,0153,0log24
11699,0σlog2
4
11n 2
y2 2=++=++=
[ ] ( ) bit628,1699,0055,0log24
11699,0σlog2
4
11n 2
y3 3=++=++=
[ ] ( ) bit564,1699,0051,0log24
11699,0σlog2
4
11n 2
y4 4=++=++=
Because we need integer values in ( i=1, 2, 3, 4), we must at first round calculated
values so that ∑=
=4
1ii zn . There is more options, while criteria is minimal mean
square value total distortion 2dσ .
Let us consider two combinations of bits:
first second
n1=5 bit n1=5 bit
n2=3 bit n2=2 bit
n3=2 bit n3=2 bit
n4=1 bit n4=2 bit
zbit11n4
1ii ==∑
= zbit11n
4
1ii ==∑
=
49
We calculate total distortion 2dσ for both proposed combinations while 02
s =σ ,
because we do not consider truncation of block:
( )
( ) 00953,0016,00055,00048,00118,04
1
10.051,010.055,010.153,010.741,34
110σ
4
1
)e(σ4
1eσ
4
1nγ-expσ
4
1σ
2
1
2
2
2
3
2
5
2
n4
1k
2y
n5,0-10ln4
1k
2y
n.10ln5,0-4
1k
2yk
4
1k
2y
2d
k
k
k
k
k
kk1
=+++=
=
+++==
====
−−−−−
=
===
∑
∑∑∑
and
( ) 00943,00051,00055,00153,00118,04
1
10.051,010.055,010.153,010.741,341
10σ41
σ 1-1-1-2
5
2
n4
1k
2y
2d
k
k2
=+++=
=
+++==
−−
=∑
From comparison we can see that 2d
2d 12
σσ < , therefore the second combination of
bits distribution is better and we will consider it by optimization of individual
PCMi in each branch of this TCS, while i=1, 2, 3, 4.
For PCM1 we optimize ONUQ1 with number of bits n = n1 = 5 bits using
tables for design of ONUQ, while its un-normalized decision values (ai) and
quantization levels (bi) are calculated so
iiiyi a934,1a741,3aσa1
=== iiyi b934,1bσb
1==
Results of this optimization are in Tab. 19. together with corresponding code
words.
50
Results of optimization of PCM2 are in Tab. 20, where ONUQ has n = n2 = 2 bits
and on its input is variance equal 153,02y2
=σ , thus calculated un-normalized
decision and quantization levels are
iiiyi a391,0a153,0aσa2
=== , iiyi b391,0bσb2
== .
Analogically are in Tab. 21. results of optimization PCM3 and in Tab. 22. are results of optimization PCM4.
Reduced redundancy for same quality of coding in TCS and reference system PCM is determined by
sample/bit397,1996,4log2
)(
log2R4/1
4
1i
2y
2x
i
==σ
σ=
∏=
For about the same quality of coding in TCS and PCM and for average number of
bits per sample in TCS
sample/bit75,24
11
M
zmT ===
reduced redundancy will be
sample/bit25,175,24mmR TPCM =−=−=
51
Table 19.
Binary code with sign
52
Table 20.
Table 21.
Table 22.
Binary code with sign
Binary code with sign
Binary code with sign
53
5. IMAGE HYBRID CODING
Hybrid coding of two-dimensional correlated signals is using one-dimensional or two-dimensional discrete orthogonal transformation and DPCM systems (Differential Pulse Code Modulation). The block scheme of hybrid coding system (HCS) is shown in Fig. 11.
Fig. 11. Block scheme of hybrid coding and decoding systems.
Optimization procedure of hybrid coding system is analogue to the method of optimizing TCS. Total distortion of encoded signal HCS will also consist of
distortion which is influenced by truncation of vector Y to sY and by influence of
coding sY by DPCM, while 2sσ does not change but 2qσ decreases. Assuming use
.
.
.
.
.Decoder
Decoder
Decoder
PROCE-SSOR
Coder
Coder
Coder
54
of ONUQ in HCS and the exponential model, then we have 2dσ - total distortion of
encoded signal of HCS expressed as follows
( )∑∑==
−+−=J
1kk
2e
J
1k
2y
2x
2d nγexpψσf
M
1σ
M
1σσ
kk ,
where 2ekσ are the variances of error coefficients ( kkk Y -Ye = ), there are the
resulting of prediction of spectral coefficients.
The optimal distribution of the number of bits for its spectral coefficients, respectively for every DPCMi coding systems, it follows equation (value z is a number of bits for vector)
σ−σ+= ∑=
J
1i
2e
2ek ik
logJ
1log2
J
zn ,
while we expect Gaussian or Laplace distribution for error coefficients ek.
Similarly, assuming that we do not consider truncation of vector spectral
coefficients ( 02s =σ ), we obtain analogue equations for ( )HSNR , Hm and R,
while the hybrid gain
M/1M
1i
2e
2x
iσ
σG
=
∏= .
55
When optimizing a two-dimensional hybrid coding system (2D HCS) we
proceed analogously to optimize 2D TCS. Again 2sσ does not change, but 2qσ
decreases by influence of encoding spectral coefficients using DPCM. When we assume the using of ONUQ in 2D HCS, the total distortion of this system will be
( )km
J
1k
J
1m
2e2
J
1k
J
1m
2y2
2x
2d nexp
Mσ
M
1σσ
'
km
'
kmγ−σψ+−= ∑∑∑∑
= −= = ,
where 2ekmσ are the variance of error coefficients
Optimal distribution of number of bits for each spectral coefficients, respectively DPCMkm coding systems follows from the equation
−+= ∑∑
= =
'
ijkm
J
1i
J
1j
2e'
2e'
'
km σlogJJ
1σlog2
JJ
zn
,
while again assume Gaussian or Laplace distribution for error coefficients.
Similarly, assume that we do not consider truncation of matrix spectral
coefficients ( 0=σ2s ), we obtain analogous equations for ( )HSNR , Hm a R of
2D HCS, with the hybrid gain
2
ij
M/1M
1i
M
1j
2e
2x
σ
σG
=
∏∏= = .
56
Example 12.
Optimize HCS with the slant transform (ST) for the image, which is modeled by two-dimensional discrete Gaussian-Markov field first order with zero mean and autocorrelation function
( ) ( )'''' jjβiiαexpj,j,i,iR −−−−=,
while 128,0=α , 0545,0=β so that approximately H)SNR( = 20 dB. Calculate the
reduced redundancy of this system to a reference system PCM.
Solution
At first we divided image into blocks of pixels, as shown in Fig.12, which are transform using ST (size of block M = 4). From correlation analyses of our discrete Gaussian – Markov process we know that the largest correlation between blocks in space ST is in the vertical direction, while the normalized correlation function in this direction is the same for all subfields spectral coefficients, i.e.
( ) τ= 128,0-vk eτc , k = 1,2,3,4.
Un-normalized correlation functions in the vertical direction are dependent on variances of spectral coefficients
( ) ( ) ( ) ( ) τ−σ=σ== 128,02y
vk
2y
vk
vk
vk eτcτc0CτC
kk ,
while individual variances are values
74165,32y1
=σ ,
05437,0σ2y3
= ,
17,0σ2y2
= ,
0327,0σ2y4
= .
57
Fig.12. The distribution of picture elements into blocks.
We perform optimization of HCS, which is shown in Fig. 13. At first we optimize individual prediction coding systems (PCSk), e.g. DPCMk, where k = 1,2,3,4. We also consider the optimal first order prediction (s = 1) in vertical direction in all
individual PCSk. Equation for this prediction ( ( ) ( ) o1vk
vk p0c1c = ) indicates that the
optimal prediction coefficient
( )( )
( ) 8798,0e1c0c
1cp 128,0v
kvk
vk
o1 ==== −
.
Normalized correlation functions ( )τcvk are identical for all subfields of spectral
coefficients ST and therefore must be predictors in all PCSk the same.
Individual mean square values of error coefficients calculated from Eq.
( )( ) ( ) 2y
22y
vko1
2y
2e kkkk
22595,08798,01σ1cp1σσ σ=−=−= .
58
Fig. 13. Block scheme of HCS with ST for M = 4.
Then
8454,07415,3.22595,0σ22595,0σ 21y
21e
=== ,
03841,017,0.22595,0σ22595,0σ 2y
2e 22
===,
01228,005437,0.22595,0σ22595,0σ 2y
2e 33
===,
00739,00327,0.22595,0σ22595,0σ 2y
2e 44
=== .
Assume that the number of bits per vector (block) z = 6 bits / sample, and the length of truncated block J = 3.
For the total distortion 2dσ we get
∑ ∑= =
γ−ψσ+σ−σ=σ+σ=σ3
1k
3
1kk
2e
2y
2x
2q
2s
2d )n(exp
4
1
4
1kk
.
Segmentation Processor ST
ONUQ
delay
Coder
PCS 1
PCS 2
PCS 3
PCS 4
MULTIPLEX
59
Mean square error of truncated vector sY will be
( ) ( )
( ) 00849,09915,0105437,017,074165,34
11
4
10,0R
4
1 3
1k
2y
2y
2y
2y
2x
2s 321k
=−=++−
=σ+σ+σ−=σ−σ=σ ∑=
.
Optimal distribution of number of bits for each spectral coefficients of truncated
vector sY determinate from Eq.
)log3
1log(2
J
zn
3
1i
2e
2ek ik ∑
=σ−σ+=
, k = 1,2,3
with constant
( ) 133,110.987,3log3
1log
3
1log
3
1 42e
2e
2e
3
1i
2e 321i
−==σσσ=σ −
=∑
.
The number of bits of coded spectral coefficients (Y1, Y2, Y3) are
( ) ( ) bit12,412,22133,18454,0log22133,1log2
3
6n 2
e1 1=+=++=+σ+=
,
( ) ( ) bit435,1565,02133,103841,0log22133,1σlog22n 2e2 2
=−=++=++=,
( ) ( ) bit223,1777,02133,101228,0log22133,1σlog22n 2e3 3
=−=++=++=.
Because we require integer values ni, i = 1,2,3, we have calculated values rounded
to ∑=
=3
1ii zn . Correctness criterion rounding is the minimum mean total distortion.
The choice is quite clear, therefore consider
60
bit4n1 =
bit1n2 =
bit1n3 =
∑=
==3
1ii zbit6n
.
If constants 1=ψ , 10ln5,0=γ then from equation for 2dσ (total distortion) we
have
∑∑∑=
−−
=
−
=σ+σ=σ+σ=σ+σ=σ
3
1k
2
n2e
2s
n5,010ln3
1k
2e
2s
n10ln5,03
1k
2e
2s
2d
k
kk
kk
k10
4
1)e(
4
1e
4
1
.
Substituting for 2sσ
( )( )
.0145,002448,04
1
00849,010.01228,010.03841,010.8454,04
1
00849,01010104
100849,0
2/12/12/4
2/3n23e
2/2n22e
2/1n21e
2d
=+
+=+++
+=σ+σ+σ+=σ
−−−
−−−
Let J = N = 4, we do not consider truncation of block. Optimal distribution of number of bits “z” for individual spectral coefficients will be
−+= ∑
=
4
1i
2e
2ek ik
σlog4
1σlog2
M
zn
,
with constant
61
( ) 133,110.947,2log4
100739,0.01228,0.03841,0.8454,0log
4
1
σσlog4
1log
4
1log
4
1
5
2e
2e
4
1i
2e
2e
2e
4
1ii
2e 4321i
−===
=σσ=σ=σ
−
==∏∑
Then
( ) ( ) bit62,312,25,1133,18454,0log25,1133,1σlog24
6n 2
e1 1=+=++=++=
( ) ( ) bit935,0565,05,1133,103841,0log25,1133,1σlog25,1n 2e2 2
=−=++=++=
( ) ( ) bit723,0777,05,1133,101228,0log25,1133,1σlog25,1n 2e3 3
=−=++=++=
( ) ( ) bit497,0997,15,1133,100739,0log25,1133,1σlog25,1n 2e4 4
−=−=++=++=
The calculated values have to be rounded to integers such that ∑=
=4
1ii zn and that
2dσ was minimal.
We consider these three combinations of distribution of number of bits:
first: bit4n1 = second: bit4n1 = third: bit3n1 =
bit1n2 = bit2n2 = bit1n2 =
bit1n3 = bit0n3 = bit1n3 =
bit0n4 = bit0n4 = bit1n4 =
∑=
==4
1ii zbit6n ∑
===
4
1ii zbit6n ∑
===
4
1ii zbit6n .
The first combination is the same as distribution the number of bits for each
spectral coefficient vector Y , when we consider truncated block (J = 3). The mean
square total distortion is the same, i.e. 0145,02d
21d =σ=σ .
62
For the second combination effects of zero bits last two spectral coefficients is a truncation of block and the length of truncated block J = 2. Then the mean square error
( ) ( )( ) ( )
0252,00031,0
9779,0110.03841,010.8454,04
117,074165,3
4
11
)10σ10σ(4
1σσ
4
10,0R
10σ4
1σ
4
1σσσσ
12
2/n2e
2/n2e
2y
2y
2
1k
2/n2e
2
1k
2y
2x
2q
2s
2d
22
1121
kkk2
=+
+−=+++−=
=+++−=
=+−=+=
−−
−−
=
−
=∑∑
For the third combination does not result in a truncated block and its mean square error
( )
( )0113,00451,0
4
1
10.00739,010.01228,010.03841,010.8454,04
1
10σ10σ10σ10σ4
110
4
1
2/12/12/12/3
2/4n24e
2/3n23e
2/2n22e
2/1n21e
4
1k
2/kn2ke
23d
==
=+++=
=+++=σ=σ
−−−−
−−−−
=
−∑
The comparison showed that 22d
21d
23d σ<σ<σ , so is preferred the third
combination of number of bits. Next, we calculate the exact value of ( )HSNR , so
that we can appreciate the choice of “z”, e.g. the number of bits per vector.
( ) dB5,190113,0
1log10
1log10SNR
2d
H
3
==σ
= .
This value ( )HSNR is close to the desired value of 20dB, therefore the choice
z = 6 bits /vector is sufficient.
63
Optimization of individual ONUQ will be performed in analogue manner as in Example 11.
Reduced redundancy of same quality coding in reference system PCM and HCS is
sample/bit5,25,144
64
M
zmmmR PCMHPCM =−=−=−=−= .
64
REFERENCES
[1] Mihalík,J.: Image Coding in Videocommunications. LDIPV FEI TU Košice, 2001, ISBN 80-89061-47-8. (In Slovak)
[2] Mihalík, J.: Effective Image Coding. LDIPV FEI TU Košice, 2013, ISBN 978-80-553-1373-3. (In Slovak)
[3] Mihalík, J. - Gladišová, I.: Image Coding (Rules on Exercises). LDIPV FEI TU Košice, 2012, ISBN 978-80-553-0894-4. (In Slovak)
[4] Gladišová, I.- Mihalík, J.: Quantization and Entropy Coding (Rules on Exercises). LDIPV FEI TU Košice, 2012, ISBN 978-80-553-0878-4. (In Slovak)
[5] Mihalík, J.: Digital Signal Processing. Alfa, Bratislava, 1987, ISBN 80-05-00786-8. (In Slovak)
[6] Mihalík, J. - Gladišová, I.: Digital Signal Processing (Rules on Exercises). Alfa Bratislava, 1989, ISBN 80-05-00275-0. (In Slovak)
[7] Poehler, P. L. - Choi, J.: Linear Predictive Coding of Imagery for Data Compression Applications. Proc.IEEE Intl.Conf.Acoust.,Speech, and Signal Proc.,1983, p.1240 - 1243.
[8] Daut, D. G.-Fries, R. W. - Modestino, J. W.: Two - Dimensional DPCM Image Coding Based on an Assumed Stohastic Image Model. IEEE Trans. Commun., Vol. COM - 29, No.9, 1981, p.1365 - 1374.
[9] Clarke, R.J.: Transform Coding of Images. Academic Press, New York, 1985.
[10] Jayant, N.S. - Noll, P.: Digital Coding of Waveforms, Principles and Applications to Speech and Video. Prentice Hall, New Jersey, 1984.
[11] Daut, D. G.: Two - Dimensional Hybrid Image Coding and Transmission. Proc.SPIE, Vol.845 Visual Commun. and Image Proc., 1987, p.24 - 31.
65
NÁZOV: Solutions of Image Coding Problems
AUTORI: Mihalík Ján, Gladišová Iveta
VYDAVATE Ľ: Technická univerzita v Košiciach
ROK: 2014
VYDANIE: prvé
NÁKLAD: 50 ks
ROZSAH: 65 strán
ISBN: 978-80-553-1640-6