# Hybrid Encoding Scheme for AMBTC Compressed Images Using Ternary Representation Technique
## 2 Related Works
### [PERSON] et al.'s Method
### [PERSON] 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, [PERSON] 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. Let \(\{\Phi_{i}\}_{i=0}^{N-1}=\{a_{i},b_{i},B_{i}\}_{i=0}^{N-1}\) be the AMBTC compressed code of the original image \(I=\{I_{i}\}_{i=0}^{N-1}\). To determine the complexity of block \(I_{i}\), a threshold \(\tau_{0}\) is set. If \(b_{i}-a_{i}\leq\tau_{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 \(\left(m_{i}\right)_{2}\), which is the 8-bit binary representation of \(m_{i}\). If \(b_{i}-a_{i}>\tau_{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 codes \(\Phi^{0}_{i}=\{a^{0}_{i},b^{0}_{i},B^{0}_{i}\}\) and \(\Phi^{1}_{i}=\{a^{1}_{i},b^{1}_{i},B^{1}_{i}\}\). According to a given threshold \(d_{\text{min}}\), this method uses the following rules to determine whether \(G^{0}_{i}\) and \(G^{1}_{i}\) should be regrouped:  
Rule 1: If \(b^{0}_{i}-a^{0}_{i}>\tau_{0}\) and the total number of pixels in \(G^{0}_{i}\) is greater than \(d_{\text{min}}\). Rule 2: If \(b^{1}_{i}-a^{1}_{i}>\tau_{0}\) and the total number of pixels in \(G^{1}_{i}\) is greater than \(d_{\text{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. [PERSON] 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, [PERSON] 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}<\gamma\), where \(\gamma\) is a predefined threshold, \(d_{i}\) is recorded using \(\log_{2}(\gamma)\) bits. Otherwise, \(d_{i}\) is recorded using \(\lceil\log_{2}(\sigma)\rceil\) bits, where \(\sigma\) 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}<\gamma\), \(Y_{i}=0\) is set. Otherwise, \(Y_{i}=1\). The number of bits \(R_{i}\) used to record the difference can be expressed as:  
\[R_{i}= \begin{cases}\log_{2}(\gamma)+1,&d_{i}<\gamma;\\ \lceil\log_{2}(\sigma)\rceil+1,&d_{i}\geq\gamma.\end{cases}