Soft Compression for Lossless Image Coding

Soft compression is a lossless image compression method, which is committed to eliminating coding redundancy and spatial redundancy at the same time by adopting locations and shapes of codebook to encode an image from the perspective of information theory and statistical distribution. In this paper, we propose a new concept, compressible indicator function with regard to image, which gives a threshold about the average number of bits required to represent a location and can be used for revealing the performance of soft compression. We investigate and analyze soft compression for binary image, gray image and multi-component image by using specific algorithms and compressible indicator value. It is expected that the bandwidth and storage space needed when transmitting and storing the same kind of images can be greatly reduced by applying soft compression.


INTRODUCTION
T HE purpose of image compression is to reduce the number of bits required to represent an image as much as possible under the condition that the fidelity of the reconstructed image to the original image is higher than a required value. Image compression often includes two processes, encoding and decoding. Encoding is to convert the input image into binary code stream by a coding method, while the decoding is the reverse process of encoding, which aims to restore the original image from the binary code stream.
There are two categories of image compression: lossy compression and lossless compression. Lossy compression allows the reconstructed image to be different from the original image, and it is supposed to be visually similar. Lossless compression requires the reconstructed image to be exactly the same as the original image, which leads to the compression ratio of lossless compression being much smaller than that of lossy compression. Although the compression ratio of lossy compression is higher, lossless compression still plays a gigantic role in a great deal of fields. Lossless compression should be employed in situations where errors cannot be tolerated or where there is significant value, such as medical images, precious cultural relics, deep space exploration, deep sea exploration and digital libraries.
Supposing that we regard an image as a random process, the minimum expected codeword length per pixel L * n will approach the entropy rate asymptotically, as shown in formula (1). However, for an actual image, the upper and lower bound of formula (1) cannot be calculated theoretically because one can't know the spatial correlation of pixels clearly.
It's impossible to reach the entropy rate and everything we can do is to make great efforts to get close to it. Soft compression [1] was recently proposed, which uses locations and shapes to reflect the spatial correlation of an image as far as possible from the perspective of information theory and statistical distribution, so as to achieve a better compression effect.
In the literature, most of image compression methods mainly consider three aspects to reduce the required number of bits when representing an image: coding redundancy, spatial redundancy and irrelevant information. Coding redundancy refers to that the probability of each pixel value in an image is diverse, so the average length can be reduced from the perspective of coding. Spatial redundancy means that pixels are spatially related where a pixel is similar to or depends on adjacent pixels [2], so the repeated information can be omitted. Irrelevant information refers to that an image contains information irrelevant to the human visual system or purpose, which leads to the redundancy. Image compression techniques usually improve its compression effect from one or several aspects.

Image Compression Method
Huffman coding [3] is an extraordinary method to eliminate coding redundancy for a steam of data, and any other code for the same alphabet cannot have a lower expected length than the code constructed by Huffman coding [4]. Arithmetic coding [5] and Golomb coding [6] are also approaches to eliminating coding redundancy, and they all require accurate probability models of input symbols. Run-Length coding [7] represents runs of identical intensities by a new coding value and length, but it may result in data expansion when there are few runs of identical intensities [2]. LZW coding [8] is a method to remove spatial redundancy, assigning fixed-length codewords to variable length sequences of source symbols, but it is easy to cause data explosion, especially when the input is with large size or irregular. Image predictive coding [9] is a means of transforming spatial redundancy into coding redundancy through prediction error.
Transform coding [10], [11] maps an image from the spatial domain to transform domain, and then encodes the coefficients of transform domain to attain the compression effect. This method can reduce the irrelevant information in an image from the visual point of view. As a tool of multi-resolution analysis, wavelet coding [12], [13] has been widely concerned and applied.
With the development of neural networks, image compression methods based on machine learning and deep learning have merged [14], [15], [16]. They use neural networks instead of the encoder and decoder to achieve image compression. As for image coding standards, there are some mature instances. JPEG [17] and JPEG-2000 [18] are based on discrete cosine transform [19] and wavelet transform [20], respectively. JPEG-LS [21] is specially designed for lossless compression, adopting predictive coding, Golomb coding and Run-Length coding.

Related Work
The earliest coding approaches using symbols and locations can be traced back to Symbol-Based coding [22]. A picture is denoted as a set of frequently occurring sub-images, called symbols. Storing repeated symbols only once can compress images significantly, especially in document storage where the symbols are usually character bitmaps that are repeated many times. But Symbol-Based coding is hard to generalize to other scenarios owing to the need of redesigning symbols. There are also some methods based on shape coding [23], [24], but none of them consider both shapes and locations at the same time. Fractal block coding [25] relies on the assumption that image redundancy can be efficiently exploited through self-transformability on a blockwise basis and it can approximate an original image by a fractal image. However, it is mainly used in lossy compression because it is tough to find a great deal of identical blocks from only one image.
Using database to find similar features is an active research topic in the field of image compression in recent years. In [26], it uses an off-the-shelf image database to find patches that are visually similar to each region of interest of the unknown input image according to associated local descriptors. These patches are then warped into input image domain according to interest region geometry and seamlessly stitched together. In [27], it makes use of external image contents to reduce visual redundancy among images by using SIFT descriptors [28]. In [29], it proposes a method of cloud-based image coding that no longer compresses images pixel by pixel and instead tries to describe images and reconstruct them from a large-scale image database via the descriptions. In [30], it adopts a semi-local approach to exploit inter-image correlation by using information from external image similarities. In [31], it proposes a cloud storage system that reduces the storage cost of all uploaded JPEG photos, at the expense of a controlled increase in computation mainly during download of requested image subset. In [32], it proposes a novel framework for image set compression based on the rate-distortion optimized sparse coding.

Soft Compression
Soft compression is a lossless image compression method that is based on information theory and statistical distribution to eliminate coding redundancy and spatial redundancy at the same time. It was first proposed in [1], using locations and shapes to represent a binary image.
The set of shapes used in soft compression is not designed by experts, but searched from dataset. Different datasets may have diverse codebooks for shapes, which ensures the adaptability of soft compression. At the same time, the codebook corresponding to each dataset is also complete, which contains all the possibilities of the smallest shape, which makes soft compression workable. Due to the adaptability and completeness of codebooks of soft compression, it can always achieve lossless compression effect for any image and any codebook. When the codebook and image match well, it will result in a better compression ratio.
The main idea of soft compression is to represent an image by a set of triplets (x i , y i , S i ), where (x i , y i ) denotes the position of shape S i in an image. The set of shapes is obtained by searching in the training set. After that, the set of codewords and codebook are obtained by variable length coding for the set of shapes according to the size and frequency of each shape. When an image is encoded, it will be transformed into a set of triplets (x i , y i , C i ) according to the codebook, where C i is the codeword of shape S i . When decoding, we also require to decode the compressed data into a set of triplets (x i , y i , S i ) according to the codebook, and then fill shapes in the corresponding locations to reconstruct the original image.
Soft compression is instrumental in reducing storage space and communication bandwidth in the process of transmitting and storing the same kind of images. When two sides communicate, the transmitter only needs to send the compressed data instead of the whole picture to the receiver in the case that both sides have identical codebooks.
In this paper, we try to answer the following two fundamental problems for lossless image compression.
x How to detect an image to be compressible in theory? In other words, what is the value of compressible indicator function for an image?
y If one image is compressible, how to find a way to compress it through increasing the value of compressible indicator function.
These two problems are great challenges in the theory of image compression. This paper is organized as follows. We first introduce a new concept, compressible indicator function with regard to image by using information theory and then use it to evaluate the performance of soft compression in Section II. In Section III, some soft compression algorithms for binary image, gray image and multi-component image are proposed. Then we give the experimental results and theoretical analysis in Section IV. Finally, we conclude this paper in Section V.

THEORY
Soft compression is based on statistics and information theory to achieve the image compression effect. Since the image has characteristics of spatial redundancy and coding redundancy, soft compression is committed to eliminating these two kinds of redundancy at the same time by filling an image with locations and shapes. In this section, we introduce the theory of soft compression.

Information Theory
Information theory provides the answer to the lower bound of data compression. For an image, the minimum number of bits per pixel needed is given by formula (1), which is the entropy rate of a random process. Definition 2.1. Let Z be a discrete random variable with alphabet Z and probability mass function p(z) = Pr{Z = z}, z ∈ Z. The entropy [33] H(Z) of a discrete random variable Z is defined by The entropy is a measure of the average uncertainty in the random variable and also clearly shows the required number of bits on average to describe the random variable [4]. In this paper, we take all logarithms to base 2 so that entropy is measured in bits unless otherwise specified.

Definition 2.2.
Supposed that Z is a random variable with only two events, i.e.
Then the entropy of Z is given by Note that H(p) is a concave function of p and equals 1 when p = 0.5. In the case where p = 0 or p = 1, H(p) reaches its minimum value of 0 because the random variable becomes a constant due to the lack of randomness. If the random variable represented by each pixel in an image is independently and identically distributed, then the minimum expected number of bits required per pixel is the entropy of this random variable. However, for an actual image, the probability distribution of each pixel cannot be independently and identically distributed. Due to the spatial correlation, the minimum expected number of bits required for a pixel is the entropy rate of the random process corresponding to an image. How to evaluate it is still an open problem in the literature.

Image Fundamentals
Let I denote a digital image with intensity levels in the range [0, D − 1] whose row and column dimensions are M and N , respectively. r k is the k-th intensity value and n k is the number of pixels in the image I with intensity r k [2]. We define X as a discrete random variable with probability mass function p(x k ) X reflects the frequency distribution of the intensity value of pixels in an image.
Let Y denote another discrete random variable with X removed from event r 0 and p = Pr{X = r 0 }, then Y reflects the frequency distribution of the remaining intensity values after removing r 0 from X in an image. Lemma 2.1. Let H(X) and H(Y ) denote the entropy of X and Y , respectively. then, where H(p) comes from Definition 2.2. Proof.

Soft Compression
Soft compression is a lossless image compression method which aims to use locations and shapes to denote an image. The purpose of soft compression is to find essential shapes of images.
We define S and C as the finite set of shapes and codewords in soft compression, respectively. Let T denote the total number of operations in the process of soft compression for an image I [1].
Let S i ∈ S, i = 1, ..., T be the shape used in the i-th operation, C i ∈ C, i = 1, ..., T be the codeword of S i , the location of shape S i in an image is defined as a pair (x i , y i ). We use F i (S i ), i = 1, ..., T to denote filling the image with shape S i at position (x i , y i ) in the i-th operation.
Then, soft compression can be formulated as the following optimization problem: where l(C i ) is the number of bits in the codeword C i and l(x i , y i ) is the length of bits needed to represent a location pair (x i , y i ). The constraint reflects that the original image I can be reconstructed by filling shapes in the corresponding positions through T operations. That is, soft compression is lossless. The core goal of soft compression algorithm design is to find S and C, so as to encode images efficiently.

Image Compression
Definition 2.3. We define compressible indicator function (CIF) with respect to p as For an image whose probability of r 0 is p, we define compressible indicator value (CIV) as the value of CIF.
Compressible indicator function C(p) is derived from Lemma 2.1, which represents the sparsity of an image. The larger it is, the more sparse the image is, and the image has more capacity to be compressed. The basic properties of compressible indicator function can be summarized as follows.
therefore, C(p) is monotonically increasing.
Definition 2.4. we use B nb to denote the number of bits needed to encode an image with natural binary code, B hf for Huffman coding, and B n sc for soft compression where the size of shapes is ranging from 1 to n, i.e. soft compression with n order. B hf,min and B n sc,min represent their minimum values, respectively.
Let L hf denote the average number of bits required to represent each pixel with Huffman coding, and L 1 sc for soft compression where the size of all shapes is one. Then, where L W is the average number of bits required to represent a location with soft compression. Theorem 2.2. If C(p) ≥ L W and H(X) > 0, the minimum number of bits needed with 1 order soft compression is less than that with Huffman coding, i.e. B 1 sc,min ≤ B hf,min , and the relative compression ratio R is Proof.
Equation (26) From Theorem 2.1, we know that C(p) increases monotonically in (0, 1). Due to the non-negativity of entropy and the trivial case for H(X) = 0, we mainly consider the case where H(X) > 0, then It completes the proof.
Theorem 2.2 gives a threshold about the average number of bits required to represent a location with soft compression by using CIF. When L W is less than this threshold, the minimum number of bits needed to represent an image with soft compression is lower than that of Huffman coding.
In general, we use the minimum value to approximately replace the actual value needed for compression, which is convenient for theoretical analysis. Theorem 2.2 indicates that for an image whose compressible indicator value is greater than the average number of bits required for a location, soft compression is better than Huffman coding in terms of compression ratio. It also points out that the larger the compressible indicator value, the higher the compression ratio. Fig. 1 illustrates the relationship between compressible indicator function C(p)and p. Theorem 2.2 presents a rule to use soft compression. Given an image, we should first evaluate the value of compressible indicator function according to p, and then judge whether it is suitable for soft compression. That is to say, if (p, L W ) is in the gray area, the minimum number of bits needed with 1 order soft compression is less than that with Huffman coding. As shown in Fig. 1, it gives an answer to the first fundamental problem of lossless image compression.

Lemma 2.2.
Let Y n represent the frequency distribution of a shape whose size is n in an image, then Proof. From the independence bound on entropy, one can come to this conclusion.

Theorem 2.3.
If L W is a constant for different orders of soft compression, then B n sc,min ≤ B 1 sc,min . Proof. We use N 1 to represent the number of shapes with size 1 used in an image, and N n is the number of shapes with size n. The derivation can be seen from (37) to (41). Theorem 2.2 and 2.3 inspire us that in image compression, we can improve the compression ratio from two aspects: one is to increase the compressible indicator value of an image; the other is to reduce the number of bits needed to represent locations. On one hand, compressible indicator value can be increased by predictive coding which only encodes prediction error. On the other hand, Golomb coding maybe a promising method for encoding the distance between each location and the previous location in order to reduce L W .

IMPLEMENTATION ALGORITHM
In this section, we try to answer the second problem, to find some ways to increase the compression ratio of images by raising compressible indicator value. We first introduce the algorithms of soft compression for different image formats, including binary image, gray image and multi-component image. In fact, three different algorithms vary in specific steps but all try to make use of locations and shapes to represent an image from the perspective of information theory and statistical distribution.

Binary Image
Binary image is quite suitable for lossless compression using soft compression method, because the pixel of binary image has only two intensity values. The probability of occurrence of r 0 can always be greater than or equal to 0.5 (through reverse operation), which ensures that the compression indicator value is greater than or equal to 2.
The soft compression algorithm for binary image was proposed in [1], which has an excellent compression effect. Although [1] introduced the algorithm for binary image, it didn't give a theoretical analysis. We will analyze the experimental results by using compressible indicator function in Section IV.

Gray Image
An important procedure of soft compression algorithm for gray image is to divide the image into two layers, shape layer and detail layer. In fact, compressible indicator value of shape layer is usually large, so the combinations of locations and shapes are used to encode. While compressible indicator value of detail layer is relatively small, and other common coding methods can be used in detail layer. Soft compression algorithm for gray image includes predictive coding, negative-to-positive mapping, layer separation, shape search, codebook generation and so on. We will introduce the vital steps one by one.

Predictive Coding and Negative-to-Positive Mapping
Predictive coding [9] is a way to transform spatial redundancy into coding redundancy by means of prediction. The main idea of predictive coding is to calculate the prediction value of the pixel according to the spatial correlation, so as to encode the prediction error.
Let I(x, y),I P (x, y) and I E (x, y) denote the pixel intensity value, predictive value, prediction error at location (x, y), respectively. The image predictive coding method [21] we use is shown in the formula (42), where the spatial relationship between pixels is displayed in Fig. 2.
After getting the predictive value, one can get the prediction error by formula (43). The range of the prediction error is in [−D + 1, D − 1], which is different from the range of pixel intensity value [0, D − 1]. We use formula (44) to map prediction error from negative to positive, which is conducive to the subsequent layer separation.
After predictive coding and mapping, the proportion of pixel value r 0 increases, which also leads to the increase of compressible indicator value. The image will be more conducive to the use of soft compression for image coding. Another reason for adopting predictive coding and mapping is that the same image will produce the same result after these two operations. The reversibility of steps ensures the lossless performance of soft compression algorithm.

Layer Separation
Soft compression is suitable for images with large compressible indicator value. After the previous steps, the compressible indicator value of the image is significantly I(x-1,y-1) I(x-1,y) I(x,y-1) Ip(x,y) increased. We want to further increase it. On one hand, we observe that the probability of the prediction error decreases with the increase of the error intensity value. On the other hand, through a proper separation, one image with large compressible indicator value and another with small compressible indicator value can be generated. Layer separation and bit-plane coding [34] are similar, but bit-plane coding focuses on decomposing a multilevel image into a series of binary images and compressing each binary image via one of several well-known binary compression methods, which will produce many layers. Layer separation produces only two layers, shape layer I S and detail layer I D .
I is divided into shape layer I S and detail layer I D via formula (45) and (46).
where // and % represent quotient and remainder operation, respectively. Layer interface l is a constant between 0 and log D which can be given in advance by searching or experience.
Because of the compressible indicator value of the shape layer is usually large, the combinations of locations and shapes are used to encode. While compressible indicator value of detail layer is relatively low, other coding methods such as Huffman coding [3] and block coding can be used to compress.

Shape Search and Codebook Generation
The shape layer uses locations and shapes to encode, the set of shapes directly determines the compression ratio and coding efficiency of an image, so how to find the set of shapes is vital.
A is an M × N matrix whose components are in [0, 2D − 2], u i and v j are vectors, representing the i row and the j column of A, respectively. The matrix whose u i and v j that follows (47) and (48) is compatible for designing shapes.
(47) and (48) show that the number of non-zero elements in all rows and columns of a matrix must be no less than half of the row size and column size, respectively. By keeping only the non-zero value blocks in the matrix and removing the zero value blocks, we can get the final shape. Using this method, we can avoid the situation that different matrices produce the same shape. As illustrated in Fig. 3, there is a part of shapes. These shapes are classified by size and not considered intensity values. Combine them with error intensity value [1, 2D − 2] to produce shapes that are actually in use.
However, not all shapes will appear in the final shape set. In fact, only a small number of shapes can be retained all the time. This is because in the process of searching, the set of shapes will be updated dynamically, and shapes with less frequency will be deleted, so as to ensure that the total number of shapes will not be too much.
After getting the set of shapes, codebook for shape layer can be generated according to the frequency and size of each shape. When searching for the set of shapes used in the shape layer, we also count the frequency distribution of pixel intensity value in the detail layer, so as to generate the codebook for detail layer. In the process of communication, when both sides have the same codebook, the transmitter can directly send compressed data instead of the whole image to the receiver, which is able to greatly reduce the communication bandwidth and storage space.

Golomb Coding for Locations
When the shape layer is encoded, a series of locations are generated. By using Golomb coding for the distance difference between each location and the previous location, the number of bits needed to represent these locations can be reduced.
Golomb coding [6] was designed for non-negative integer input with geometric probability distribution. Golomb coding of one location we used adopts the following steps.

•
Step 1. Calculate the distance difference ∆ from the previous location.

•
Step 2. Get a positive integer m by giving or searching in advance.

•
Step 3. Form the unary code of quotient ∆/m . (The unary code of an integer q is defined as q 1s followed by a 0.)

•
Step 4. Let k = log 2 m , c = 2 k − m, r = ∆ mod m, and compute truncated remainder r such that r = r truncated to k − 1 bits 0 ≤ r < c r + c truncated to k bits otherwise (49)

•
Step 5. Concatenate the results of steps 3 and 4.
The location difference obtained by soft compression approximately obeys geometric probability distribution. Fig. 4 shows the empirical frequency distribution of location difference on Fashion-mnist dataset by using soft compression algorithm for gray image which has a good match to the scenarios of Golomb coding. Under the prior information, using Golomb coding will greatly reduce the space for storing location differences.

Encoder
When an image is encoded, preprocessing is needed first, which includes predictive coding, negative-to-positive mapping and layer separation. Secondly, two codebooks are used to encode the shape layer and the detail layer, respectively. Thirdly, locations in the shape layer are encoded by Golomb coding. Finally, connect the encoded results of the two layers to obtain the compressed data. Fig. 5 shows the entire process of Encoder. Fig. 6 illustrates the composition of the compressed data. Header part contains information about the height and width of an image and the layer interface. Shape layer data and detail layer data carry the encoding results of these two layers, respectively.  Fig. 7 summarizes the overall procedure of soft compression algorithm for gray image. We design the set of shapes firstly, and then search the frequency of each designed shape in the training set while updating the set of shapes by deleting shapes whose frequency are below the reference value. After getting the final set of shapes and its frequency, we use Huffman coding to generate the codebook for the shape layer. In the training stage, we will also acquire the codebook for detail layer at the same time. Codebooks are used in the Encoder and Decoder, which should also be stored or transmitted for subsequent usage.

Overall Procedure
In the testing stage, the image will be compressed through the Encoder. When the sender wants to communicate with the receiver, it will firstly transmit two codebooks. After both sides of the communication have the same codebook, the transmitted content will be the compressed data instead of the original image.
After storage or transmission, the receiver will get the compressed data. Decoder adopts the opposite structure to the Encoder, and the original image can be reconstructed by inputting the compressed data into Decoder. Firstly, the shape S i is obtained according to the codebook for shape layer, and then the shape S i is filled in the location (x i , y i ), shape layer I S is acquired by repeating T operations. Secondly, the detail layer I D is decoded by the codebook for detail layer from the compressed data. Finally, the original image can be recovered by merging I S and I D , positive-to-negative mapping and anti-predictive coding. Due to the completeness of codebooks, the recovered image is exactly the same as the original image, which ensures the lossless compression.

Multi-component Image
Considering multi-component image, soft compression algorithm for gray image can be used for each component. In this case, soft compression algorithm for multi-component image is equivalent to the combination of several soft compression algorithms for gray image, and the compressed data are also a combination of several components.

EXPERIMENTAL RESULTS AND THEORETICAL ANALYSIS
In this section, we reveal the experimental results and theoretical analysis of soft compression algorithms. Definition 4.1. Supposed that b and b represent the number of bits required to express the same image by using natural binary code and other coding methods, respectively. The compression ratio R is defined as and R avg is defined as the average compression ratio of a class of images.
The compression ratio reflects the effect of different coding methods. We use it as an significant criterion to measure coding methods in this section.

Binary Image
Soft compression algorithm for binary image [1] is tested on the MNIST [35] dataset and has excellent results. In this subsection, we analyze the experimental results theoretically. MNIST has ten categories, different classes have different compressible indicator values, and the frequency histogram of compressible indicator value is shown in Fig. 8. Although they are of different classes, the compressible indicator value is generally subject to the normal distribution. Table 1 illustrates the average compressible indicator value and compression ratio of MNIST dataset by using the same codebook. From Table 1, it is shown that they are positively related, the larger the average compressible indicator value, the greater the average compression ratio, which is consistent with the theoretical result in Theorem 2.2. It enlightens us that soft compression is suitable for compressing images with large compressible indicator value. Although the compression ratio is not only related to this factor, the compressible indicator value becomes a key element affecting the compression ratio.

Gray Image
In this subsection, we obtain the compression ratio of Fashion-mnist [36] by using soft compression algorithm for gray image. Table 2 illustrates results of soft compression algorithm for gray image on Fashion-mnist, it is the result of cross validation. The first row represents each category of testing set and the first column denotes codebooks generated by the corresponding class in the training set. The value in (i, j) denotes the average compression ratio R avg of j-th class of testing set by using the codebook generated by i-th class of training set.
It is observed that values on the diagonal are higher than that of the same column, which suggests that soft compression is related to the training set for generating the codebook. The more suitable codebook is used for encoding one class of images, the higher the corresponding compression ratio will be.
In practice, for the same kind of images, it is better to adopt the corresponding codebook. However, the use of different types of codebook for encoding will not produce disgusting consequences, and will not cause loss of images. In fact, codebooks of soft compression are complete, that is to say, for any codebook and any picture, lossless compression can always be attained in the image dataset. The difference lies in diverse compression ratios.
From Table 2, we can draw a conclusion that the compression ratio is both related to codebooks and images. It is reflected in the image compressible indicator value and the similarity between images and codebooks. The larger the compressible indicator value of image is, the higher the similarity between images and codebooks generated by the training set, then the compression ratio will become higher.  Fig. 7. The overall procedure of soft compression algorithm for gray image including training and testing. The shape design, frequency search, shape update, detail acquisition, codebook generation, and saved codebook are the training stage. On the other hand, the encoder and decoder are the testing stage.

Multi-component Image
In this subsection, we show an instance of Fundus Image Registration dataset [37] by using soft compression algorithm for multi-component image. We use ten images in the dataset to train the codebook, and test the compression effect of another image. Fig. 9 illustrates an example, whose compression ratio is 3.40. Subfigure (a) is a multi-component original image, whose components are B, G and R, respectively, as shown in (b), (c) and (d). Subfigure (e) to (j) show images after dividing these three components into shape layer and detail layer respectively (binarization has been made for clearer appearance). Subfigure (k) can be obtained through decoding, which is the same as (a).

CONCLUSION
In this paper, we investigated how to use soft compression to represent an image, which is in lossless mode. It is based on information theory and statistics to eliminate coding redundancy and spatial redundancy at the same time by using locations and shapes of codebook. Due to the adaptability and completeness of codebooks of sot compression, it can always achieve lossless compression effect for any image and any codebook.
In theory, we also proposed a new concept, compressible indicator function with regard to image and theoretically analyzed the performance of soft compression, which pointed out the suitable scenarios of soft compression. Compressible indicator function also gives a threshold about the average number of bits required to represent a location by using soft compression.
At the same time, we designed soft compression algorithms for binary image, gray image and multi-component image. These algorithms have been tested on the dataset.  Experimental results 1 indicated that soft compression has sound effects on lossless image compression, especially for images which have a large compressible indicator value. This paper focuses on lossless compression. However, soft compression can also be combined with other transformation methods, such as wavelet transform. Lossy compression can be realized by using soft compression for the coefficients in the transform domain. Soft compression can also be combined with channel coding to enhance the effect of joint source-channel coding.