Enhancement of Curve-Fitting Image Compression Using Hyperbolic Function

Image compression is one of the most interesting fields of image processing that is used to reduce image size. 2D curve-fitting is a method that converts the image data (pixel values) to a set of mathematical equations that are used to represent the image. These equations have a fixed form with a few coefficients estimated from the image which has been divided into several blocks. Since the number of coefficients is lower than the original block pixel size, it can be used as a tool for image compression. In this paper, a new curve-fitting model has been proposed to be derived from the symmetric function (hyperbolic tangent) with only three coefficients. The main disadvantages of previous approaches were the additional errors and degradation of edges of the reconstructed image, as well as the blocking effect. To overcome this deficiency, it is proposed that this symmetric hyperbolic tangent (tanh) function be used instead of the classical 1stand 2nd-order curve-fitting functions which are asymmetric for reformulating the blocks of the image. Depending on the symmetric property of hyperbolic tangent function, this will reduce the reconstruction error and improve fine details and texture of the reconstructed image. The results of this work have been tested and compared with 1st-order curve-fitting, and standard image compression (JPEG) methods. The main advantages of the proposed approach are: strengthening the edges of the image, removing the blocking effect, improving the Structural SIMilarity (SSIM) index, and increasing the Peak Signal-to-Noise Ratio (PSNR) up to 20 dB. Simulation results show that the proposed method has a significant improvement on the objective and subjective quality of the reconstructed image.


Introduction
Image processing has been considered to be one of the most important applications of computer engineering in recent decades.It has become one of the pillars of modern technology, and consists of several branches that work to improve image quality [1], image retrieval [2], image restoration [3], and image compression [4], which is considered to be the most important branch as it deals with reducing the size of the image.Due to the large increase of data and information, including the increased volumes of digitized medical information, hyperspectral, and digital images, the challenge now is how to deal with the storage and transmission requirements.This is why image and data compression is still considered an effective research field [5,6].
The purpose of image compression is to minimize image size while retaining maximum information considering the human eye abilities such as a low sensitivity of distinguishing colors.For example, the uncompressed colored image BMP contains 2 24 (more than 16 million) colors while the human eye can only distinguish up to 256 color levels.Therefore, high accuracy color information will not be sensed by the human eye, thus, image size can be reduced and therefore this can be considered to be the basic principle of image compression [1].
In general, image compression methods are divided into two categories; lossless and lossy methods.Lossless methods maintain image pixels without any loss, i.e., the original image can be completely recovered after the decompression process.TIFF (Tagged Image File Format), LZW (Lempel-Ziv-Welch), and PNG (Portable Network Graphics) are examples of these methods that are suitable for web browsing, image editing, and printing.Lossy methods benefit from the inherent redundancies of the image, such as psycho-visual redundancy, inter-pixel redundancy, or coding redundancy to reduce the amount of data needed to represent the image, i.e., the original image cannot be completely recovered.Therefore, lossy methods give high compression ratios with low signal-to-noise ratios (PSNR).JPEG is an example of this approach, which is a suitable method for most images [7].
Furthermore, image compression can be implemented into two domains, namely spatial and frequency.In the spatial domain, the digital image is decomposed into its bit-planes [8], and the process detects how to ignore some of these pixels without affecting the resulting image [9].In the frequency domain a discrete transform such as Discrete Cosine transform (DCT), Fourier Transform (FT), or Wavelet Transform (WT) that can be applied to compact the energy of the image into only few coefficients, while low coefficients can be set to zero, followed by quantization and entropy coding, such as Huffman coding method, to reduce the number of bits required to represent pixel value (bpp) [10].
Curve-fitting has been used in different image processing algorithms, such as image compression through plane fitting [11], block-based piecewise linear image coding using surface triangulation [12], image representation and creation based on curvilinear feature driven subdivision surfaces [13], segmentation-based compression using modified competitive learning network [14], as well as segmentation-based gray image compression through global approximations of sub-images by 2D polynomial along with corrections [15].
During the last two decades, image compression methods in the spatial domain have been developed using 2D curve-fitting, which essentially transforms the image from random values to simple mathematical equations (linear or non-linear) [2].2D curve-fitting depends on dividing the image into blocks of pixels, which are converted into a set of equations.Thus, it can reduce the size of the storage space and save only a few coefficients of the equation that represent the blocks of image.This is theessential idea of this image compression approach [2,11,13].
Ameer and Basir implemented a scalable image compression scheme via plane fitting by dividing the image into non-overlapping blocks (typically of 8 × 8 pixels) and presented each block with only three or four quantized coefficients.The block center was chosen as the origin followed by simple quantization and coding schemes to reduce the cost [16].Sadanandan and Govindan proposed a lossy compression method to eliminate the redundancy in the image using two steps, namely skipline encoding and curve-fitting-based encoding [17].Liu and Peng proposed a rotating mapping curve-fitting algorithm for image compression; this method depends on the correlation of the DC component and the rotation angle between adjacent blocks.They have proven that lots of blocks need less curve-fitting data to fit the AC component [18].Sajikumar and Anilkumar proposed bivariate polynomial surface fitting for image compression.Chebyshev polynomials of first kind were used to generate the surface for each block; this method stores three to four parameters of the fitted surface at each block instead of pixel values.Therefore, its compression ratio did not depend on redundant information but depended on a predefined block size [19].Al-Bahadili proposed a method that depended on the value of block-pixels variance to apply two adaptive polynomial fittings for image compression combined with uniform quantizer and Huffman encoding, the variance value of each block determined the minimum number of coefficients for each block [20].Image compression using curve-fitting has applied on wireless multimedia sensor networks (WMSNs) for energy saving [21] and has been applied for intra-prediction coding modality of High-Efficiency Video Coding (HEVC) using a piecewise mapping (pwm) function [22].Hyperspectral image compression using Savitzky-Golay smoothing filter with curve-fitting model is presented in [23].Butt and Sattar proposed a curve-fitting model for image compression in [24].This study discussed a comparison using 4 × 4 and 8 × 8 block sizes at 1st-and 2nd-order curve and showed that there was a large difference in compression ratio for the same value of mean squared error or Peak Signal-to-Noise Ratio (PSNR).Using 4 × 4 block size has given better quality of images in comparison to 8 × 8 block size at the same curve-fitting order but less compression ratio [24].
Image compression using curve-fitting has many disadvantages and artifacts.Thus, it is still not widely used, but it is a promising and scalable method for research.This paper aims to improve the results that depend only on curve-fitting approach without applying any smoothing filter [23], segmentation algorithms [14], defining some polygon vertices [11][12][13], or without applying coding technique to the parameters [12,21,22].It uses a non-linear function which is more flexible than previous proposed curve-fitting or interpolation functions, which incorporates better edge and texture description.The proposed function model focuses on solving the problem of edge distortion of the decompressed image to get an image that is very similar to the original one.
The main weaknesses in all previously mentioned curve-fitting functions (linear or non-linear) in the related work are the edge quality (fine features) of the image and the blocking effects of the reconstructed image.Some works proposed a post-processing [16,19] or pre-processing process [13] to reduce these imperfections; however, this paper proposes an able curve-fitting function to maintain the fine details of compressed image.
The remainder of this paper is organized into further sections.Section 2 introduces 2D curve-fitting with image pixels.Section 3 explains the proposed compression method, while Section 4 demonstrates the experimental results.Finally, conclusions are drawn in Section 5.

2D Curve-Fitting of Image
Curve-fitting refers to the use of a mathematical expression to represent gathered random data into a group.This data has one or two dimensions.The 2-dimensional (2D) data is represented by a matrix of data such as the digital image that is saved and processed.This duality means that the image or block (small part) of the image (g(x, y)) can be represented as a 2D mathematical expression (z(x, y)).
To achieve data compression, least squares approximation was presented as an optimization algorithm where only a small number of coefficients is enough to represent all pixels in the block of the image.Mathematically, we have where g(x, y) is the original intensity value of the image (or any color component) and z(x, y) is the value from the suggested function.A simplified derivation of first order (plane) fitting was proposed by [24] as the following min The coefficients a, b, and c of a 2N × 2N block are computed from their N × N counter parts and were assumed uniformly distributed.The resulting values of the minimization procedure, usually 8 × 8 or 16 × 16, were retained whenever the resulting error was less than a prescribed threshold.A PSNR of 32 dB was reported for 16:1 compression (0.5 bpp) with high complexity in building the quad tree describing the sizes of the compressed blocks.To reduce the error energy imposed by quantizing a and b, the block center was selected as the origin of the coordinate system.In fact, the selection of the origin can also affect the range values of c [25,26].
The computation of 2N × 2N parameters from their N × N counterparts can be generalized for higher-order polynomials [27].A related quad tree approach was proposed to predict block corners from the upper left one.These four corners were used in the decoder to find the coefficients of (dxy + ax + by + c) [25,28].

The Proposed Method
In the abovementioned works, different functions (linear and non-linear) for 2D curve-fitting were used.These functions have satisfied good subjective results for the general view of the image, but the main drawback was the subjective quality (edges of the image).However, some works proposed special processes [13,14,16,19] to resolve the edges and texture description problem, but these processes have reduced PSNR and increased the image reconstruction time.
In this paper, a 2D curve-fitting function for image compression is proposed to maintain edges and texture of the reconstructed image.This function is a hyperbolic tangent (tanh(x)), and is a non-linear function that has three main sections as shown in Figure 1; the first section is a semi-linear function that works with the growing area in the image (block), the second section works with edges, while the third section is a flat part that works with flat area in the image.
where a is the base value of the block (minimum value), b is the growing parameter, while c and d are controlling the edge orientation in the block.The edge orientation changes slowly for large coefficients (c or d), the condition in Equation ( 4) is for achieving perceptible orientation change, the maximum value of tanh function is 0.964 (tanh(2)) at the end corner of the block N × N, this condition will shrink the values of these coefficients and reduce the number of coefficients to three, which as a result, will increase the Compression Ratio (CR).To represent the image using Equations ( 3) and ( 4), their coefficients (a, b, c, and d) need to be calculated.First, we divide the image into blocks, each one consists of N × N points, then we save the N × N block corner values as (g(1, 1), g(1, N), g(N, 1), and g(N, N)), and finally we rotate the block g(x, y) to move the minimum corner value at the left bottom corner (t(1, 1)).
The rotated block is then called t(x, y), this block is then used to calculate the coefficients a, b, c, and d as follows: Hence, the calculated coefficients are considered as initial values and are used to find the final values of these coefficients as in Equation (1), which reduces the error between the estimated values (z(x, y)) and the actual values (t(x, y)), these coefficients are then codded and saved in three separate matrices which are called f a , f b , and f c .
The decompression process uses these matrices to re-generate the blocks and re-rotate them to the correct position, then grouping them in one matrix (image).A simple post-processing technique could be used to enhance the final result (final image).

Simple 4 × 4 Block Compression Algorithm
A simple case for the proposed work using 4 × 4 block size can be described in the following four main steps.The first step is pre-processing, the second step is calculating the initial values of the coefficients, which will be used to find the final values of these coefficients (a, b, c and d), and the third step is the enhancement of these values using Equation (1), while coding these coefficients will be implemented in the fourth step.
Step 4: coding Hence, Figure 3 shows an example for these matrices.

Simple 4 × 4 Block Decompression Algorithm
The decompression process is simple and fast and comprises of two steps, representing the inverse of Step 4 and Step 2 of the compression side, as follows: Step 1: decoding Find a, b, m 0 , m 1 , c, and d as follows: Step 2: block values calculation 1. Calculate the values of z(x, y) for x = 1, . . ., 4 and y = 1, . . ., 4 using Equation (3) for each point of the block.2. Re-rotate the block using the values of m 0 and m 1 .

Experimental Results
Image compression quality can be assessed using three main factors, which are CR, PSNR, and Structural Similarity Index (SSIM) [13,21].Image CR can be defined as [2]: PSNR is defined as [2].
where g and ĝ are the original and reconstructed image pixel value respectively, x = 1, . . .X and y = 1, . . .Y, where X and Y are image dimensions.Structural Similarity Index (SSIM) measures the range of structural variation of reconstructed image over original one [13,21].Its value ranges between 0.0-1.0,higher value means small structural variation, and vice versa.
Optimum edge detection of the image can be considered to be an important factor for defining subjective image quality, therefore; in this manuscript, edge detection test will be considered as another measurement for image compression quality.
Applying 1st-order curve-fitting using 4 × 4 block size gave better quality than using 8 × 8 block size, and it gave better image quality than 4 × 4 (or 8 × 8) block size when 2nd-order curve-fitting was applied [16,26].Therefore, the test process in our experimental work will use 4 × 4 block size applying 1st order for comparison purposes.
The CR result will be the same value for all tested images, because each block consists of 16 pixels (each one of 8-bits) and the result is consisting of three coefficients (each one of 8-bits), then the CR = 16:3 = 5.3:1 without quantization and entropy coding, while using them the CR value could reach 14:1 [4].

Objective Test (PSNR)
The first test compares the PSNR of six standard test images (PEPPER, BOAT, LENA, HOUSES, CLOWN, and MAN), Figure 4 shows CR results of the six test images using the proposed method and 1st order method, while PSNR and MSE results are listed in Table 1.From Table 1 we can note that the proposed method (tanh function) increased the average of the PSNR from 8.5 dB to 29.7 dB under same conditions.This test uses 4 × 4 block size without quantization and entropy coding and without applying any pre-processing.

Subjective Test (Edges)
The subjective test is comprised of edge detection and SSIM index.Edge detection test compares the edge sharpness of six test images that have been used in the objective test, the results are shown in Figure 5. From this figure, we note that the proposed method enhances the edges of the reconstructed image and removes the blocking effects.To evaluate our compression quality, we have used SSIM index which evaluates the human subjective assessment [13], Table 2 shows the SSIM results of the proposed method and JPEG for same objective quality (PSNR).From this table, it is observed that the proposed method has better SSIM results than JPEG, although they have same PSNR (obviously, the CR of JPEG is higher than the recent proposed method which does not use any quantization or entropy coding, but we have to recall that JPEG uses quantization and Huffman coding, which accomplished most of this CR).
Table 3 shows the SSIM and PSNR results of the proposed method and JPEG for the same CR which is 5.3, to realize a fair comparison between the proposed method and JPEG, neither quantization nor Huffman coding are applied to JPEG.   Figure 6 shows an example of image magnification (×2) based on our method and JPEG method.We can see that the image features are well preserved and without blocking effects when the proposed method is applied in comparison with JPEG for the same PSNR.Tables 1-3 and Figures 4-6 represent results of using only the curve-fitting function without any quantization and entropy coding or post-processing.The CR can be increased using quantization and entropy coding techniques [29] as in JPEG, so these results could be enhanced using post-processing filters [30,31] to reduce the blocking effects which are introduced through compression steps.

Conclusions
This manuscript presents a lossy compression method based on curve-fitting using the hyperbolic tangent function.Simulation results showed that the use of hyperbolic tangent function has increased the objective image quality (PSNR) by 20 dB in comparison with 1st-order curve-fitting function (4 × 4 block size), and has improved the subjective image quality (SSIM increased up to 10%) by removing the blocking effects and enhancing the edge and texture description in comparison with standard image compression method (JPEG) for the same PSNR, as well as both objective and subjective image quality of the reconstructed image using the proposed method is more satisfactory than JPEG for the same CR and neither quantization nor Huffman coding are used.
The proposed method is efficient for high-quality grayscale images, so it can be modified to RGB images and expanded to 8 × 8 block size to increase CR from 5.3:1 to 21.3:1 without quantization and entropy coding.The results of the 2D curve-fitting for high-quality colored images and 8 × 8 block size using hyperbolic tangent function and suitable quantization could compete with the CR of the JPEG method.Applying some smoothing filters on image data or increasing the size of block to 8 × 8 or 16 × 16 to improve the CR are part of our extensions for future work.

Figure 3 .
Figure 3. Results of Compression Method.(a): result of matrix a; (b): result of matrix b; (c): result of matrix c.

Figure 4 .
Figure 4.The first column: original images; the second column: results of proposed method; the third column: results of JPEG method, the fourth column: results of 1st-order curve-fitting.

Figure 5 .
Figure 5.The first column: original images edge detection; the second column: results of edge detection for proposed method; the third column: results of edge detection for JPEG method; the fourth column: results of edge detection for 1st order curve-fitting.

Table 3 .
Objective and subjective test results for the same CR (5.3).( 1 Neither quantization nor Huffman coding are used.)