# Design of OCC Indoor Positioning System Based on Flat Panel Light and Angle Sensor Assistance
## 3 Fuzzy Positioning
### Image Pre-Processing  
Because it is convenient to make a frosted barcode, this paper uses the approach of hollowing out during fabrication, so the black and white barcode of the frosted barcode is opposite to the normal barcode, the black part is cut off to transmit light so that it becomes the white part. Moreover, in order to ensure the normal use of the flat panel light, the image acquisition is relatively low in clarity and contrast, so the image must be pre-processed to facilitate the subsequent identification and decoding work. There is inevitably a lot of useless information in the captured image, and the target region extraction is to find the region of interest (ROI), which in this system is the region of the flat panel light. After extracting the barcode region, the image to be processed can be narrowed down and the interference of background noise, such as ambient light source and luminescence, can be reduced in the subsequent image processing. The specific algorithm process is to segment the flat panel light and the environment by image threshold segmentation, and then select the barcode region in the image by the connected domain feature. The classical otsu algorithm is to select a gray level such that \(\sigma_{B}^{2}\) is the maximum value by traversing the gray level range \(\mathfrak{t}\in[0,\,\mathrm{M}-1]\), and that gray level \(\mathfrak{t}\) is the best image segmentation threshold. \(\sigma_{T}^{2}\) is the image feature factor, which is independent of the selection of gray level \(\mathfrak{t}\); \(\sigma_{W}^{2}\) is the class variance, which is a second-order statistical value; \(\sigma_{B}^{2}\) is the class mean, which is a first-order statistical value. In order to obtain the optimal image segmentation threshold, a gray level \(\mathfrak{t}\) needs to be selected such that the values of \(\lambda\) and \(\eta\) are maximized [13; 14]. \[\sigma_{B}^{2}\ =\ \omega_{0}\omega_{1}(\mu_{0}-\mu_{1})^{2}\ =\ w_{0}w_{1}\bigg{[}\frac{\mu_{(t)}}{w_{0}}- \frac{\mu_{T}-\mu_{(t)}}{1-w_{0}}\bigg{]}^{2}\ =\ \frac{[\mu_{T}w_{0}-\mu(t)]^{2}}{w_{0}w_{1}}\ =\ \frac{ \bigg{(}\sum_{j\ =\ 0}^{t}P_{j}\sum_{l\ =\ 0}^{M-1}P_{i}-\sum_{i\ =\ 0}^{t}P_{j}\bigg{)}^{2}}{\sum_{j\ =\ 0}^{t}P_{i}\big{(}1-\sum_{i\ =\ 0}^{t}P_{i}\big{)}} \tag{1}\]  
Figure 4: Flow chart of the fuzzy positioning process. The specific flow of the algorithm is as follows:  
1. Calculate the probability of gray level for each pixel;
2. Calculate the global mean and variance;
3. Calculate the average density value and the average intensity value of the pixel;
4. Calculate the inter-class variance and find the separable threshold Kstar;
5. Find the average intensity and separable metric of the whole image;
6. Convert the image into a binarized image based on Kstar. After the threshold segmentation of the acquired image, the connected domain with the largest area is the target area of the barcode, and all eight neighbors with less than 1000 pixels can be deleted to remove small objects for subsequent image processing. Due to the influencing factors, such as the angle and tilt of the LED lights taken by the user terminal, it is difficult to directly identify the barcode information in the image. In order to improve the efficiency of the subsequent image processing and the accuracy of the identification decoding, the image needs to be tilt-corrected first to make it rectangular. This system adopts the image correction algorithm based on the projection interpolation method of corner point recognition based on the projection method [15]. Assuming that the projection matrix M is  
\[M\ =\ \begin{bmatrix}a&b&c\\ d&\mathbf{e}&f\\ g&h&l\end{bmatrix}  \tag{2}\]  
Then, the transformation equation is  
\[x_{i}\ =\ \frac{ax_{i}+by_{i}+c}{gx_{i}+ly_{i}+l} \tag{3}\]  
\[Y_{i}\ =\ \frac{\mathrm{d}X_{i}+\mathrm{e}y_{i}+f}{gx_{i}+ny_{i}+l} \tag{4}\]  
{x,y} are the pixel coordinates of the original image, {X,Y} are the pixel coordinates of the corrected image, and i = {1,2,3,4} is the index of the corner points.