## Appendix B  
The image receiver uses a dedicated script for data extraction and collection from the frames. The same parameters for the preamble and lengths of a frame from Table A1 are used. FIR matched filter is used for the detection of PN preamble at the beginning of each frame. The synchronized frame from the receiver script's output is used as an input for the image reconstruction script. To receive and reconstruct an image, the transmitter's and receiver's protocol parameters for header and payload parts must be equal. ```
Data:\(psn[4]\): previous sequence numbers, \(sn\): current sequence number Result:\(snl\): sequence number lock, \(sn\_ce\): sequence number count enable for\(i\gets 4\) to \(2\) by \(-1\)do \(psn(i)\gets psn(i-1)\); // Shift previous sequence numbers end \(psn(1)\gets sn\); // Save current sequence number if\(psn(4)+1=psn(3)\)and\(psn(3)+1=psn(2)\)and\(psn(2)+1=psn(1)\)then \(snl\gets psn(1)\); // Set lock to the current sequence number \(sn\_ce\gets 1\); // Set sequence number count enable high end if\(sn\_ce=1\)then \(snl\gets snl+1\); // Increment sequence number lock  end
```  
**Algorithm A1**Frame sequence number lock algorithm  
Figure A1: Creation of data bits from the image where \(n\) is image pixel row length, \(m\) is image pixel column length, and \(i\) is frame or image column number. (**a**) Image matrix with decimal values. (**b**) Image matrix reshaped into column vector with decimal values. (**c**) Matrix of each image pixel (matrix row) and its binary value in matrix columns. (**d**) Data row containing the image in bits where black lines show a start of an image pixel column. ```
Data:\(\mathit{rsn}\): received sequence number, \(\mathit{snl}\): sequence number lock, \(\mathit{sn\_ce}\): sequence number count enable Result:\(\mathit{valid}\): frame validity \(\mathit{valid}\gets 1\); if\(\mathit{rsn}<1\)or\(\mathit{rsn}>100\)then if\(\mathit{sn\_ce}=1\)then \(\mathit{rsn}\leftarrow\mathit{snl}\); // Received frame is after previous frame else \(\mathit{valid}\gets 0\); // Received frame is not valid  end if  end for
```  
**Algorithm A2**Frame validity and out of bounds check  
```
Data:\(\mathit{valid}\): frame validity, \(\mathit{snl}\): sequence number lock, \(\mathit{sns}[100]\): sequence number storage, \(\mathit{rsn}\): received sequence number, \(\mathit{rx}\): received frame Result:\(\mathit{image}\): reconstructed image \(\mathit{b\_l}\gets 8\); // Binary length of a pixel header\(\_l\gets 76\); // Header length data\(\_l\gets 800\); // Data length \(\mathit{column}(1\) to \(100)\gets 0\); if\(\mathit{valid}=1\)and\(\mathit{snl}\geq 100\)and\(\mathit{sns}(\mathit{rsn})=0\)then \(\mathit{data}\leftarrow\mathit{rx}(\mathit{header\_l}+1\)to\(\mathit{header\_l}+\mathit{data\_l})\); for\(i\gets 1\)to\(100\)by\(1\)do \(\mathit{b\_data}\leftarrow\mathit{data}((i-1)*\mathit{b\_l}+1\)to\(i*\mathit{b\_l})\); \(\mathit{column}(i)\leftarrow(\mathit{decimal})\mathit{b\_data}^{\prime}\); // Convert pixel from binary to decimal format  end for\(\mathit{sns}(\mathit{rsn})\gets 1\); \(\mathit{image}(1\)to\(100,\mathit{sn})\leftarrow\mathit{column}\); // Add column to an image  end for
```  
**Algorithm A3**Image column reconstruction  
If header, payload and padding lengths are recovered with errors, these lengths are set to default values. After the conversion of header values, the validity of a received frame is checked. It is carried out by comparing the current received frame's sequence number and 3 previous sequence numbers which are described in Algorithm A1. If the frame is valid, the lock enable signal is set high and the next sequence number is locked. Lock enable signal is used in the case when the received frame's sequence number is out of bounds of acceptable sequence numbers, which is \(<\)1 and \(>\)100, which corresponds with the used image's width in pixels. When such a frame is received, and the lock enable signal is high, the received frame is assumed to be with a sequence number of a locked sequence number.