Colored Image Compression Using Gradient Adjustment Prediction Based Wavelet

: Problem statement: Uncompressed graphics, audio and video data require considerable storage capacity and transmission bandwidth. Despite rapid progress in mass-storage density, processor speeds and digital communication system performance, demand for data storage capacity and data transmission bandwidth continues to outstrip the capabilities of available technologies. The recent growth of data intensive digital audio, image and video (multimedia) based web applications, have not only sustained the need for more efficient ways to encode signals and images but have made compression of such signals central to signal-storage and digital communication technology. Approach: The objective includes developing and applying an efficient Space-Frequency Segmentation (SFS) as an image partitioning scheme, then using an appropriate entropy-coding algorithm that can be used with the developed segmentation to improve compression performance, particularly in the case of still image compression. The proposed compression system focuses on an innovative scheme for adaptive wavelet coding technique combined with spatial encoding. Result: Experiments conducted using the proposed system produced encouraging results. The entropy-spatial coders used in the proposed system produced better results than those obtained by using the basic arithmetic coder. It provides more appropriate rate-distortion optimization for the space-frequency segmentation than the basic arithmetic coder does. The proposed compression system implies some control coding parameters; the effects of these parameters were investigated to determine the suitable range for each one of them. Conclusion: We conclude that a comparison between the energy of two partitioning types (space and frequency) shows that the energy of frequency partitioning is greater than the space partitioning from the point of view of quality of compressed image. And also the selection of parameter value used in SFS part (Ratio and Threshold) should be chosen correctly, because its value has a great effect on the compressed image quality. And the selection of the quantization step size and the quantization factor (weight) should be done carefully, because experimental results show that these two factors have a great effect on the compression ratio and PSNR factor. Finally experimental results indicate that the use of GAP predictor produces better PSNR than other predictors.


INTRODUCTION
Image compression has become increasingly important with the continuous development of the internet, remote sensing, medical imaging, forensic analysis, digital libraries, police department and satellite communication techniques. Most of these applications used compression in order to reduce the size of the image file by removing the redundant data, which implies the reduction of bandwidth. Wavelets are a mathematical tool for hierarchically decomposing functions. Image compression using wavelet transforms is a powerful method that is preferred by scientist to get the compressed images at higher compression ratios with higher PSNR value (Nadenau et al., 2003).
The aim of this study includes developing and applying an efficient SFS algorithm for image partition. Then using an appropriate entropy-coding algorithm that can be used with the developed segmentation to improve compression performance, particularly in the case of still image compression (Ji, 2001;Tham et al., 2000;Charrier et al., 1999;Wu and Coll, 1993;Xiong and Wu, 1999;Al-Saidi and Said, 2009). Experiments conducted using the proposed approach produced encouraging results. The entropyspatial coders used in the proposed system produced better results than those obtained by using the basic arithmetic coder. It provides more appropriate ratedistortion optimization for the SFS than the other coder does. This algorithm reduces the loading of telecommunication works and is quite suitable for low bit-rate telecommunication applications. Here a signal is passed through a lowpass and highpass filter, h and g, respectively, then down sampled by a factor of two, constituting one level of transform. Multiple levels or "scales" of the wavelet transform are made by repeating the filtering and decimation process on the lowpass branch outputs only. The process is typically carried out for a finite number of levels K and the resulting coefficients, d i1 (n), i ∈ {1,….,K} and d K0 (n), are called wavelet coefficients. Referring to Fig. 1, half of the output is obtained by filtering the input with filter H(z) and downsampling by a factor of two, while the other half of the output is obtained by filtering the input with filter G(z) and down-sampling by a factor of two again. H(z) is a low pass filter, while filter G(z) is a high pass filter.
The 1-D wavelet transform can be extended to a two-dimensional (2-D) wavelet transform using separable wavelet filters. With separable filters the 2-D transform can be computed by applying a 1-D transform to all the rows of the input and then repeating on all of the columns. Using the Lena image in Fig. 2a shows an example of a one-level (K = 1), 2-D wavelet transform. The example is repeated for a two-level (K = 2) wavelet expansion in Fig. 2b.
From Fig. 2a subband LL is more important than the other 3 subbands, as it represents a coarse version of the original image. The multiresolutional features of the wavelet transform have contributed to its popularity.
Image compression: Image compression research aims to reduce the number of bits needed to represent an image by "removing the spatial and spectral redundancies as much as possible" (Salomon, 2006;Xiong and Ramchandran, 1997). In general, there are two basic categories for image compression that is based on the information content of the reconstructed image. They are: Lossless and Lossy (Salomon, 2006). Compression is accomplished by applying a linear transform to decorrelate the image data, quantizing the resulting transform coefficients, and entropy coding the quantized values. Currently, many linear transforms have been developed for this purpose. These transformations include Discrete Fourier Transform (DFT), Discrete Cosine Transform (DCT), Discrete Wavelet Transform (DWT) and many more (Salomon, 2006). Forward transform coding of Fig. 3a, is a coding scheme based on the utilization of interpixel correlation's (concerned with the correlation between pixels). In transform coding, the main idea is that if the transformed version of a signal is less correlated compared with the original signal, then quantizing and encoding the transformed signal may lead to data compression. The quantizer role in Fig. 3a, is to reduce the number of bits needed to store the transformed coefficients. The entropy encoder of Fig. 3 a, further compresses the An image can be compressed by transforming its pixels (which are correlated) to a representation where they are de-correlated. Compression is achieved if the new values are smaller, on average, than the original ones. The decoder inputs the transformed values from the compressed stream and reconstructs the original data by applying the opposite transform. We used JPEG2000 image compression standard that which supports the DCT-based coding mode and wavelet-based coding mode.

GAP (Context_based entropy coding):
The previous two fixed linear predictors have some disadvantages because their predictors are fixed for all symbols. The quality of the prediction can be improved by considering image gradients in the neighborhood of the pixel being predicted. The GAP is a simple, adaptive, nonlinear predictor that can adapt itself to the intensity gradients near the predicted pixel.
For each pixel x[i,j], it uses n, w, ne, nw, nn, ww, nne to denote north, west, northeast, northwest, northnorth, west-west and north-northeast pixels respectively that form a context model as shown in Fig. 4.
In the prediction algorithm, the predictor becomes either pixel n or w when there is a reasonable likelihood that a vertical or horizontal edge exists; otherwise, it is selected from several choices according to the local smoothness, which needs to be estimated. When the samples of n, w, ne, nw, nn, ww and nne are known to both the encoder and decoder, the parameters d h and d v can be estimated by using the following equations.
In the algorithm, d h and d v are introduced to represent the horizontal and vertical gradients for each image sample during the encoding.

Proposed compression method:
The main processes for the designed compression algorithm are shown in Fig. 5, which consists of 8 stages. The input to this figure is the source image which will do compression for it, and the output is the compressed image. Following is a description of each stage.

Stage 1 (image decomposition into 3 components):
The proposed scheme supports multiple component images. The image components can be divided into tiles using SFS. These tiles are square arrays that include the same relative portion of all the components that make up the image. Thus, image tiling actually creates tile-components that can be decoded independently of each other. These tile-components can also be extracted and reconstructed independently. Different components need not have the same bit depths nor need all be signed or unsigned. For reversible (i.e., lossless) systems, the only requirement is that the bit depth of each output image component must be identical to the bit depth of the corresponding input image component. In the proposed scheme, the colored image is decomposed into three color components (i.e., Red, Green and Blue), and all steps of encoding and decoding are performed on each component. On the other hand, these three components are merged in the decoding stage to reconstruct the image. Stage 2 (forward discrete cosine level shift): Discrete cosine (DC) level shifting is performed on samples of components that are unsigned only. It is performed prior to the computation of the forward Component Transform ( CT). All samples of the image tile component are DC level shifted by subtracting the same quantity (i.e., 2 P-1 ) from the component samples, where P is the pixel depth. The inverse of this operation, when it is performed during the uncompression, is the inverse DC Level Shifting, which is executed on the reconstructed samples of components.

Stage 3 (forwarded component transformation):
The component transformation can be achieved by one of two methods. They are the Reversible Component Transformation (RCT) and the Irreversible Component Transformation (ICT). The RCT is a decorrelating transformation that is applied to the three color components of an image. The forward RCT is applied to all image color samples I 0 (x,y), I 1 (x,y), I 2 (x,y), corresponding to the Red, Green and Blue components, and produces the corresponding transformation. The second method of forwarded component transformation is the ICT. The Forward ICT is applied to all image component samples I 0 (x,y), I 1 (x,y), I 2 (x,y), corresponding to the Red, Green and Blue components, and produces the corresponding transformations (Salomon, 2006;Skodras et al., 2001).

Stage 4 (data ordering-SFS):
The SFS method comes from the single-tree and double-tree wavelet pack et al gorithms. The double-tree library allows different wavelet packet single-trees over all quadtree segmentations of the image. SFS extends the doubletree segmentation scheme where the binary partition of two one-dimensional segments is replaced by the partition of four two-dimensional structures. Each space partition divides an image into four quadrants. General SFS applies the general timefrequency-pruning algorithm to choose between the four-way splits in space or frequency in a spacefrequency tree. The SFS algorithm should generate a better optimal basis than both the single-tree and the double-tree. Its basis must be at least as good as the best double-tree/single-tree basis, because the set of possible double-tree/single-tree bases is a subset of the possible SFS bases. Figure 6 presents the three possible tree structures when the decomposition depth is set to two, where F indicates frequency partition and S means time partition in one-dimensional signals.
In addition to the implementation of SFS algorithm, the Delta Modulation Coder was applied to encode the low level (LL) subband. Arithmetic coders were used to encode the contents of the high pass subbands, while a vector quantizer with fixed codebook was applied to encode the space-segments. An example for SFS partition is shown in Fig. 7. It has maximum decomposition depth of five. The white lines indicate that the sub-image is space split, while the black lines indicate that frequency segmentation is applied. The disappearance of lines inside a subimage indicates that there is no splitting performed on the sub-image.
In the current research study, the operation of partitioning the image components (into tiles and performing the Discrete Wavelet Transform on some partitions) was performed by using adaptive SFS. This means, that the two sub-steps (tiling and DWT operations) are mixed in one combined step. The adaptive SFS work as follows: Also the minimum allowable size of the partitioning must be determined (MinSiz), where the MinSiz depends on the numbers of partitioning levels • If the size of the considered subblock is greater than MinSiz then this subblock must be tested to determine whether it requires further partitioning or not • Initial subblocks will be partitioned, by using SFS, either as spatial (space) partitioning or as frequency (DWT) • The Gradient Adjustment Predicator (GAD) is utilized to evaluate whether the partitioning is performed in space or frequency. The GAD is selected because it is the best appropriate causal context model • The algorithm can decide, which type of partitioning will be performed (space or frequency). There are two parameters have a great effects on selecting an appropriate partitioning types (the ratio and threshold). This operation is performed after doing the space and frequency partitioning on the same block, and then selecting partitioning type whose error is less than other and it is higher than a selected threshold • According to these conditions, the partitioning operation is done on the entire image block. These operations continue until the block size reaches the MinSiz or they are uniform and the error of GAD predictor doesn't exceed the threshold value. The formal description of SFS operation is given in Fig. 8 To reconstruct the image partitioning in the decoder, the inverse of each step must be performed directly. Only the types of all partitions need to be registered from the encoder and from it and the maximum size, the decoder can build all the partitions starting from the smallest blocks (calculated from the maximum size and number of levels) to build the largest ones (parents) and this will continue until reaching the reconstruction of the whole image partitions.

Stage 5 (wavelet transform):
Wavelet transform is used for the analysis of the frequency-segmentation components into different decomposition levels. These decomposition levels contain a number of subbands, which consist of coefficients that describe the horizontal and vertical spatial frequency characteristics of the original tile component. To perform the forward DWT we have used a one-dimensional (1-D) subband decomposition of a 1-D set of samples into low-pass

Stage 6 (adaptive quantization and classification):
After that each of the transform coefficients a b (u,v) is quantized to the value q b (u,v) according to the following equation: The quantization step-size ∆ b depends on the subbands number, its dynamic range, and the required number of compression. In other words, the proposed scheme supports separate quantization step-sizes for each subband. The dynamic range depends on the number of bits used to represent the maximum coefficients in the specific subbands and on the choice of the frequency or space partitioning. All quantized transform coefficients are signed values even when the original components are unsigned. For reversible compression, the quantization step-size is required to be known.
In proposed algorithm, the step size for the LLsubband was taken equal 1 because of their importance which means that their coefficients are distorted significantly. Also, the proposed system combines the partition classification and adaptive quantization together in a uniform coding scheme. For each subband, types of partitioning are made on the initial partition of MaxSiz until reaching MinSiz. These sequences must be recorded and according to them, a quantization step size is computed. This quantization model tries to give a more precise step size for the subband coefficient.
Also the proposed algorithm gives a different consideration for the quantizer sets. First, they separate the subbands into different classes; then they apply different quantization to each class using a bit allocation strategy. In adaptive scheme, the operations of calculation quantization step-size depend relatively on the subband size and types of partitioning occurred on the initial partition until reaching current size. The magnitudes of these stepsize also help us to determine the value of LowBit which is needed in the entropy coder step.

Stage 7 (Coefficient Bit Modeling):
The next stage was to do coefficient bit modeling (Bit Slicing). In this stage, the wavelet coefficients are arithmetically coded by bit-plane. The coding is done from most significant bit-plane to least significant bit-plane. The basic idea behind using this method is based on decomposing the quantized transform coefficients into binary component (i.e., bitmap layers), such that the ith layer represents a (0-1) bitmap, each point represents the ith bit value of the corresponding transform coefficient. The resulting layers may imply different spatial and statistical characteristics. If these characteristics are considered to choose the suitable coding method and to encode each layer separately, then the resulting code size may, probably, be compact in a smaller size than that of the original image, consequently the image compression task will be achieved. In our case, the bitmap slicing is performed upon the quantized coefficients. These coefficients first are expressed in a sign magnitude representation by splitting the sign of each coefficient repairing it to another state. The sign bit is taken (1) for the positive or a zero coefficient and (0) for the negative coefficients. The proposed scheme suggests the following equation.
Plan(I,X,Y)=(q(X,Y) shr I) and 1; Where: q(x,y) = The quantized transform coefficient I = The bit-plane index, whose value laies between (LowBit-HiBit) HiBit = Maximum number of bits needed to represent each subband LowBit = The lower bound of the bit-planes will be considered throughout the codingstage of each plane. In the proposed scheme the value of LowBit is considered variable and, mainly, depends on the partitioning information Stage 8 (adaptive spatial encoders): The mapping operations are those process which tend to map the original image data from the pixel domain to another domain, such that the output data will show suitable characteristics (e.g., energy compactness, highly peaked bandwidth, small variance or entropy). The adapted mapping methods in the proposed coding scheme are divided into four principal categories, they could be merged through different steps and produce hybrid methods which show a progressive compression performance. A brief description will be devoted for presenting the major concepts accompanied with the principal mapping methods. In this study three different coding schemes for compression of images have been constructed and evaluated. The first scheme is based on applying vector quantization with fixed codebook on the spacesegments. The second one is based on applying Differential Pulse Code Modulation ( DPCM) on the  low subbands of frequency-segments, and the third is based on applying the bitmap slicing followed either by Run-length Coder , Chaining Coder or Arithmetic Coder on high subbands of frequencysegmentations. An important considerations which must be taken when choosing mapping process, is the history of each partition, since the history of subbands is used to calculate the step-sizes of quantizer and to choose the appropriate coder. Before applying any of the coders for any subband yielded from a frequencysegmentation, a bit-plane is generated by finding the maximum number of bits for each subband. The decision of choosing an appropriate coder depends at first on the types of partitioning used to construct the considered lock (partition), on the size of subband and finally on the nature of the contents of bit-planes. The last two factors are important to determine the type of spatial encoders used to represent the content of the bit-planes. Table 1 presents the relationship between the block size and the maximum allowed number of runs and chains, which might exist in the bit-plane.
To calculate the total number of bits needed by the Run-Length decoder, the following equation will determine the required bits: Total-Bits = Bits * No. of Ones + (Bits-1) Where: Bits = Number of bits need to represent a specific subband No. of Ones = Number of bits in bit-plane whose value equals (1) To calculate the total number of bits needed by the chaining encoder, we suggest the following equation to determine the required number of bits: Total-Bits = No. of Chains * Bits + (No. of Ones -No. of Chains) * 3 where No. of Chains is the number of sequence of ones in the bit-plane.

RESULTS AND DISCUSSION
The experimental results for adaptive SFS scheme as a partition utility are illustrated here. That was • Input the source image to the encoder • Partition the image into initial blocks of maximum size and call this variable "MaxSize" • erform partition using SFS method Results showed that "MaxSize" has a considerable effect on the mean square error (MSE) and peak signal to noise PSNR measurements of the constructed image. In addition, it has an effect on the compression ratio. The larger the maximum size value generates higher compression ratio and less distortion for MSE and PSNR. As mentioned in previous, the proposed scheme used SFS (Space-Frequency Segmentation) in partitioning an image. It partitions an image either in spatial domain or frequency domain depending on some control factors whose values are given by the user for the encoder. After calculating a MSE of two partitioning, the adaptive algorithm first check if the two errors greater than this threshold value, if it is greater than this threshold, then check if the result of multiplying one of error by a ratio  greater than other. Depending on this checking, the coder chooses an appropriate partitioning. The ratio factor is considered an important factor in the proposed algorithm of partitioning, because its value will have effect directly on the compression ratio, quality of output images (degradation) and PSNR. Table 2 shows the objective measures of applying the proposed scheme to a random image with a different ratios and the corresponding figure for the constructed image. The previous experiment and other experiments showed that a ratio (0.5) is a good ratio to get a relatively good compression ratio, image quality and quality measurement (MSE and PSNR). Another factor which was investigated is the threshold factor. Results shoed that the threshold factor has a small effect on the subjective quality of the reconstructed image on a noticeable effect on the compression ratio and PSNR. Table 3 shows an example of the effect of change in the threshold factor on the compression results of a random image.
The third parameter which was investigated is the quantization step-size. Test results showed that quantization step-size has a major influence on the compression performance and, consequently, on the reconstructed image. The increase of quantization step-size will lead to a decreasing in the constructed image but will cause an increase in the compression ratio. In the proposed coding scheme, different quantization steps values are used for each partition (sub-block), its value depends on the initial quantizer value allocated by the user at the initial step. The values change of the quantizer depend on the history of partitioning applied to produce the consider sub-block. The following Table 4 presents the effect of the initial quantization step-size on the quality of the constructed random image and on the compression ratio.
The result showed that the quantizatition step-size has a great effect on the compression ratios and it causes a monotonic increase in compression ratio as the magnitude of the initial quanitization step-size is increased.
The fourth parameter which was investigated is the number of partitioning levels. The levels of decomposition of an image (starting with tiles that have certain maximum size) have a great effect on the reconstructed image quality and also on the compression ratio. The previous experiments use the same number of decomposition levels (i.e. 4), but in the following experiment we use the number of levels to be 5. The reason for this is to see the effect of this on the compression performance. Table 5 gives the effect of this for a certain image entitled "Ski".
Note that all the previous experiments depend on changes one of the parameters, whose values have a significant effect on the quality compression measurements of the compressed image. The results of this experiment are listed in Fig. 10. The MaxSize and Levels of wavelet partitioning are fixed (128 and 5 respectively).
From this figure, once can notice the following: • The best magnitude of ratio has the range of 0.5-0.6 • The magnitude of the quantization step size must be greater than or equal to 2. • When the value of the threshold becomes greater than 3, the MSE increases and PSNR decreases although the compression ratio is increased   Fig. 10: Output of performing the suggested compression system

CONCLUSION
We proposed an adaptive image compression scheme that is based on wavelet using space-frequency segmentation. The suggested approach is a flexible scheme. In addition, the suggested approach has higher energy of frequency partitioning than the space partitioning from the point of view of quality of compressed image. Experimental results showed that ratio, threshold, the quantization step size and the quantization factor(weight) should be selected very carefully. The experiential results showed that the use of GAP predictor produces better PSNR than other predictors from simplest model (Sp1) and Sp2. In addition, the spatial encoders used in the proposed algorithm (Run-Length encoder and Chain Encoder) have a positive effect on the proposed scheme by reducing its complexity and speeding up the compression time, while the use of vector quantization and DPCM have the effect of increasing the compressed image quality (increasing PSNR). The above adaptive encoding mechanism has made the proposed system more effective than other popular entropy coders discussed in this thesis.