Optimum Uniform Quantizer
Transcription
Optimum Uniform Quantizer
Chapter 2 Quantization 1 How much can we compress this image losslessly? How much can we compress this image with a loss? CS4670/7670 Digital Image Compression 2 Outline Quantization and Source encoder Uniform quantization • Basics • Optimum Uniform quantizer CS4670/7670 Digital Image Compression 3 Quantization and Source Encoder Transmitter Input visual information A/D Source encoder Channel encoder Modulation Channel Received visual information D/A Source decoder Channel decoder Demodulation Receiver Block diagram of a visual communication system4 CS4670/7670 Digital Image Compression Quantization and Source Encoder Storage Input visual information A/D Source encoder D/A Source decoder Retrieved visual information Retrieval Block diagram of a visual storage system CS4670/7670 Digital Image Compression 5 Quantization and Source Encoder Input information Transformation Codeword assignment Quantization Codeword string (a) source encoder Codeword string Codeword decoder Inverse transformation Reconstructed information (b) source decoder Block diagram of a source encoder and decoder CS4670/7670 Digital Image Compression 6 Quantization and Source Encoder Quantization: • An irreversible process • A source of information loss • A critical stage in image and video compression It has significant impact on • The distortion of reconstructed image and video • The bit rate of the compressed bitstream CS4670/7670 Digital Image Compression 7 Uniform Quantizer Simplest Most popular Conceptually of great importance CS4670/7670 Digital Image Compression 8 Uniform Quantizer -- Basics Definitions • The input-output characteristic of the quantizer Stair-case like Non-linear y i = Q ( x) if x ∈ (d i , d i +1 ), Where yi and Q(x) is the output of the quantizer with respect to the input x CS4670/7670 Digital Image Compression 9 Uniform Quantizer – Basics (midtread quantizer) y Reconstructed levels include 0 For odd # of reconstruction y9 4 y8 3 y7 levels 2 1 y6 y5 -3.5 d2 d1=-∞ -2.5 d3 -1.5 d4 y3 y4 -0.5 d5 x 0 0.5 d6 -1 1.5 d7 2.5 d8 3.5 d9 d10=∞ -2 y2 -3 y1 CS4670/7670 Digital Image Compression -4 10 Uniform Quantizer -- Basics Decision levels • The end points of the intervals, denoted by di where i : index of intervals Reconstruction level • The output of the quantization, denoted by yi Step size of the quantizer • The length of the interval, denoted by ∆ CS4670/7670 Digital Image Compression 11 Uniform Quantizer -- Basics Two features of a uniform quantizer • Except possibly the right-most and left-most intervals, all intervals along the x-axis are uniformly spaced • Except possibly the outer intervals, the reconstruction levels of the quantizer are also uniformly spaced Furthermore, each inner reconstruction level is the arithmetic average of the two decision levels of the corresponding interval CS4670/7670 Digital Image Compression 12 Uniform Quantizer – Basics (midrise quantizer) Reconstructed levels do not include 0 For even # of reconstruction y y8 3.5 y7 levels 2.5 y6 1.5 y5 x 0.5 -4.0 d1=-∞ -3.0 d2 -2.0 d3 -1.0 y 4 d4 0 d5 -0.5 1.0 d6 2.0 d7 3.0 d8 4.0 d9 =∞ y3 -1.5 y2 -2.5 y1 CS4670/7670 Digital Image Compression -3.5 13 Uniform Quantizer -- Basics WLOG, assume both input-output characteristics of the midtread and midrise uniform quantizers are odd symmetric with respect to the vertical axis x=0 • Subtraction of statistical mean of input x • Addition of statistical mean back after quantization • N: the total number of reconstruction levels of a quantizer CS4670/7670 Digital Image Compression 14 Quantization Distortion In terms of objective evaluation, we define quantization error eq eq = x − Q(x), Quantization error is often referred to as quantization noise Mean square quantization error MSEq d N i+1 MSEq = ∑ ∫ ( x − Q( x))2 f ( x)dx X i=1 d i CS4670/7670 Digital Image Compression 15 Quantization Distortion fx(x): probability density function (pdf) • The outer decision levels may be -∞ or ∞ • When the pdf fx(x) remains unchanged, fewer reconstruction levels (smaller N, coarser quantization) result in more distortion. • In general, the mean of eq is not zero. It is zero when the input x has a uniform distribution. In this case, MSEq is the variance of the quantization noise eq. CS4670/7670 Digital Image Compression 16 Quantization Distortion y granular quantization noise overload quantization noise 0.5 x -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0 0.5 1 1.5 2.0 2.5 3.0 3.5 4.0 4.5 -0.5 overload quantization noise CS4670/7670 Digital Image Compression 17 Quantizer Design The design of a quantizer (uniform/nonuniform) • Choosing the # of reconstruction levels, N • Selecting the values of decision levels and reconstruction levels The design of a quantizer is equivalent to specifying its input-output characteristic Optimum quantizer design • For a given probability density function of the input random variable, fX(x), design a quantizer such that the mean square quantization error, MSEq, is minimized. CS4670/7670 Digital Image Compression 18 Quantizer Design For uniform quantizer design • N is usually given. • According to the two features of uniform quantizers Only one parameter that needs to be decided: the step size ∆ As to the optimum uniform quantizer design, a different pdf leads to a different step size CS4670/7670 Digital Image Compression 19 Optimum Uniform Quantizer y y9 4 y8 3 y7 2 1 y6 y5 -4.5 d1 -3.5 d2 -2.5 d3 -1.5 d4 y 4 y3 -0.5 d5 x 0 0.5 d6 -1 1.5 d7 2.5 d8 3.5 d9 4.5 d10 -2 y2 -3 y1 -4 Uniform quantizer with uniformly distributed input CS4670/7670 Digital Image Compression 20 Optimum Uniform Quantizer y Zero overload quantization noise Granular quantization noise 0.5 x -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0 0.5 1 1.5 2.0 2.5 3.0 3.5 4.0 4.5 -0.5 Zero overload quantization noise Quantization distortion CS4670/7670 Digital Image Compression 21 Optimum Uniform Quantizer The mean square quantization error d 2 MSE q = N ∫ ( x − Q ( x)) 2 1 dx N∆ d 1 2 ∆ MSE q = . 12 σ x2 SNRms = 10 log = 10 log N 2 . 10 10 σ 2 q If we assume N = 2n, we then have SNRms = 20 log10 2n = 6.02n CS4670/7670 Digital Image Compression dB. 22 Optimum Uniform Quantizer The interpretation of the above result • If use natural binary code to code the reconstruction levels of a uniform quantizer with a uniformly distributed input source, then every increased bit in the coding brings out a 6.02 dB increase in the SNRms • Whenever the step size of the uniform quantizer decreases by a half, the MSEq decreases four times CS4670/7670 Digital Image Compression 23 Quantization Effects 1 bit quantizer 2 bit quantizer 3 bit quantizer 4 bit quantizer CS4670/7670 Digital Image Compression 24 Optimum Uniform Quantizer Conditions of optimum quantization • Derived by [Lloyd’57, 82; Max’60] • Necessary conditions, for a given pdf fX(x) x = −∞ 1 xN +1 = +∞ d i+1 ∫ ( x − yi ) f X ( x)dx = 0 i = 1,2,L, N d i d = 1(y + y ) i = 2,L, N i 2 i −1 i CS4670/7670 Digital Image Compression Centroid condition Nearest neighbor condition 25 Optimum Uniform Quantizer • • • First condition: for an input x whose range is -∞ <x< ∞ Second: each reconstruction level is the centroid of the area under the pdf and between the two adjacent decision levels Third: each decision level (except for the outer intervals) is the arithmetic average of the two neighboring reconstruction levels These conditions are general in the sense that there is no restriction imposed on the pdf. CS4670/7670 Digital Image Compression 26 Optimum Uniform Quantizer Optimum uniform quantizer with different input distributions • A uniform quantizer is optimum when the input has uniform distribution • Normally, if the pdf is not uniform, the optimum quantizer is not a uniform quantizer • Due to the simplicity of uniform quantization, however, it may sometimes be desirable to design an optimum uniform quantizer for an input with a nonuniform distribution. CS4670/7670 Digital Image Compression 27 Some Typical Distributions Laplacian Gamma CS4670/7670 Digital Image Compression 28 Optimum Uniform Quantizer Optimal symmetric uniform quantizer for Gaussian, Laplacian and Gamma distribution (with zero mean and unit variance). [Max’60][Paez’72]. The numbers enclosed in rectangular are the step sizes. CS4670/7670 Digital Image Compression 29 Optimum Uniform Quantizer Under these circumstances, however, three equations are not a set of simultaneous equations one can hope to solve with any ease Numerical procedures were suggested for design of optimum uniform quantizers • E.g., Newton method Max derived uniform quantization step size for an input with a Gaussian distribution [Max ’60] CS4670/7670 Digital Image Compression 30 Optimum Uniform Quantizer Paez and Glisson found step size for Laplacian and Gamma distributed input signals [Paez’ 72] Zero mean: if the mean is not zero, only a shift in input is needed when applying these results Unit variance: if the standard deviation is not unit, the tabulated step size needs to be multiplied by the standard deviation. CS4670/7670 Digital Image Compression 31 Nonuniform Quantizer In general, an optimal quantizer is a nonuniform quantizer. • Depends on statistic (pdf) of input source Companding quantization • Using uniform quantizer to realize non-uniform quantization • Reading: Section 2.3.2 Adaptive quantization • Adapt to changing statistic of input source • Reading: Section 2.4 HW #1: Ex. 2-2 CS4670/7670 Digital Image Compression 32