Gradient-based Space Filling Curves: Application to lossless image compression

Most conventional lossless image compression schemes such as GIF and PNG use entropic coding to reduce redundancies that results in adjacent pixels correlation. In such schemes, images are scanned line by line, and so, only horizontal patterns are effectively compressed. The proposed approach attempts to more explore image correlation in different direction by adopting a context based scanning process. An image is scanned along a space filling curve (SFC) so as to exploit inherent coherence in the image. The used SFC is determined by a gradient based method allowing the detection pixel's change direction. The resulting one-dimensional representation of the image should have improved auto-correlation compared with universal scans. Combined with conventional lossless image compression techniques such as GIF and PNG, the proposed scan shows significant compression efficiency improvement. The new algorithm used for SFC determination is presented and it is used as an input to conventional coding scheme.


INTRODUCTION
Many image processing methods provide image transformation from the 2-dimenstional representation into the 1-dimenstional by exploiting different image characteristics. The scanning process transforms the 2dimensional image into 1-dimensional representation. Various image scanning algorithms focus on the nearby pixel similarity in the image. They are designed to exploit this characteristic to improve the autocorrelation in the resulting 1-dimensional image representation. Image scanning using SFCs is a typical example of such an algorithm. They define a continuous scan that traverses through every image pixel exactly once. The resulting sequence of pixels is processed as required by the particular application. For instance, the sequence may be compressed using lossless or lossy compression, it may be processed for halftoning, analysis, pattern recognition or texture analysis etc [2] [6]. The scan-line is a standard scanning method, which traverses a frame line by line. However, it is well known that SFC's, which are defined recursively, end up with more favorable properties than the scan-line. Intuitively, the recursive nature of the SFC requires it to traverse neighboring pixels before moving to more distant ones, resulting in better exploitation of the two-dimensional locality.
The most popular SFC is the Peano-Hilbert curve, which has been considered, for its strong locality property, for numerous applications [1] [3][4][5][6]. Lempel and Ziv [9] [15] showed that, for images generated by suitably random sources, the entropy of the pixel-sequence obtained using the Peano-Hilbert curves converges asymptotically to the two-dimensional entropy of the image. Hence, compressing the sequence using the Lempel-Ziv encoder [8] results in an image compression scheme that is optimal in the information theoretic sense. Matias and Shamir considered [7] the relationship between the two-dimensional autocorrelation of an image and the one-dimensional autocorrelation of the pixelsequence. They showed that, for first-order Markov isotropic images, the autocorrelation of the pixelsequence is a function of the fractal-dimension n of the SFC. These studies support the approach that recursive SFCs, such as the Peano-Hilbert curve would be a good choice as a universal SFC that would work well (statistically) for large families of images [10].
Recently, research in SFC exploitation in image processing turned towards a new dynamic strategy of SFC application that depends on image semantic content. In contrast to the well known universal SFCs, these approaches treat each image separately, ie SFCs computation is performed for each individual image separately based on its own characteristics.
In [12] authors propose the use of context-based space filling curves that are to be computed so as to exploit inherent coherence in the image. That is, rather than relying on a universal SFC that works statistically well, this approach consists in selecting a SFC that would work well for the particular image or group of images. A favorable SFC would traverse the pixels within the principal shapes in the considered image for as long as possible before moving across the border edges to traverse the pixels outside the shapes. Thus the contextbased SFC is tailored to avoid edge crossings to a considerable extent, resulting in a smoother pixelsequence. However, the problem of finding such a SFC is NP-hard, especially in image with complex texture.
Another consideration is that, unlike with universal SFCs, the selected context-based SFC needs to be encoded along with the pixel sequence, to enable retrieval at a later stage which demands costly additional information to be transmitted. The same inconvenient persists in [14], where authors utilize a new algorithm based on correlation optimization used for Space Filling Curve (SFC) determination in image compression. Improving the image autocorrelation function can be also achieved by another approach. In [17], authors propose a new SFC-based approach using image segmentation. The outcome of the segmentation process is a set of image segments, each covering a continuous area of similar pixels from the original image. The segments are then treated and processed as individual units. Since the segments are irregular areas, the scanning is performed using standard raster algorithm. In [13], authors have proposed a bit-plane processing system which utilizes an image scanning language called SCAN. If an 8-bit gray scale image matrix is separated into its eight binary components or bit planes, and each of these 2D arrays is scanned with the appropriate SCAN language algorithm, then pixels with the same binary value can be grouped together and run-length encoding would yield very good compression. This methodology works very well for the more significant bit planes, but compression becomes impossible for the less significant bit planes due to the random nature of these image patterns.
In this context, we studied a new SFC based lossless image compression approach that starts by image features analysis step in order to find specific SFC that will be adapted for the image semantic content. Our approach starts by analyzing the image local pixels activity. The gradient concept is used in order to find the direction in where minimal pixels change is estimated. According to this direction, a decisional algorithm assigns, for each pixels block, the suitable SFC (the one which advantages the selected direction). The main contribution of this work consists in finding an efficient decisional algorithm able to select-in the most of cases-the best or the suitable SFC.
This preprocessing step aims to transforms the image source into some strongly correlated representation before applying coding algorithms.
In this paper, we study the compression performances of a new gradient based image scan approach further called G-SFC approach. A new decisional algorithm based on the principle of the vote is proposed. Conducted experiments show the new algorithm improvement compared to both conventional coders and our previous works.
In Section 2 we describe the proposed approach. In Section 3 we discuss the autocorrelation improvement in the proposed scan method. In Section 4, we discuss compression efficiency improvement of the proposed approach. Final concluding remarks are in Section 5.

II. PROPOSED APPROACHAPPROACH DESCRIPTION
The basic idea is to develop a coding scheme which depends on the processed image features. Thus the coder starts by the analysis of image pixels activity in order to select a suitable scan providing a highly correlated pixels sequence. One efficient alternative consists in scanning the image according to the direction where minimal pixel's change is recorded. To overcome this objective, a gradient based algorithm is proposed; First, the proposed algorithm, further called G-SFC algorithm, splits the original image into isometric squared blocks. A context based SFC is computed, for each block individually because each one has its own local autocorrelation characteristic and nearby pixel similarity.
Subsequently, a decisional algorithm would find the best SFC (Space Filling Curve) that scans the image by promoting the direction in which the block's pixel values change is minimal. In order to find this direction, we try to estimate the pixels variations direction by a gradient based approach.
The signal generated after the proposed scan process that should have a strong correlation and minimal fluctuation will be GIF or PNG coded.

Gradient concept
A gradient is used to display variations of a phenomenon.
In vector calculus, the gradient of a scalar field is a vector field that points in the direction of the greatest rate of increase of the scalar field, and whose magnitude is the greatest rate of change.
An image gradient is a directional change in the intensity in an image. Image gradients may be used to extract information from images. Mathematically, the gradient of a two-variable function (here the image intensity function) is at each image point a 2D vector with the components given by the derivatives in the horizontal and vertical directions.
The gradient of the image is one of the fundamental building blocks in image processing such as image filtering, edge and contour detection, texture matching and human feature extraction etc. In our context, gradient is used to detect pixels variation for compression purpose.

Detection of Minimal pixels change direction
The source image is divided into blocks.
The gradient of one two-dimensional bloc F is defined by: [Gx,Gy] = gradient(F) Where Gx (resp. Gy) corresponds to F (resp. F ), the differences in (resp. y) direction. The spacing between two adjacent points in each direction is assumed to be one.
Each point (i,j) in the block matrix F is presented by a local gradient (cf. figure 1): g ı, j gx i, j ı gy i, j j The scan selection depends on these elements.

Scan selection
Two approaches were tested: the first works on the overall direction of the sum of different local gradients [16].
The second is based on the principle of voting.

A. Global gradient based appraoch
The global gradient is: Where H and L are respectively the block height and the width.

Let:
Gx ∑ ∑ gx i, j ı and Gy ∑ ∑ gx i, j j Then, each image block is represented by its own gradient components Gx and Gy . Therefore, the direction of the block pixel's change will be approximated by the orientation of the global gradient vector: The decisional algorithm is based on voting principle. This method calculates for each pixel, the gradient orientation; actan Our objective consists in scanning the image according to the direction where minimal pixel's change is recorded, which corresponds to the direction perpendicular to the pixel gradient one.
Thus, depending on this calculated direction, each pixel votes for one SFC that advantages the redundancies in the computed direction.
According to the aforementioned considered directions, the coder chooses between 4 proposed SFC's (cf. Figure  1): • Horizontal snake scan • Vertical snake scan We consider the following four values: • NH: number of votes for the horizontal snake scan; • NV: number of votes for the vertical snake scan; • NZ1: number of votes for the first zigzag scan; • NZ2: number of votes for the second zigzag scan.
Horizontal snake scan Vertical snake scan First Zigzag scan Second Zigzag scan For each image bloc, the appropriate scan is selected as follows: • If ( ) and

and 2
The minimal pixel's change direction is the horizontal one, consequently the selected SFC will be the horizontal snake scan.

and 2
The minimal pixel's change direction is the vertical one, consequently the selected SFC will be the vertical snake scan. The minimal pixel's change direction is the first diagonal one. Consequently, the selected SFC will be the first ZigZag scan The minimal pixel's change direction is the second diagonal one. Consequently, the selected SFC will be the second ZigZag scan.
In order to check the adopted decisional criteria, we tested our scan selection method justness on 5175 8x8blocks extracted from 20 images. For each block, we record the scan selected by the proposed method. Next we apply the four considered SFCs. Generated pixels sequences are DPCM and Huffman coded in order to detect the most efficient SFC (the one offering minimal string length) and then we check if it is the same chosen by our method. Among 5175 blocs, the proposed scan process based on the vote principle offers 4071 good decisions and then outperforms the one based on global gradient approach which offers 3965 good decisions.

III. AUTOCORRELATION IMPROVEMENT
The proposal for image gradient-based space filling curve is primarily motivated by the proposition that a curve tailored for a given image would better exploit its spatial coherence than a universal curve. To support this proposition, we compare the autocorrelation of 1-D pixelsequences generated by both gradient-based and Hilbert space filling curves (G-SFC). The pixel-sequences were generated for the four pictures in Figure 4, and their average autocorrelation is displayed. As a complementary approach to evaluate the redundancy of the pixel-sequences, images are scanned, block by block, respectively with linear scan, Hilbert scan, and the proposed gradient based scan. The resulting pixel-sequences were positioned (block by block) using linear scan to reconstruct the 2D pictures, and were compressed using the most prevalent lossless image compression techniques GIF ( Figure 4) and PNG ( Figure  5). The results, depicted in figure 4 and 5, show the vote based scan improvement in compression efficiency compared to classical scan (linear), Hilbert scan and the global gradient based scan.

V. CONCLUSION
Many SFC based compression methods are introduced in the literature. They attempted to translate the image into high correlated one dimensional signal in order to improve compression performances. In this context, we propose a new lossless compression approach based on gradient concept. The proposed coder tries to scan the image with the SFCs that advantage minimal pixels change direction detected by a gradient process. For each image block, the used SFC is selected according to some decisional algorithm. The one based on voting principle introduced in this paper has showed a visible performance improvement compared to global gradient based algorithm presented in previous works.
Compared to state-of-the-art approaches [12] [14], the proposed gradient based approach shows a considerable improvement in both correlation and compression performance. This improvement is principally due to two factors; first, the proposed scan takes its advantages from the local autocorrelation, which is accentuated in the block by block 2D image scanning. Second, the proposed method has insignificant additional data for further image reconstruction unlike other state-of-the-art approaches which require considerable additional data to code the non standard scan path.
There are several directions for future investigations; first of all, we will explore the proposed approach performances in color images. Another promoting direction could be interesting; it consists in extending the approach to lossy image compression context.