# On the Utilization of Reversible Colour Transforms for Lossless 2-D Data Compression
## Appendix A The Arithmetic Coder  
The Huffman Coding trades a symbol with a particular code depending on the Huffman tree generated from the prior probabilities of the symbols in the message. On the other hand, the Arithmetic coding evades this idea by replacing a set of input symbols with a single floating point output number. The length of the message and its complexity leads to higher number of bits required for generating the output. The range of an arithmetic coding output, say x here, is a single number such that \(0\leq x<1\). x is uniquely decodable taking considering probabilities of the symbols.  
This interval keeps on reducing for lengthier messages which in turn leads to the utilization of a higher numbers of bits to represent the range. The process continues for the subsequent symbols and frequently occurring symbols narrow the range lesser as compared to less frequent symbols.  
Figure 11 shows the encoding example for the Arithmetic encoder for better comprehension. The example of a fixed model arithmetic code from the works of [PERSON] et al. [59], is presented below.  
Let suppose we have a set of alphabets i.e., [a,e,i,o,u,!] where! is used as end of message indicator. The probabilities of these alphabets are given in Table 11. Now, a message \"ea  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Symbol** & **Probability** & **Range** \\ \hline a & 0.2 & [0.0, 0.2) \\ e & 0.3 & [0.2, 0.5) \\ i & 0.1 & [0.5, 0.6) \\ o & 0.2 & [0.6, 0.8) \\ u & 0.1 & [0.8, 0.9) \\! & 0.1 & [0.9, 1.0) \\ \hline \hline \end{tabular}
\end{table}
Table 11: Symbols probabilities and ranges for fixed model Arithmetic coder example.  
The alphabet \"e\" is the first symbol to be encoded as it has the highest probability. The first symbol is the important part of the arithmetic encoder as it defines the highest interval which will be subsequently narrowed. As seen in Figure A1, in the first step, the message is arranged on the vertical probability interval. The range of \"e\" starts from 0.2 and ends at 0.5. The second alphabet in the message is \"a\". The range of e [0.2,0.5) needs to be narrowed. The equations below let us calculate that new range.  
\[range=upper\_bound-lower\_bound \tag{1}\]  
Range of a \"symbol\" is calculated then as  
\[lower\_limit:lower\_limit+range*\text{``symbol''\_probability} \tag{2}\]  
So, for \"a\" the overall range is \(0.5-0.2=0.3\). The new range for symbol \"a\" is calculated as \(0.2:0.2+0.3\times 0.2\) giving us \([0.2,0.26]\)  
Similarly, the ranges for all the symbols are calculated as shown in Table A1.  
Now, let's see how we can decode a message for the Arithmetic coder. Say the decoder only has the information about the last range of the message i.e., [0.23354, 0.2336). This range according to the probability given in Table A2 shows the first character has to be \"e\". Once the first character is decoded it imitates the probability ranges for the rest of the symbols.  
Initially the range was [0, 1) and after seeing \"e\" it became [0.2, 0.5). From here, as per the probabilities, the range is narrowed for symbol \"a\" giving us [0.2, 0.26). The process is repeated till all the symbols ranges are generated at the decoder end. Then from the last range, in the reverse order, the message is identified.