An Algorithm for Grayscale Images Compression based on the forward Adaptive Quantizer Designed for Signals with Discrete Amplitudes

Pateikiamas nespalvotų vaizdų suspaudimo algoritmas, pagrįstas adaptyviu impulsiniu moduliatoriumi, skirtu signalams su diskretinėmis amplitudėmis. Atlikti eksperimentai taikant sį algoritmą nespalvotiems vaizdams. Gauti rezultatai rodo, kad srautą galima gerokai sumažinti (apie 40 %) ir islaikyti labai gerą atkurto vaizdo kokybe. Il. 2, bibl. 6, lent. 2 (anglų kalba; santraukos anglų ir lietuvių k.). DOI: http://dx.doi.org/10.5755/j01.eee.118.2.1166


Intoduction
Image compression refers to a process in which the amount of data used to represent image is reduced to meet a bit rate requirement, while the quality of the reconstructed image satisfies a requirement for a certain application and the complexity of computation involved is affordable for the application.
The required quality of the reconstructed image and video is application dependent.In medical diagnosis and some scientific measurements, we may need the reconstructed image and video to mirror the original image and video.This type of compression is referred to as lossless compression.In application, such as motion picture and television (TV), a certain amount of information loss is allowed.This type of compression is called lossy compression [1].
Very often, an image is divided into blocks of pixels, and each block is processed separately (for example, in transform coding).Due to the high correlation between a pixel and its neighbor pixels, instead coding the original value of a pixel, it is better to code the difference between the pixel and its neighbor, or the difference between the pixel and the mean value of the block where the pixel is included.The selection of the block size is an important issue.If blocks are too large, the dynamic range of the difference between pixel and the mean value of the block will be large, which is not good for compression.For these reason, the block size should not be large [1].
Quantization is a necessary component in lossy coding and has direct impact on the bit rate and the distortion of the reconstructed image and video.Quantization is an irreversible process and there is no way to find the original value from the quantized value.Therefore, quantization is a source of information loss.In fact, quantization is a critical stage in image and video compression.It has significant impact on the distortion of reconstructed image and video as well as the bit rate of encoder.As a measure of the quality of the compressed image, PSQNR (peak signal-to-quantization-noise ratio) is used [2].
Uniform quantization is the simplest, yet very popular quantization technique.The design of a quantizer involves choosing the number of levels N, and selecting the values of decision levels and reconstruction levels (deciding where to locate them).Optimal design of quantizers was analyzed in the paper [3].
Since the signal variance (speech, audio, video) is not stationary (variance varies with time), adaptation should be applied to achieve good signal quality in the wide range of input variances.Adaptation can be forward and backward [4].It is known that the forward adaptation gives for about 1 dB higher SQNR (signal-to-quantization noise ratio), compared to the backward adaptation [5].
Usually, quantization is done in two steps.In the first step, quantization with large number of levels is done, with the aim of the analog-to-digital conversion (for example, quantization with 256 levels is applied for grayscale images).In the second step, quantization with smaller number of levels is done, with the aim of compression.Input signal for quantizers in the first step has continuous amplitude while input signal for quantizers in the second step has discrete amplitude.Because of that, design of quantizers in the first and in the second step is different.Design of adaptive quantizers for input signals with discrete amplitudes (for the second step) was analyzed in the paper [6].
In this paper an algorithm for the compression of grayscale images is presented.According to this algorithm, the image is divided into macroblocks, each macroblock is divided into microblocks and the difference between a pixel and the mean value of the corresponding microblock is quantized using adaptive quantizers described in [6].Using this algorithm, significant decrease of the bit-rate is achieved, preserving very high quality of the reconstructed image (near lossless compression).
Experiment is done, applying this algorithm on three standard grayscale images.Experimental results are presented in the paper and based on them, optimal values of some parameters are determined.Also, it is shown that reconstructed images are almost identical to the original images with bit-rate decrease of about 40%, which proves that our algorithm enables near lossless compression.

Algorithm for forward adaptive uniform quantization
In this part the algorithm is shown, according to which the image compression is done.The algorithm is performed from left to right and from top to bottom.The proposed algorithm has the following steps: 1.The image is divided into a set of non-overlapping MxM blocks (macroblocks).
2. The mean value of pixels in each macroblock ( ) is calculated, quantized ( ) and transmitted to the receiver.
3. The macroblock is divided into a set of nonoverlapping lxl blocks (microblocks).The mean value of pixels in the microblock ( ) is calculated.Then, the difference between the mean value in the microblock and the quantized mean value of the macroblock is calculated After that, this difference is quantized ( ) and transmitted to the receiver.
4. The pixel values in each individual microblock are substituted with , which is the difference between the pixel value and the mean value of the microblock available in the receiver (i.e. in the decoder): ( ) * = + . Therefore, we have that

The standard deviation of such obtained values (
) for the microblock is calculated.After that, this standard deviation is quantized ( ) and transmitted to the receiver.
6. Quantization of is done using the forward adaptive quantizers defined in [6] and quantized values ( ) are transmitted to the receiver.Forward adaptation is done based on the quantized standard deviation ( ) of the microblock.
7. Go to the step 3 until all microblocks are processed.8. Go to the step 2 until all macroblocks are processed.
In the previous algorithm, with ^ are denoted quantized values and with * are denoted values available to decoder.
To summarize: , , and are transmitted to the receiver and these values are available to the decoder.Reconstructed pixel value on the output of the decoder is * = + + .
In (1) in the 3, is used instead of since is available to decoder.In (2) in the step 4, ( ) * is used instead of since ( ) * is available to decoder.Also, in the step 6, is used for adaptation instead of since is available to decoder.
Therefore, in the coding process we use values which will be available to decoder, to minimize the reconstruction error (i.e. the difference between the original and the reconstructed images).
The quality of the reconstructed image is measured with PSQNR (peak signal-to-quantization-noise ratio), which is defined as followed where is the maximal pixel value of the original image (for grayscale images = 255) and = ∑( − * ) is the mean square error between the original and the reconstructed images, where summation is done for all pixels in the image.
in the step 2 and in the step 3 can take values from the set of real numbers, and therefore quantization of these parameters is done using classic quantizers for signals with continual amplitudes whose representation levels are integers.But, in the step 4 can take discrete values (since x can take discrete values and ( ) * has been already quantized).Therefore, for quantization of , with the aim of compression, quantizers designed for signals with discrete amplitudes (from [6]) should be used.Now, we will explain some aspects of implementation of these quantizers.
The maximal amplitude of the adaptive quantizer depends on the quantized standard deviation of the microblock , i.e.
= , where k is a parameter of proportionality.The number of levels of the forward adaptive quantizer is denoted with N. The step size ∆= 2 • / of the quantizer must be an integer (since the input signal has discrete integer values).Therefore, the maximal amplitude = ∆ • /2 must be an integer multiple of /2.But, what if is not equal to an integer multiple of /2, i.e. if • ≤ < ( + 1) , where j is an integer.Then, we introduce the following rule where m can take integer values from 0 to ( − 1) and its optimal value depends on N and also on the type of the image.Therefore, optimal value of m should be experimentally found for desired value of N and for desired ensemble (class) of images.j can take values from 1 to − 1 and minimal value of j that satisfies condition (4) should be used.
We introduced the following parameters: , , and denote the number of bits that is used for transmission of , , and respectively., and denote the total numbers of macroblocks, microblocks and pixels, respectively.The total average bit-rate is defined as where bpp is abbreviation for bits per pixel.

Experimental results
In this section we present experimental results, obtained by applying algorithm from previous section on three grayscale images (Lena, Airplane and Street), shown in Fig. 1.These images are 512x512 of pixel size and each pixel can take integer values from 0 to 255.
According to the previous algorithm, these images are divided into macroblocks of 16x16 pixels (i.e.M =16), which are further divided into microblocks of 4x4 pixels (i.e.l =4).Experimental results for various values of and (which can take values from the set {3, 4, 5} bits) are given in Tables 1 and 2. In Table 1, the adaptive quantizer with 16 levels is used (i.e. = 4 bits) while in Table 2, the adaptive quantizer with 32 levels is used (i.e.= 5 bits).In both tables, = 6 bits.For each combination ( , ) optimization of the parameters k and m is performed.From Table 1 we can see that for = 4 bits, optimal values of parameters ( , ) are = 3 bits and = 5 bits.The average bitrate in this case is = 4.52 bpp (since the bit-rate of the original image is 8 bpp, the reduction of the bit-rate for about 40% is achieved).From Table 2 we can see that for = 5 bits, optimal values of parameters ( , ) are = 4 bits and = 5 bits.The average bit-rate in this case is = 5.58 bpp.For the other combinations ( , ) we get unproportional reduction in the image quality (PSQNR) regarding to the decrease of the total bit rate.It can be concluded from these tables that when increases for about 1 bpp (from 4.52 bpp to 5.58 bpp), PSQNR increases for about 5 dB.
In Fig.

Conclusions
An algorithm for grayscale image compression was presented in this paper.It is based on division of the image into macro and micro blocks and on implementation of the adaptive quantizers designed for signals with discrete amplitudes.Experiments were done, applying this algorithm on three standard grayscale images and it was shown that reconstructed images are almost identical to the original images, but reduction of the bit-rate for about 40% was achieved.Increasing the bit-rate for about 1 bpp, PSQNR increases for about 5 dB.Further research will be dedicated to include some entropy code in this algorithm, with the aim of further decrease of the bit-rate, preserving the high quality of the reconstructed images (high PSQNR).

Fig. 1 .Fig. 2 .
2. three images from Fig 1. after compression with forward adaptive quantizer with 16 levels ( = 4 bits) are shown.We can see that reconstructed images are almost identical to the original images.The grayscale images, size 512x512 pixels: a) Lena, b) airplane, c) The grayscale images from Fig.1 after compression with adaptive quantizer with N =16 levels: a) Lena, b) airplane, c) street

Table 1 .
Experimental results obtained by using the adaptive quantizer with 16 levels ( = 4 bits)

Table 2 .
Experimental results obtained by using the adaptive quantizer with 32 levels ( = 5 bits)