# Design of OCC Indoor Positioning System Based on Flat Panel Light and Angle Sensor Assistance
## 3 Fuzzy Positioning
### Image Optimization  
After pre-processing, the image can still be affected by complex factors such as ambient lighting and reflective objects, which can destroy the true information of the image, affect the visual effect of the image, and hinder the recognition decoding of the image. Therefore, it is necessary to perform further image optimization processing after the image has been preprocessed. Classical lighting compensation algorithms include the top hat method [17]. In this paper, the adaptive illumination compensation algorithm is used to correct the illumination unevenness of the image [18]. Illumination compensation is essentially an unequal stretching of the image grayscale values to extract the images with uneven illumination and remove the effects of uneven illumination using image subtraction operations. In this paper, we use the method of extracting the image background gray level in a region using mathematical statistics, calculating the standard deviation and mean value of the pixel gray level in the region, and calculating the gray level of the background in the region based on the statistical value. The specific process is as follows:1. The image is segmented into m \(\times\) n small regions, the background gray value of each region is estimated, and the standard deviation \(\sigma\) and mean \(\mu\) of the pixel gray level of the region are calculated; max(v\({}_{\rm min}\), \(\mu-3\sigma\)) is taken as the gray level of the region, and v\({}_{\rm min}\) is the minimum gray level of the region;
2. max(v\({}_{\rm min}\), \(\mu-3\sigma\)) is expanded into a matrix of regional background gray values of the same size for that region; the same is done for each region, and the matrices are merged;
3. The original image matrix is subtracted from the background grayscale matrix, i.e., a new image matrix is generated to complete the image adaptive illumination compensation once.  
After luminance correction by the illumination compensation algorithm, there is a significant brightness bias in the image, and the histogram equalization technique can be used to maintain the brightness characteristics of the image while enhancing the local details and optimizing the uneven distribution of pixel gray levels. Histogram equalization is a simple and effective image enhancement technique [19,20], which changes the gray level of each pixel in an image by changing the histogram of the image, and is mainly used to enhance the contrast of images with a small dynamic range. The basic principle of histogram equalization is that the grayscale values with a large number of pixels in the image (i.e., those that play a major role in the image) are widened, while those with a small number of pixels (i.e., those that do not play a major role in the image) are merged, thus increasing the contrast and making the image clear for the purpose of enhancement.  
The mathematical process can be expressed by the following Equation (8).  
\[S_{k}\ =\ \sum_{i\ =\ 0}^{k}P(r_{i})\ =\ \sum_{i\ =\ 0}^{k}\frac{n_{i}}{n} \tag{6}\]  
where r\({}_{\rm k}\) is the kth gray level in the original image; s\({}_{\rm k}\) is the kth gray level in the output image, n is the total number of pixels in the image, n\({}_{\rm i}\) is the number of pixels in the image with gray level r\({}_{\rm i}\), and k \(\in[0,\) L \(-\) 1].