FRIENDz

FAILURE IS THE SIGN OF SUCCESS!!

Uniform Quantizer with Matlab Program

Uniform Quantizer
When the pdf of the analog sample is uniform, the decision intervals and output levels of the Lloyd–Max quantizer can be computed analytically as shown below.In this case, the decision intervals are all equal as well as the intervals between the output levels and the quantizer is called a uniform quantizer.
We will use the Barbara image for this example. Since this image is rather large in size, we will crop it to a smaller size. Figure 1.a is the cropped original 8-bpp image, and Figures 1.b,c correspond to the requantized images at 3 and 5 bpp, respectively. We see that flat areas appear very patchy especially in the 3-bpp imageas compared with the 5-bpp image. Because of the large quantization step size, a large neighborhood of pixels gets quantized to the same level and this makes the image look patchy in the flat areas.

Figure 1An example of a uniform quantizer: (a) cropped original 8-bpp image, (b) image
in (a) requantized to 3 bpp using a uniform quantizer, (c) image in (a) requantized to 5 bpp
using a uniform quantizer, (d) SNR due to quantization versus bpp, (e) histogram of the input
8-bpp image, (f) error due to quantization: the top figure is the pixel error and the bottom figure is the corresponding histogram, and (g) plot of input decision boundaries versus reconstruction levels.
 The SNR in dB due to quantization noise isshown in Figure 1.d for 1–7 bits of quantization. The SNR versus bits is linear over a large range of quantization bits. From the plot we find the slope to be around, 6.3 dB/bit, which is slightly larger than that obtained from analysis. At 6bpp, the SNR is around 35 dB and the distortion is hardly noticeable. It should be pointed outthat the uniform quantizer is optimal only when the pdf of the input image is uniform.However, the histogram of the image in this example is not exactly uniform, as shown in Figure 1.e. The error due to quantization for L = 32 is shown in Figure 1.f (top figure), where we notice that the quantization error ranges between -4 and +4, as
expected. The corresponding error histogram is shown in the bottom figure, where we
find the error distribution to be broad. It is not exactly uniform due to the particular nature of the image we picked and due to the input image already being digitized. Finally, a plot of the input decision intervals versus the reconstruction levels for the uniform quantizer is shown in Figure 1.g, which is of the type staircase, as expected. A listing of the MATLAB codes for this example is shown below. Both assignment rules are included in the following code.


No comments:

Post a Comment