## 3 Realization of Proposed QCD-OCC System
### Implementation of Proposed QCD-OCC Receiver Simulation  
The steps involved in receiver simulation are shown in Figure 6. The process starts with accessing the folder containing images generated by the Tx simulator. Each image is processed sequentially as per the naming convention. Since in a practical system, packet drop is probable due to frame sampling errors, a simulation of this error resulting in the skipping of the image (\(S(i)\)) is implemented as follows:  
\[S(i)= \begin{cases}i,&ifP<1-(F_{r}/48/3/D_{r})\\ 0\end{cases}  \tag{12}\]  
where \(i\) is an image from the folder, \(F_{r}\) is the frame rate of the camera, and \(D_{r}\) is the transmitter data rate. The probability of a packet drop for the selected image decreases with an increase in the camera frame rate and/or decrease in transmitter data rate. The selected image undergoes noise removal using a Wiener filter. The extraction of the RoI from the first image is a sequence of preprocessing steps. The input colored image is converted into grayscale (\(Gr\)) as per Equation (13), where \(x\) and \(y\) are the rows and columns of pixels in the image, and \(R\), \(G\), and \(B\) are color channels. \[Gr_{x,y}=0.299*R_{x,y}+0.587*G_{x,y}+0.114*B_{x,y} \tag{13}\]  
A threshold (\(T\)) for binarization is estimated as per Equation (14), where the maximal grayscale pixel intensity is used as the threshold. Equation (15) provides a binarized image (\(B\)):  
\[T=max_{x}(max_{y}(Gr_{x,y})) \tag{14}\]  
\[B_{x,y}=Gr_{x,y}<T-1 \tag{15}\]  
A square structural element (\(strel\)) of size \(n\), as given in Equation (16), is used to dilate the binarized image. Equation (17) provides a dilated binary image. \[strel_{n}= \begin{bmatrix}1_{1,1}&..&..&1_{n,n}\\..&..&..&..\\..&..&..&..\\ 1_{n,1}&..&..&1_{n,n}\end{bmatrix}  \tag{16}\]  
Figure 6: Block diagram of the proposed QCD-OCC receiver simulator. \[B_{i,j}\oplus strel=\left\{z|(\hat{strel}_{z}\cap B_{i,j}^{c}\
eq\phi)\right\} \tag{17}\]  
Out of the \(n\) blobs from the dilated image, the blob with the maximal area (\(BM\)) was selected as per Equation (18), where \(BA_{n}\) is the area of blob \(n\). \[BM=max(BA_{n}) \tag{18}\]  
The coordinates of \(BM\) are extracted from each channel to provide an RoI as shown in Equation (19), where \(p_{x,y}\) is the pixel at positions \(x\) and \(y\). \[RoI=\left\{p_{x,y}|(R_{x,y}\cap BM_{x,y})+(G_{x,y}\cap BM_{x,y})+(B_{x,y}\cap BM _{x,y})\right\} \tag{19}\]  
The coordinates of the extracted RoI are applied to all subsequent images to crop the Tx. It was assumed that subsequent images had the same Tx position and magnification in the image as those of the first reference image. A square bounding box was drawn around the Tx. The area of the bounding box was compared with the area of the blob in RoI, and RoI rotation was performed to align the RoI with the bounding box. A Hough transform was applied to identify the angle (\(\theta\)) by which Tx was rotated, and a rotation of Tx in the opposite direction was performed. Thus, the aligned Tx (\(A_{i}^{Tx}\)) from the cropped RoI of the \(i\)th image can be expressed as shown in Equation (20), where \(H_{T}\) is the Hough transform. \[A_{i}^{Tx}=rotate(RoI_{i},-(H_{T}(RoI_{i}))) \tag{20}\]  
The aligned RoI of Tx was further quantized into 3-bit color, and a reshaping function was applied to convert the resultant image into an 8 \(\times\) 8 \(\times\) 3 matrix. The values from anchoring positions were extracted and compared with the expected values. A counter-clockwise matrix rotation was performed till all anchor values matched or four iterations were over. The rotated matrix (\(O\)) could be expressed as shown in Equation (21) where \(T_{r}\) is a transpose operation, and \(C_{r}\) is a column-reverse operation. \[O_{8\times\ 8}^{Rx}=C_{r}(T_{r}(A_{8\times\ 8})) \tag{21}\]  
Each cell in the resultant matrix \(O_{8\times\ 8}^{Rx}\) consisted of RGB values.