# Adaptive Neural-Network-Based Lossless Image Coder with Preprocessed Input Data
## 4 The Coder Structure  
Many modern lossless coding algorithms have cascade organization; the main predictor (here, an AdNN) is followed by a single stage or by several stages of NLMS (Normalized Least Mean Square) filters; see Figure 4. Image pixels are coded independently row after row from the top down, and from left to right. Then, computed according to (2), AdNN errors \(e_{AdNN}(0)\) are processed by NLMS stages, followed by the prediction bias cancellation procedure in the \(C_{mix}\) block; see Figure 4. The most advanced update formulas for NLMS coefficients used here, and for \(C_{mix}\) definition, can be found in [12]. Two NLMS sub-stages of rank \(r_{NLMS1}=106\) and \(r_{NLMS2}=42\) are implemented. This is the data modeling part of the code; it is followed by an advanced adaptive context arithmetic coder, which is fully described in [12].  
The authors of the CALIC algorithm discovered that predictors tend to accumulate biases, which superimpose on their estimates. As a consequence, both CALIC and JPEG-LS include a stage of prediction bias cancellation. The cancellation procedure is a context one; the context is defined by the coded pixel neighborhood. For each context, the accumulated error is calculated and the prediction error corrected; see [1,4]. In [46], it was discovered that the single predictor bias cancellation formula can be unreliable. Following this observation, in our techniques the weighted sum of outputs from several bias canceling methods is computed: \(C_{mix}\) in Figure 4. The definition of the most advanced 12-element one can be found in [12].  
The following algorithms describe the cascade coder and decoder operation, Algorithm 1 and Algorithm 2, respectively:  
```
For each coded pixel \(x_{(n)}\):
1. Launch the AdNN learning process using data from training window \(Q\); Figure 3.
2. Compute pixel prediction error \(\epsilon_{(n)}\) (2) using the cascade of operations shown in Figure 4: AdNN prediction \(\epsilon_{AdNN}(0)\) is improved by NLMS+ correction; finally, the prediction bias is removed in the \(C_{mix}\) block.
3. Calculate a binary prediction error representation using the Golomb coder [12].
4. Perform final coding using the adaptive context arithmetic coder [12].
```  
**Algorithm 1** Coder operation  
For each coded pixel \(x_{(n)}\):  
1. Compute its binary representation, knowing how the adaptive context arithmetic decoder works.
2. Convert it to a number using the Golomb decoder.
3. Launch the AdNN learning process using already decoded pixels from training window \(Q\); Figure 3.
4. Compute pixel prediction value \(\hat{x}_{(n)}\) (2) using the cascade of operations shown in Figure 4: AdNN prediction is improved by NLMS+ correction; finally, prediction bias is removed in the \(C_{mix}\) block.
5. Calculate the pixel \(x_{(n)}\) value from (2).  
The relatively high computational complexity of the AdNN block in Figure 4 is caused by the fact that AdNN learning is performed for each coded pixel. The learning data are taken from the window shown in Figure 3, and then processed as described in Sections 3 and 5.