Hybrid Encoding Scheme for AMBTC Compressed Images Using Ternary Representation Technique

: Absolute moment block truncated coding (AMBTC) is a lossy image compression technique aiming at low computational cost, and has been widely studied. Previous studies have investigated the performance improvement of AMBTC; however, they often over describe the details of image blocks during encoding, causing an increase in bitrate. In this paper, we propose an efﬁcient method to improve the compression performance by classifying image blocks into ﬂat, smooth, and complex blocks according to their complexity. Flat blocks are encoded by their block means, while smooth blocks are encoded by a pair of adjusted quantized values and an index pointing to one of the k representative bitmaps. Complex blocks are encoded by three quantized values and a ternary map obtained by a clustering algorithm. Ternary indicators are used to specify the encoding cases. In our method, the details of most blocks can be retained without signiﬁcantly increasing the bitrate. Experimental results show that, compared with prior works, the proposed method achieves higher image quality at a better compression ratio for all of the test images.


Introduction
With the rapid development of imaging technology, digital images are perhaps the most widely used media of the Internet. Because digital images themselves contain significant amounts of spatial redundancy, an efficient lossy image compression technique is required for lower storage requirement and faster transmission. The Joint Photographic Experts Group (JPEG) [1,2], vector quantization (VQ) [3,4], and block truncation coding (BTC) [5,6] are well-known lossy compression methods and have been extensively investigated in the literature. Among these techniques, BTC requires significantly less computation cost than others while offering acceptable image quality. BTC has been widely investigated in the disciplines of remote sensing and portable devices, in which computational costs are limited. BTC was firstly proposed by Delp and Mitchell [7]. This method partitions image into blocks, and each block is represented by two quantized values and a bitmap. Inspired by [7], Lema and Mitchel [8] propose a variant method called absolute moment block truncation coding (AMBTC), which offers a simpler computation than that of BTC.
The applications of AMBTC are studied in video compression [9], image authentication [10][11][12], and image steganography [13,14]. Moreover, some recoverable authentication methods adopt AMBTC codes as the recovery information to recover the tampered regions. Because the recovery codes have to be embedded into the host image, a more efficient coding of AMBTC is always desirable because the burden of the embedment can be reduced and the quality of the recovered regions can be enhanced. To improve the compression efficiency of the AMBTC method, several approaches, including bitmap omission [15], block classification [16,17], and quantized value adjustment [18], are adopted to lower the bitrate while maintaining the image quality. For example, Hu [15] recognizes that if the difference between two quantized values is smaller than a predefined threshold, the bitmap plays an insignificant role in reconstructed image quality. Therefore, Hu employs the bitmap omission approach by neglecting the recording of a bitmap if a block is considered to be flat, and only uses block means to represent the flat block. Chen et al. [17] adopt quadtree partitioning and propose a variable-rate AMBTC compression method for color images. The basic idea of [17] is to partition the image into blocks with various sizes according to their complexities. The AMBTC and bitmap omission technique are then employed to encode the image blocks. In some applications, such as data hiding or image authentication, bitmaps have to be altered to carry some required information, causing a degradation in image quality. Hong [18] optimizes the quantized values so that the impact of bitmap alteration can be reduced. Mathews and Nair [19] propose an adaptive AMBTC method based on edge quantization by considering human visual characteristics. This method separates image blocks into edge and non-edge blocks, and quantized values are calculated based on the edge information. Because the edge characteristics are considered, their method provides better image quality than other AMBTC variants.
Xiang et al. [16] in 2019 proposed a dynamic multi-grouping scheme for AMBTC focusing on improving the reconstructed image quality and reducing the bitrate. Their method partitions an image into non-overlapping blocks. According to the block complexity, varied grouping techniques are designed. An indicator is employed to distinguish the grouping types. In addition, instead of recording the quantized values, the differences between them are recorded so as to reduce the bitrate. Xiang et al.'s method provides better compression performance than those of prior works.
In Xiang et al.'s method, the number of pixel groups of an image block directly affects the reconstructed image quality and bitrate. Their method divides pixels of complex blocks into three or four groups during encoding, which may improve the image quality insignificantly but requires more bits for encoding. In this paper, we propose a ternary representation technique, which uses two thresholds to classify image blocks into three types, namely flat, smooth, and complex. We use the bitmap omission technique [15] to code flat blocks. The adjusted quantized values and an index pointing to one of the representative bitmaps are used to encode the smooth blocks. The complex blocks are encoded using three quantized values and a ternary bitmap. Compared with the AMBTC and Xiang et al.'s work, the proposed method achieves a higher reconstructed image quality with a smaller bitrate.
The reminder of this paper is organized as follows: Section 2 introduces AMBTC and Xiang et al.'s methods. Section 3 introduces the algorithms of this paper in detail. Section 4 presents the experimental results of the proposed method, and concluding remarks are provided in the final section.

Related Works
In this section, we briefly introduce AMBTC and Xiang et al.'s methods, which are compared with the proposed method for evaluating the encoding performance.

The AMBTC Method
The AMBTC method [8] compresses image blocks into two quantized values and a bitmap. The detailed approaches are as follows. Let I be the original image of size w × h and partition I into non-overlapping blocks {I i } N−1 i=0 of size n × n, where N = (w/n) × (h/n) is the total number of blocks. Let I i,j be the j−th pixel of i−th block. Therefore, I i = . For block I i , the averaged value m i can be calculated by: The j−th bit of bitmap B i , indicated by B i,j , is used to indicate the relationship between I i,j and m i . B i,j can be obtained by: The lower quantized value a i and higher quantized value b i are obtained by averaging the pixels in I i with values smaller than and larger than or equal to m i , respectively. This can be implemented by sequentially visiting pixels in I i . The lower quantized value a i is obtained by calculating the averaged value of visited pixels with values smaller than m i . Similarly, the higher quantized value b i is the averaged values of the other pixels. Therefore, the compressed code Each block is processed using the same manner, and the AMBTC compressed . The j−th pixel of I i can be decoded by: After all of the image blocks are reconstructed, the image I can then be obtained.

Xiang et al.'s Method
AMBTC uses the same approach to compress all image blocks. However, the same approach may not suitable for flat and complex blocks. As a result, Xiang et al. proposed an improved scheme to efficiently encode blocks according to their complexity, and achieve a better image quality than that of AMBTC with a satisfactory bitrate.
To determine the complexity of block I i , a threshold τ 0 is set. If b i − a i ≤ τ 0 , the variations of pixel values in block I i are relatively small. Therefore, all the pixels in this block are categorized as one group. In this case, the block mean m i is calculated, and this block is encoded by (m i ) 2 , which is the 8-bit binary representation of m i .
If b i − a i > τ 0 , the variations of pixels in block I i are large and these pixels need to be regrouped to achieve a better reconstructed image quality. Let G 0 i and G 1 i be the group of pixels with B i,j = 0 and B i,j = 1, respectively. Apply the AMBTC method to G 0 i and G 1 i to obtain According to a given threshold d min , this method uses the following rules to determine whether G 0 i and G 1 i should be regrouped: i > τ 0 and the total number of pixels in G 0 i is greater than d min . Rule 2: If b 1 i − a 1 i > τ 0 and the total number of pixels in G 1 i is greater than d min . If neither rule is met, block I i does not need to be further divided. Otherwise, block I i will be sub-divided into three or four groups using the following rules: (1) If only rules 1 or 2 are met, group G 0 i or G 1 i needs to be subdivided. The number of pixels needing to be subdivided is denoted by P i , and P i −bit bitmap B 0 i or B 1 i has to be used to record the bitmap of G 0 i or G 1 i . In this case, block I i is eventually divided into three groups.
(2) If both rules 1 and 2 are met, both G 0 i and G 1 i need to be subdivided, and block I i is eventually divided into four groups. Bitmap B 0 i and B 1 i have to be recorded to maintain the grouping information.
Xiang et al.'s method uses a 2-bit indicator I ND to record grouping information of I i . When block I i is divided into one to four groups, the indicator I ND is set to be 00 2 , 01 2 , 10 2 , and 11 2 , respectively. Moreover, if I i needs to be divided into three groups, an extra indicator is required to show which group is subdivided. Specifically, if G 0 i is sub-divided, then J i = 0. On the contrary, if G 1 i is sub-divided, then J i = 1.
To record the quantized values, Xiang et al.'s method records the smallest quantized value of a block using 8 bits, and utilizes a difference encoding scheme (DES) to encode the difference d i between two quantized values. In DES, if d i < γ, where γ is a predefined threshold, d i is recorded using log 2 (γ) bits. Otherwise, d i is recorded using log 2 (σ) bits, where σ is the maximum difference between quantized values in all blocks. An extra indicator Y i is used to distinguish these two methods. That is, if d i < γ, Y i = 0 is set. Otherwise, Y i = 1. The number of bits R i used to record the difference can be expressed as: We use the symbol (x − y) 2 to represent the R-bit encoded result of the difference between x and y using DES. For example, if x = 40, y = 28, and γ = 64, then d i = 12 < γ. Therefore, R = 7 and the encoding result is (40 − 28) 2 = 0 2 ||001100 2 , where || is the concatenation operator.
The compressed code and the number of bits required to record blocks I i of different grouping cases are summarized in Table 1. Each block is compressed using the same procedures and the final compressed code stream CS f of image I is obtained.
To decode CS f , the 2-bit indicator I ND is read. According to the read bits, four possible compressed codes shown in Table 1 with different lengths can be extracted. The image blocks can be reconstructed from the compressed codes, and the decompressed image can be obtained. The detailed decoding procedures can be referred to [16].

Proposed Method
The traditional AMBTC compression method uses the same number of bits to compress each block. However, coding in this way requires more bits than necessary for flat blocks and neglects too much image detail for complex blocks. Xiang et al.'s method improves AMBTC, resulting in better compression effects for both flat and complex blocks. However, in the processing of complex blocks, Xiang et al.'s method reconstructs the gray values of the image block by four quantized values. Although the quality of the reconstructed block is improved, it requires quantized values to be recorded and bitmaps with more bits. In addition, Xiang et al. adopt the traditional AMBTC method to compress the smooth blocks, which may increase the cost of recording bitmaps and quantized values.
In this paper, we propose a more effective solution by classifying image blocks into flat, smooth, and complex blocks based on thresholds τ 0 and τ 1 (τ 0 ≤ τ 1 ). Let Φ i = {a i , b i , B i } be the AMBTC codes of I i . If b i − a i ≤ τ 0 , I i is classified as a flat block. Because pixel variations in a flat block are small, all pixels in a flat block can be simply reconstructed by their mean to a satisfactory visual quality. If τ 0 < b i − a i < τ 1 , I i is classified as a smooth block. For the smooth block, we use a clustering algorithm to obtain representative bitmaps, and the original bitmaps are replaced by the indices pointing to the obtained bitmap. The two quantized values are also adjusted to reduce the error caused by the bitmap replacement. If b i − a i ≥ τ 1 , I i is classified as a complex block. We use three quantized values and a ternary map to represent the complex block to maintain better texture details. The encoding algorithms of these three types of blocks will be presented in the following sections.

Encoding of Flat Blocks
The pixel values of a flat block I i (i.e., b i − a i ≤ τ 0 ) are relatively close, and thus the bitmap plays an insignificant role in reconstructing the image block. Therefore, we omit the recording of the quantization value in addition to the bitmap, and use an 8-bit mean value (m i ) 2 to represent the flat block, where: and round(x) is the function rounding x to the nearest integer.

Encoding of Smooth Blocks
If τ 0 < b i − a i < τ 1 , the fluctuation of pixel values of block I i is more than that of a flat block. Therefore, we refer to I i as a smooth block. To reduce the bitrate, a codebook consisting of the k most representative bitmaps (codewords) is found, and the bitmap of the smooth block will be replaced by an index pointing to one of the codewords in the codebook. We use the k-means algorithm [20] to obtain the k most representative bitmaps. Let {a s , b s , B s } N s −1 s=0 be the set of AMBTC codes satisfying are also obtained. Note that the codeword with index α * s has the nearest distance to B s , that is: where B s,j and C α,j represent the j−th element of B s and C α , respectively. Instead of recording {B s } N s −1 s=0 , the proposed method uses the binary representation of {α * s } N s −1 s=0 as the required bitmap information. Therefore, the bits required to record the bitmap are reduced from n × n bits to log 2 (k) bits. To successfully decode the bitmap, we must have cluster centers {C α } k−1 α=0 and cluster indices {α * s } N s −1 s=0 . Therefore, {C α } k−1 α=0 must be included as part of the compressed codes.
When decoding a smooth block, because we use cluster center C α * s to replace the original bitmap B s , the quality of the reconstructed image block will be reduced. To minimize the reduced quality, a quantized value adjustment (QA) technique [18] is employed. QA is a technique originally used in a data hiding technique to reduce the distortions of the reconstructed AMBTC block when the original bitmap is replaced by secret data. Because bits in the bitmap are altered, distortions of the reconstructed block are inevitable. QA subtly adjusts the quantized values by counting the bit difference between the original bitmap and secret data. In the proposed method, the original bitmap is replaced by a cluster center, which resembles the situations in which the bitmap is replaced by secret data. Therefore, the QA technique can be applied in the proposed method. To find the minimum distortion, the QA technique adjusts a s and b s toâ s andb s by calculating: a s = a s ρ 00 + b s ρ 10 ρ 00 + ρ 10 (7) and:b s = a s ρ 01 + b s ρ 11 ρ 01 + ρ 11 (8) respectively, where ρ pq is the number of bits with B s,j = p and C α * s ,j = q, (p, q) ∈ {0, 1}. For example, ρ 01 indicates the number of bits with B s,j = 0 and C α * s ,j = 1. After adjustment of quantized values, the distortion due to the bitmap replacement will be smaller than that without adjustment. , where T c,j is a ternary digit ranging from 0 to 2 used to indicate which quantized value should be used to reconstruct the j−th pixel of I c . Because the value of T c,j is equally distributed over 0 to 2, we can simply encode the ternary digits 0 3 , 1 3 , and 2 3 by 0 2 , 10 2 , and 11 2 , respectively. We assume the encoded result

Encoding of Complex Blocks
can be reconstructed. When encoding a 4 × 4 ternary map, the average number of bits required in the proposed method is: Theoretically, recording 16 ternary digits requires 16 × log 2 3 = 26 bits, which is almost the same as in the proposed method. Therefore, the encoding of the ternary map used in the proposed method is effective.

Encoding Procedures
This section describes the procedures of the proposed method. To distinguish the encoding methods of three types of image blocks, an indicator is prepended to the code stream of each encoded block. The indicators 0 2 ,10 2 , and 11 2 are used to indicate a flat, smooth, and complex block is encoded, respectively. The detailed encoding procedures are shown as follows: Input: Original image I, block size n × n, thresholds τ 0 and τ 1 , parameter γ, and cluster size k. Output: Code stream CS f .
Step 1: using the AMBTC encoder and obtain codes

a flat block is visited and the code stream of block
obtained in Step 2, and block I i is encoded by Note that (b s −â s ) 2 is encoded using the DES, as described in Section 2.2.

Decoding Procedures
In decoding, data bits are sequentially read and decoded, and image blocks are reconstructed by decoding the read data bits. The detailed steps of decoding are listed as follows: Input: Code stream f CS , block size n n × , parameter γ , σ , and cluster size k .

Decoding Procedures
In decoding, data bits are sequentially read and decoded, and image blocks are reconstructed by decoding the read data bits. The detailed steps of decoding are listed as follows: Input: Code stream CS f , block size n × n, parameter γ, σ, and cluster size k.
Step 1: Extract CS A from CS f and reconstruct k cluster centers {C α } k−1 α=0 .
Step 2: Extract one bit b from CS f . According to the extracted bit, one of the following decoding cases is then performed: Case 1: If b = 0 2 , the block to be reconstructed is a flat block. All the pixel values of block I i are the decimal value of the next 8 bits extracted from CS f . Case 2: If b = 1 2 and the next extracted bit is 0 2 , the block to be reconstructed is a smooth block. Extract the next 8 bits and convert them to a decimal value to obtain the quantized valueâ s . Read the next bit from CS f . If the read bit is 0 2 ,b s is reconstructed by the decimal value of the next log 2 (γ) bits plusâ s . Otherwise,b s is reconstructed by the decimal value of next log 2 (σ) bits plusâ s . The clustering index α * s is the decimal value of next k bits, and the bitmap C α * s can be obtained from {C α } k−1 α=0 . Using the AMBTC decoder to decode â s ,b s , C α * s , the image block can be reconstructed.
Case 3: If b = 1 2 and the next extracted bits is 1 2 , the block to be reconstructed is a complex block. Extract the next 8 bits and convert them to a decimal value to obtain the quantized value q 0 c . Read the next bit from CS f . If the read bit is 0 2 , q 1 c is reconstructed by the q 0 c plus the decimal value of the next log 2 (γ) bits; otherwise, q 1 c is reconstructed by the decimal value of the next log 2 (σ) bits plus q 0 c . Using a similar manner, q 2 c is reconstructed. To reconstruct the ternary map T c,j n×n−1 j=0 , we start from j = 0 to j = n × n − 1 and repeat the following process: Read a bit b 0 from CS f . If b 0 = 0 2 , we have T c,j = 0. Otherwise, read the next bit , the j-th pixel of the image block is reconstructed by q 0 c , q 1 c , or q 2 c if T c,j = 0, 1, or 2, respectively.
Step 3: Repeat Step 2 until all image blocks are reconstructed, and the final decompressed image I is obtained.
We continue the example given in Section 3.4 to illustrate the decoding process. The detailed process and the decoded result are depicted in Figure 3. To decode the code stream CS 0 = 10 || 00100001 || 0 000101 || 0101011 2 , because the first bit is 1 2 and the second bit is 0 2 , the to-be-reconstructed block is a smooth block. Extract the next 8 bits from CS 0 and convert them into decimal representation; we obtainâ 0 = 33. The next extracted bit is 0. Therefore, the difference d 0 = 5 is the decimal value of the next log 2 (γ) bits, and we havê b 0 =â 0 + 5 = 38. Finally, extract log 2 (k) bits and convert them to a decimal value; we have α * s = 43 and the bitmap C 43 is obtained. The image block can then be constructed by decoding â 0 ,b 0 , C 43 using the AMBTC decompression technique.

Experimental Results
In this section, we conduct several experiments to show the effectiveness and applicability of the proposed scheme. We take eight grayscale images of size 512 512 × , namely, Lena, Jet, Baboon, Tiffany, Boat, Stream, Peppers and House, as the test images, as shown in Figure 4. These images can be obtained from the USC-SIPI image database To decode CS 1 = 11 || 00010011 || 1 1000010 || 0 110000 || 10101010 11101110 011100 0000 2 , because the first two extracted bits are 11 2 , the block to be decompressed is a complex block. Extract 8 bits and q 0 1 = 19 is the decimal value of these 8 bits. The next bit is 1 2 ; therefore, d 1 1 = 66 is the decimal value of the next log 2 (σ) = 7 bits and q 1 1 = 19 + 66 = 85 can be obtained. Similarly, the next extracted bit is 0 2 ; therefore, d 2 1 = 48 is obtained by converting the next log 2 (γ) = 6 bits to their decimal value, and q 2 1 = 85 + 48 = 133 can be obtained. Finally, we have to reconstruct T 1,j 15 j=0 from the remaining bits. Because the next extracted bit is 1 2 , we extract one more bit, which is 0 2 . Therefore, T 1,0 = 1 is obtained. The remaining 15 ternary digits T 1,j 15 j=1 can be decoded in the similar manner. Once we have q 0 1 , q 1 1 , q 2 1 and T 1,j 15 j=0 , block I 1 can be reconstructed. Figure 3b illustrates the decoding process of CS 1 .

Experimental Results
In this section, we conduct several experiments to show the effectiveness and applicability of the proposed scheme. We take eight grayscale images of size 512 × 512, namely, Lena, Jet, Baboon, Tiffany, Boat, Stream, Peppers and House, as the test images, as shown in Figure 4. These images can be obtained from the USC-SIPI image database [21]. We use the peak signal-to-noise ratio (PSNR) and bitrate to measure the performance. The PSNR is calculated by: where x i and x i represent the pixel values of the original and decompressed images, respectively. The bitrate metric is measured by the number of bits required to record each pixel (i.e., bit per pixel, bpp).
Appl. Sci. 2021, 11, x FOR PEER REVIEW 11 of 20 [21]. We use the peak signal-to-noise ratio (PSNR) and bitrate to measure the performance. The PSNR is calculated by:

The Performance of the Proposed Method
Because the number of cluster centers k and threshold greatly affect the coding efficiency in the application of the quantized value adjustment (QA) technique [18], we evaluate how the QA technique and these parameters influence the bitrate and image quality in this section. In all of the experiments, we set τ 0 = 4 because the flat blocks under this setting show no apparent block boundary artifacts.

The Performance of the Proposed Method
Because the number of cluster centers k and threshold greatly affect the coding efficiency in the application of the quantized value adjustment (QA) technique [18], we evalu-ate how the QA technique and these parameters influence the bitrate and image quality in this section.

Coding Efficiency Comparisons
In the coding of smooth blocks, the original bitmaps of smooth blocks are used to obtain the cluster centers, and the quantized values are adjusted using the QA technique to lower the distortions. Tables 2 and 3 show how the QA technique improves the image quality when the block size is set to 4 × 4 and 8 × 8, respectively. In this experiment, τ 1 = 16 and γ = 32 are set. As seen from the tables, the QA technique effectively enhances the quality of reconstructed images for every k. For example, in Table 2 and k = 128, the averaged quality of the reconstructed images with and without the QA technique is 34.63 and 34.52 dB, respectively. The averaged quality has improved by 34.63 − 34.52 = 0.11 dB. Similarly, in Table 3 when k = 128, the PSNR improvement is 31.86 − 31.76 = 0.10 dB. Therefore, the QA technique indeed reduces the distortion caused by replacing the original bitmap with a cluster center. Tables 2 and 3 also reveal that the increase in cluster size k also enhances the image quality. For example, in Table 3 when k = 128, the averaged PSNR of eight test images is 31.86 dB. When k = 256 and 512, the PSNR increases 31.91 − 31.86 = 0.05 dB and 32.00 − 31.86 = 0.14 dB, respectively. The reason is that a larger cluster size provides a greater chance to reduce the difference between the cluster centers and original bitmaps.
To evaluate how threshold τ 1 affects the performance of the QA, we plot the gain of PSNR when using the QA for various τ 1 with k = 128 and 512. The results are shown in Figure 5. Note that, in this experiment, a block size of 4 × 4 is set.
in reducing the distortion caused by the differences, and the bitmaps of Stream and Baboon images are more different from the cluster centers than the other images. Therefore, the improvement in PSNR after applying the QA technique is more significant than for the others. the blue squares, red dots, and black cross marks represent flat, smooth, and complex blocks, respectively. Because the same 0 τ is applied, it can be seen that the number of blue squares (flat blocks) is the same in Figure 6a-d. However, as 1 τ increases, the red dots increase and black cross marks decrease. The reason is that an increase in 1 τ leads more blocks to be categorized as smooth. It can also be inferred that a better image quality can be achieved at a smaller 1 τ but the bitrate will be higher because more blocks are deemed to be complex. Note that in the proposed method, more bits are required to represent a complex block than a smooth block.  Figure 5a,b shows that the gain in PSNR increases as τ 1 increases, and this is mainly because the number of smooth blocks also increases as τ 1 increases. Because more blocks are classified as smooth for larger τ 1 , more blocks will be processed using the QA technique. As a result, the gain in PSNR is higher when τ 1 is larger. It also can be observed that for each test image, the gain in PSNR is larger when k = 128 than that when k = 512. The reason is that a smaller k implies larger differences between the original bitmaps and cluster centers. Because the QA technique is capable of reducing the distortion caused by the differences, a larger PSNR improvement can be achieved for smaller k.
It is interesting to note that the gain in PSNR of the Stream and Baboon images increases more than that of other test images when varying τ 1 = 10 to τ 1 = 50 for both k = 128 and k = 512. Because these two images are more complex than the others, their bitmaps of smooth blocks are expected to be more different from the selected cluster centers used to replace the bitmaps. As previously mentioned, the QA technique is effective in reducing the distortion caused by the differences, and the bitmaps of Stream and Baboon images are more different from the cluster centers than the other images. Therefore, the improvement in PSNR after applying the QA technique is more significant than for the others.

Performance Comparison of Various τ 1
The parameter τ 1 controls the number of smooth and complex blocks. The number of complex blocks decreases as τ 1 increases. To see the distribution of flat, smooth, and complex blocks of a test image, we take the Lena image as an example to illustrate their distribution by varying τ 1 . Figure 6a-d shows the distributions of blocks when τ 1 = 8, 16, 32, and 64 are set. The block sizes in these figures are 8 × 8 and τ 0 = 4. In this figure, the blue squares, red dots, and black cross marks represent flat, smooth, and complex blocks, respectively.
Because the same τ 0 is applied, it can be seen that the number of blue squares (flat blocks) is the same in Figure 6a-d. However, as τ 1 increases, the red dots increase and black cross marks decrease. The reason is that an increase in τ 1 leads more blocks to be categorized as smooth. It can also be inferred that a better image quality can be achieved at a smaller τ 1 but the bitrate will be higher because more blocks are deemed to be complex. Note that in the proposed method, more bits are required to represent a complex block than a smooth block.  more bits per pixel than the latter. In addition, the experiments also reveal the fact that a large 1 τ effectively reduces the bitrate at the expense of image quality.
On the contrary, a small 1 τ provides better image quality, but requires more bitrate. This result is expected because a small 1 τ increases the number of complex blocks and, therefore, the bitrate, however, the image quality also increases.   Tables 4 and 5 show the PSNR and bitrate for all of the test images under various τ 1 with block size 4 × 4 and 8 × 8, respectively. In this experiment, τ 0 = 4, γ = 64, and k = 256 are set. We also list the PSNR and bitrate of the standard AMBTC method as a comparison. Note that the bitrates of the AMBTC with block size 4 × 4 and 8 × 8 are 2.0 and 1.25 bpp, respectively.
As seen in Tables 4 and 5, the PSNR of block size 8 × 8 is lower than that of block size 4 × 4. For example, when τ 1 = 16, the PSNR of the Lena image of block sizes 4 × 4 and 8 × 8 are 34.73 and 31.91 dB, respectively. However, the former requires 1.68 − 1.02 = 0.66 more bits per pixel than the latter. In addition, the experiments also reveal the fact that a large τ 1 effectively reduces the bitrate at the expense of image quality. On the contrary, a small τ 1 provides better image quality, but requires more bitrate. This result is expected because a small τ 1 increases the number of complex blocks and, therefore, the bitrate, however, the image quality also increases.  Figure 7 shows the bitrate-PSNR curves of each of the eight test images by varying the threshold τ 1 from 8 to 64. The figure shows that for all of the test images, the PSNR increases as the bitrate increases. Moreover, the figure also reveals that smooth images, such as Tiffany or Jet, have a better compression efficiency than those of complex images, such as Stream or Baboon. The reason is that a smooth block not only requires less bits to record its compressed code but also provides better reconstructed quality. Because the smooth images naturally possess more smooth blocks than complex blocks, their bitrate-PSNR curves are higher than those of complex ones.

Comparisons with Xiang et al.'s Work
Xiang et al.'s method [16] also improves the AMBTC method by dynamically splitting images into multiple groups and achieves a good performance. In this section, we compare the proposed method with that of Xiang  It also can be seen from Figure 7 that the PSNR and bitrate vary as the threshold τ 1 changes. A larger τ 1 gives a lower bitrate with lower PSNR. In contrast, a smaller τ 1 offers a higher image quality, but the bitrate is also higher. Therefore, the selection of threshold τ 1 depends on real applications. For example, if an application requires higher image quantity, a smaller τ 1 is required.
It is worth noting that, for most of the test images, the proposed method provides better performance than AMBTC, particularly for smooth images. For example, Lena, Jet, Tiffany, Boat, and Peppers are considered to be smooth. For these smooth images, regardless of the value of τ 1 , the PSNR is always higher and the bitrate is always lower than those of the AMBTC method. In contrast, for the complex images such as Baboon or Stream, few blocks are classified as flat, which require only 8 bits to record them. Therefore, the reduction in bitrate is limited. Nevertheless, the proposed method either provides a better image quality or lower bitrate than those of AMBTC.

Comparisons with Xiang et al.'s Work
Xiang et al.'s method [16] also improves the AMBTC method by dynamically splitting images into multiple groups and achieves a good performance. In this section, we compare the proposed method with that of Xiang Table 6. Table 7 shows the same experimental results, except block size is 8 × 8 and d min = 28, 32, and 36. The settings of d min in Xiang et al.'s method ensure that best performance can be achieved.  = 0.12 dB higher than the proposed method. The reason is that under these settings, more blocks are divided into four groups and thus a better image quality is achieved. However, their method requires 3.57 − 3.12 = 0.45 bpp more than the proposed method. In the performance comparisons with block size 8 × 8, the proposed method shows better results for all test images. For example, as shown in Table 7 when τ 1 = 14 and d min = 28, the PSNR of the Baboon image of the proposed method is 28.84 dB at 1.88 bpp. The PSNR is 28.84 − 28.14 = 0.70 dB higher and the bitrate is 2.23 − 1.88 = 0.35 bpp lower than those of Xiang et al.'s method.
Figure 8a-f shows the visual quality comparisons of the AMBTC, Xiang et al.'s, and the proposed methods. As seen from Figure 8a when the block size is 4 × 4 and the AMBTC method is applied, apparent distortions can be seen in the image edges, and noticeable boundary artifacts are observed (see Figure 8a). Note that the PSNR of the AMBTC is 33.27 dB with 2.0 bpp. Xiang et al. improve the AMBTC method by adding more details to complex blocks. As a result, the PSNR (36.31 dB) is significantly higher and blocks at the edges look more natural than those of AMBTC (Figure 8c, d min = 6). However, their method requires 2.35 − 2 = 0.35 bpp more to achieve this effect. In contrast, the visual quality of the proposed method (Figure 8e, τ 1 = 8) is comparable with that of Xiang et al.'s method, but the bitrate is 2.35 − 2.05 = 0.30 bpp lower with a slightly higher PSNR.
When the block size is 8 × 8, the distortion of AMBTC is more apparent (Figure 8b) than that of 4 × 4, but the bitrate reduces from 2.0 to 1.25 bpp. The visual quality of Xiang et al.'s method (Figure 8d, d min = 28) is significantly better than that of AMBTC, and has no noticeable block boundary artifacts. However, their method requires 1.64 − 1.25 = 0.39 bpp more to improve the image quality. In addition, some edges in Lena's face, eyes, and shoulder exhibit apparent distortions because the pixel splitting operation may not be triggered due to the setting of d min . In contrast, the edges of the proposed method exhibit no apparent distortion (see Figure 8f, τ 1 = 14). Moreover, the bitrate required in the proposed method is even lower than that of AMBTC by 1.25 − 1.09 = 0.16 bpp.
When the block size is 8 8 × , the distortion of AMBTC is more apparent (Figure 8b) than that of 4 4 × , but the bitrate reduces from 2.0 to 1.25 bpp. The visual quality of Xiang et al.'s method (Figure 8d, min 28 d = ) is significantly better than that of AMBTC, and has no noticeable block boundary artifacts. However, their method requires 1.64 1.25 0.39 − = bpp more to improve the image quality. In addition, some edges in Lena's face, eyes, and shoulder exhibit apparent distortions because the pixel splitting operation may not be triggered due to the setting of min d . In contrast, the edges of the proposed method exhibit no apparent distortion (see Figure 8f, 1 14 τ = ). Moreover, the bitrate required in the proposed method is even lower than that of AMBTC by

Conclusions
In this paper, we propose a hybrid encoding scheme for AMBTC compressed images using a ternary representation technique. Considering that the number of quantized values greatly affects the quality of the reconstructed image, the proposed method classifies image blocks into flat, smooth, and complex. These three types of blocks are encoded by using one, two, or three quantized values. Flat blocks require no bitmap, whereas smooth and complex blocks require binary and ternary maps, respectively, to record the quantized values to be used to reconstruct the corresponding pixels. A sophisticated design indicator is prepended before the code stream of a block to signify the block type. The proposed method achieves a better image quality than that of prior works with a smaller bitrate. The effectiveness of the proposed method is observed from the experimental results. Note that although the k-means algorithm used in the proposed method may require slightly higher computational cost than that of the discrete cosine transform (DCT) based methods, it is only applied to smooth blocks in the encoding stage to obtain the representative bitmaps rather than the whole image. Furthermore, the k-means algorithm does not need to be applied again during decoding. Therefore, the overall computational cost of the proposed method is smaller than that of DCT-based compression methods.