In the quantization process, the amplitude of an analog signal sample is compared to a set of decision levels.. If the sample amplitude falls between two decision levels, it is quantized
Trang 16
IMAGE QUANTIZATION
Any analog quantity that is to be processed by a digital computer or digital system must be converted to an integer number proportional to its amplitude The
conver-sion process between analog samples and discrete-valued samples is called quanti-zation The following section includes an analytic treatment of the quantization
process, which is applicable not only for images but for a wide class of signals encountered in image processing systems Section 6.2 considers the processing of quantized variables The last section discusses the subjective effects of quantizing monochrome and color images
6.1 SCALAR QUANTIZATION
Figure 6.1-1 illustrates a typical example of the quantization of a scalar signal In the quantization process, the amplitude of an analog signal sample is compared to a set
of decision levels If the sample amplitude falls between two decision levels, it is quantized to a fixed reconstruction level lying in the quantization band In a digital system, each quantized sample is assigned a binary code An equal-length binary code is indicated in the example
For the development of quantitative scalar signal quantization techniques, let f
and represent the amplitude of a real, scalar signal sample and its quantized value,
respectively It is assumed that f is a sample of a random process with known
proba-bility density Furthermore, it is assumed that f is constrained to lie in the range
(6.1-1)
fˆ
p f( )
a L≤ ≤f a U
Digital Image Processing: PIKS Inside, Third Edition William K Pratt
Copyright © 2001 John Wiley & Sons, Inc ISBNs: 0-471-37407-5 (Hardback); 0-471-22132-5 (Electronic)
Trang 2142 IMAGE QUANTIZATION
where and represent upper and lower limits
Quantization entails specification of a set of decision levels and a set of recon-struction levels such that if
(6.1-2)
the sample is quantized to a reconstruction value Figure 6.1-2a illustrates the placement of decision and reconstruction levels along a line for J quantization lev-els The staircase representation of Figure 6.1-2b is another common form of
description
Decision and reconstruction levels are chosen to minimize some desired
quanti-zation error measure between f and The quantiquanti-zation error measure usually
employed is the mean-square error because this measure is tractable, and it usually
correlates reasonably well with subjective criteria For J quantization levels, the
mean-square quantization error is
(6.1-3)
FIGURE 6.1-1 Sample quantization.
256 11111111 11111110
00100000
00000010 00000001 00000000 ORIGINAL
SAMPLE
DECISION LEVELS
BINARY CODE
QUANTIZED SAMPLE
RECONSTRUCTION LEVELS
00011111 00011110
255 254
33 32 31 30
3 2 1 0
a U a L
d j
r j
d j≤f<d j+1
r j
fˆ
E E{(f–fˆ)2} (f–fˆ)2p f ( ) f d (f–r j)2p f ( ) f d
J 1–
∑
=
a L
a U
∫
Trang 3SCALAR QUANTIZATION 143
For a large number of quantization levels J, the probability density may be
repre-sented as a constant value over each quantization band Hence
(6.1-4)
which evaluates to
(6.1-5)
The optimum placing of the reconstruction level within the range to can
be determined by minimization of with respect to Setting
(6.1-6)
yields
(6.1-7)
FIGURE 6.1-2 Quantization decision and reconstruction levels.
p r( )j
E p r( )j (f–r j)2d f
d j
d j+1
∫
j 0=
J 1–
∑
=
3
- p r ( ) d j [( j+ 1–r j)3–(d j–r j)3]
j 0=
J 1–
∑
=
E d
r j d
- = 0
r j d j+1+d j
2
-=
Trang 4144 IMAGE QUANTIZATION
Therefore, the optimum placement of reconstruction levels is at the midpoint between each pair of decision levels Substitution for this choice of reconstruction levels into the expression for the quantization error yields
(6.1-8)
The optimum choice for decision levels may be found by minimization of in Eq 6.1-8 by the method of Lagrange multipliers Following this procedure, Panter and Dite (1) found that the decision levels may be computed to a good approximation from the integral equation
(6.1-9a)
where
(6.1-9b)
for j = 0, 1, , J If the probability density of the sample is uniform, the decision
lev-els will be uniformly spaced For nonuniform probability densities, the spacing of decision levels is narrow in large-amplitude regions of the probability density func-tion and widens in low-amplitude porfunc-tions of the density Equafunc-tion 6.1-9 does not reduce to closed form for most probability density functions commonly encountered
in image processing systems models, and hence the decision levels must be obtained
by numerical integration
If the number of quantization levels is not large, the approximation of Eq 6.1-4 becomes inaccurate, and exact solutions must be explored From Eq 6.1-3, setting the partial derivatives of the error expression with respect to the decision and recon-struction levels equal to zero yields
(6.1-10a)
(6.1-10b)
12
- p r ( ) d j ( j+ 1–d j)3
j 0=
J 1–
∑
=
E
d j
a U–a L
( ) [p f( )]–1 3⁄
f d
a L
a j
∫
p f( ) [ ]–1 3⁄
f d
a L
a U
∫
-=
a j j a( U–a L)
J - a+ L
=
E
∂
d j
∂ - = (d j–r j)2p d( )j –(d j–r j–1)2p d( )j = 0
E
∂
r
∂
- 2 (f–r j )p f ( ) f d
d
d j+1
Trang 5SCALAR QUANTIZATION 145
Upon simplification, the set of equations
(6.1-11a)
(6.1-11b)
is obtained Recursive solution of these equations for a given probability distribution provides optimum values for the decision and reconstruction levels Max (2) has developed a solution for optimum decision and reconstruction levels for a Gaus-sian density and has computed tables of optimum levels as a function of the number
of quantization steps Table 6.1-1 lists placements of decision and quantization
lev-els for uniform, Gaussian, Laplacian, and Rayleigh densities for the Max quantizer.
If the decision and reconstruction levels are selected to satisfy Eq 6.1-11, it can easily be shown that the mean-square quantization error becomes
(6.1-12)
In the special case of a uniform probability density, the minimum mean-square quantization error becomes
(6.1-13)
Quantization errors for most other densities must be determined by computation
It is possible to perform nonlinear quantization by a companding operation, as shown in Figure 6.1-3, in which the sample is transformed nonlinearly, linear quanti-zation is performed, and the inverse nonlinear transformation is taken (3) In the com-panding system of quantization, the probability density of the transformed samples is forced to be uniform Thus, from Figure 6.1-3, the transformed sample value is
(6.1-14)
where the nonlinear transformation is chosen such that the probability density
of g is uniform Thus,
FIGURE 6.1-3 Companding quantizer.
r j = 2d j–r j–1
r j
fp f ( ) f d
d j
d j+1
∫
p f ( ) f d
d j
d j+1
∫
-=
p f( )
Emin f2p f ( ) f d r j2 p f ( ) f d
d j
d j+1
∫
–
d j
d j+1
∫
j= 0
J– 1
∑
=
Emin 1
12J2
-=
g = T f{ }
T{ }·
Trang 6146 IMAGE QUANTIZATION
TABLE 6.1-1 Placement of Decision and Reconstruction Levels for Max Quantizer
Uniform Gaussian Laplacian Rayleigh
1 –1.0000 –0.5000 – –0.7979 – –0.7071 0.0000 1.2657 0.0000 0.5000 0.0000 0.7979 0.0000 0.7071 2.0985 2.9313
2–1.0000 –0.7500 – –1.5104 –1.8340 0.0000 0.8079 –0.5000 –0.2500 –0.9816 –0.4528 –1.1269 –0.4198 1.2545 1.7010 –0.0000 0.2500 0.0000 0.4528 0.0000 0.4198 2.1667 2.6325 0.5000 0.7500 0.9816 1.5104 1.1269 1.8340 3.2465 3.8604 1.0000
3 –1.0000 –0.8750 – –2.1519 – –3.0867 0.0000 0.5016 –0.7500 –0.6250 –1.7479 –1.3439 –2.3796 –1.6725 0.7619 1.0222 –0.5000 –0.3750 –1.0500 –0.7560 –1.2527 –0.8330 1.2594 1.4966 –0.2500 –0.1250 –0.5005 –0.2451 –0.5332 –0.2334 1.7327 1.9688 0.0000 0.1250 0.0000 0.2451 0.0000 0.2334 2.2182 2.4675 0.2500 0.3750 0.5005 0.7560 0.5332 0.8330 2.7476 3.0277 0.5000 0.6250 1.0500 1.3439 1.2527 1.6725 3.3707 3.7137 0.7500 0.8750 1.7479 2.1519 2.3796 3.0867 4.2124 4.7111 1.0000
4 –1.0000 –0.9375 – –2.7326 – –4.4311 0.0000 0.3057 –0.8750 –0.8125 –2.4008 –2.0690 –3.7240 –3.0169 0.4606 0.6156 –0.7500 –0.6875 –1.8435 –1.6180 –2.5971 –2.1773 0.7509 0.8863 –0.6250 –0.5625 –1.4371 –1.2562 –1.8776 –1.5778 1.0130 1.1397 –0.5000 –0.4375 –1.0993 –0.9423 –1.3444 –1.1110 1.2624 1.3850 –0.3750 –0.3125 –0.7995 –0.6568 –0.9198 –0.7287 1.5064 1.6277 –0.2500 –0.1875 –0.5224 –0.3880 –0.5667 –0.4048 1.7499 1.8721 –0.1250 –0.0625 –0.2582 –0.1284 –0.2664 –0.1240 1.9970 2.1220 0.0000 0.0625 0.0000 0.1284 0.0000 0.1240 2.2517 2.3814 0.1250 0.1875 0.2582 0.3880 0.2644 0.4048 2.5182 2.6550 0.2500 0.3125 0.5224 0.6568 0.5667 0.7287 2.8021 2.9492 0.3750 0.4375 0.7995 0.9423 0.9198 1.1110 3.1110 3.2729 0.5000 0.5625 1.0993 1.2562 1.3444 1.5778 3.4566 3.6403 0.6250 0.6875 1.4371 1.6180 1.8776 2.1773 3.8588 4.0772 0.7500 0.8125 1.8435 2.0690 2.5971 3.0169 4.3579 4.6385 0.8750 0.9375 2.4008 2.7326 3.7240 4.4311 5.0649 5.4913 1.0000
Trang 7PROCESSING QUANTIZED VARIABLES 147
(6.1-15)
for If f is a zero mean random variable, the proper transformation
func-tion is (4)
(6.1-16)
That is, the nonlinear transformation function is equivalent to the cumulative
proba-bility distribution of f Table 6.1-2 contains the companding transformations and
inverses for the Gaussian, Rayleigh, and Laplacian probability densities It should
be noted that nonlinear quantization by the companding technique is an approxima-tion to optimum quantizaapproxima-tion, as specified by the Max soluapproxima-tion The accuracy of the approximation improves as the number of quantization levels increases
6.2 PROCESSING QUANTIZED VARIABLES
Numbers within a digital computer that represent image variables, such as lumi-nance or tristimulus values, normally are input as the integer codes corresponding to the quantization reconstruction levels of the variables, as illustrated in Figure 6.1-1
If the quantization is linear, the jth integer value is given by
(6.2-1)
where J is the maximum integer value, f is the unquantized pixel value over a
lower-to-upper range of to , and denotes the nearest integer value of the argument The corresponding reconstruction value is
(6.2-2)
Hence, is linearly proportional to j If the computer processing operation is itself linear, the integer code j can be numerically processed rather than the real number
However, if nonlinear processing is to be performed, for example, taking the
loga-rithm of a pixel, it is necessary to process as a real variable rather than the integer j
because the operation is scale dependent If the quantization is nonlinear, all process-ing must be performed in the real variable domain
In a digital computer, there are two major forms of numeric representation: real and integer Real numbers are stored in floating-point form, and typically have a large dynamic range with fine precision Integer numbers can be strictly positive or bipolar (negative or positive) The two's complement number system is commonly
p g( ) = 1
1
2
– g 1
2
≤ ≤
T f{ } p z ( ) z 1 d –2
∞ –
f
∫
=
j (J–1) f–a L
a U–a L
-N
=
a L a U [ ]· N
r j a U–a L J - j a U–a L
2J - a L
=
r j
r j
r j
Trang 8f 2σ
1 rf 2
f 2σ
f 2 σ
f 2σ
1 - 2
f 2σ
1 - 2
⁄
α 2
1 -1 2
1 -1 2
1 - α
1 -ln α
2g
2 π
2 σ
Trang 9PROCESSING QUANTIZED VARIABLES 149
used in computers and digital processing hardware for representing bipolar integers The general format is as follows:
S.M1,M2, ,M B-1 where S is a sign bit (0 for positive, 1 for negative), followed, conceptually, by a binary point, M b denotes a magnitude bit, and B is the number of bits in the
com-puter word Table 6.2-1 lists the two's complement correspondence between integer, fractional, and decimal numbers for a 4-bit word In this representation, all pixels are scaled in amplitude between –1.0 and One of the advantages of
TABLE 6.2-1 Two’s Complement Code for 4-Bit Code Word
Code
Fractional Value
Decimal Value
1.0 2– –(B–1)
7 8 -6 8 -5 8 -4 8 3 8 -2 8 -1 8
-1 8 2 8 -3 8 -4 8 -5 8 -6 8 7 8 -8 8
Trang 10-150 IMAGE QUANTIZATION
this representation is that pixel scaling is independent of precision in the sense that a pixel is bounded over the range
regardless of the number of bits in a word
6.3 MONOCHROME AND COLOR IMAGE QUANTIZATION
This section considers the subjective and quantitative effects of the quantization of monochrome and color images
6.3.1 Monochrome Image Quantization
Monochrome images are typically input to a digital image processor as a sequence
of uniform-length binary code words In the literature, the binary code is often
called a pulse code modulation (PCM) code Because uniform-length code words
are used for each image sample, the number of amplitude quantization levels is determined by the relationship
(6.3-1)
where B represents the number of code bits allocated to each sample.
A bit rate compression can be achieved for PCM coding by the simple expedient
of restricting the number of bits assigned to each sample If image quality is to be
judged by an analytic measure, B is simply taken as the smallest value that satisfies the minimal acceptable image quality measure For a subjective assessment, B is
lowered until quantization effects become unacceptable The eye is only capable of judging the absolute brightness of about 10 to 15 shades of gray, but it is much more sensitive to the difference in the brightness of adjacent gray shades For a reduced
number of quantization levels, the first noticeable artifact is a gray scale contouring
caused by a jump in the reconstructed image brightness between quantization levels
in a region where the original image is slowly changing in brightness The minimal number of quantization bits required for basic PCM coding to prevent gray scale contouring is dependent on a variety of factors, including the linearity of the image display and noise effects before and after the image digitizer
Assuming that an image sensor produces an output pixel sample proportional to the image intensity, a question of concern then is: Should the image intensity itself, or some function of the image intensity, be quantized? Furthermore, should the quantiza-tion scale be linear or nonlinear? Linearity or nonlinearity of the quantizaquantiza-tion scale can
F j k(, )
1.0 – ≤F j k(, ) 1.0<
L = 2B
Trang 11MONOCHROME AND COLOR IMAGE QUANTIZATION 151
FIGURE 6.3-1 Uniform quantization of the peppers_ramp_luminance monochrome
image
(b) 7 bit, 128 levels (a) 8 bit, 256 levels
(c) 6 bit, 64 levels (d) 5 bit, 32 levels
(e) 4 bit, 16 levels (f ) 3 bit, 8 levels
Trang 12152 IMAGE QUANTIZATION
be viewed as a matter of implementation A given nonlinear quantization scale can
be realized by the companding operation of Figure 6.1-3, in which a nonlinear amplification weighting of the continuous signal to be quantized is performed, followed by linear quantization, followed by an inverse weighting of the quantized amplitude Thus, consideration is limited here to linear quantization of companded pixel samples
There have been many experimental studies to determine the number and place-ment of quantization levels required to minimize the effect of gray scale contouring (5–8) Goodall (5) performed some of the earliest experiments on digital television and concluded that 6 bits of intensity quantization (64 levels) were required for good quality and that 5 bits (32 levels) would suffice for a moderate amount of contour-ing Other investigators have reached similar conclusions In most studies, however, there has been some question as to the linearity and calibration of the imaging sys-tem As noted in Section 3.5.3, most television cameras and monitors exhibit a non-linear response to light intensity Also, the photographic film that is often used to record the experimental results is highly nonlinear Finally, any camera or monitor noise tends to diminish the effects of contouring
Figure 6.3-1 contains photographs of an image linearly quantized with a variable number of quantization levels The source image is a split image in which the left side is a luminance image and the right side is a computer-generated linear ramp In Figure 6.3-1, the luminance signal of the image has been uniformly quantized with from 8 to 256 levels (3 to 8 bits) Gray scale contouring in these pictures is apparent
in the ramp part of the split image for 6 or fewer bits The contouring of the lumi-nance image part of the split image becomes noticeable for 5 bits
As discussed in Section 2-4, it has been postulated that the eye responds logarithmically or to a power law of incident light amplitude There have been several
efforts to quantitatively model this nonlinear response by a lightness function ,
which is related to incident luminance Priest et al (9) have proposed a square-root nonlinearity
(6.3-2)
where and Ladd and Pinney (10) have suggested a cube-root scale
(6.3-3)
A logarithm scale
(6.3-4)
Λ
Λ = (100.0Y)1 2⁄
0.0 Y 1.0≤ ≤ 0.0 Λ 10.0≤ ≤
Λ = 2.468 100.0Y( )1 3⁄ –1.636
Λ = 5.0[log10 100.0Y{ }]