## 3 Method
### Light Compensation
#### 3.1.2 An Illumination Compensation Mechanism Based on Luminance Adjustment and Gamma Correction  
In order to prevent the low accuracy of reflective region recognition due to illumination, an illumination compensation mechanism based on brightness adjustment and gamma correction is proposed in this paper. In this method, the video obtained by the black box camera is processed in frames. And the video frame image sequence \(F=\{F_{1},F_{2},\ldots,F_{n}\}\) is taken as the input image \(I(x,y)\). The image \(I(x,y)\) is converted from RGB space to YUV space by the spatial conversion method, and the Y component \(B_{m}(x,y)\) in YUV space is extracted. \(B_{w}(x,y)\) can be obtained when Equation (4) is calculated. \(k_{1}\), \(k_{2}\), and \(k_{3}\) are the proportions of R, G, and B channels in the RGB image, respectively. \[B_{w}(x,y)=k_{1}\times I_{R}(x,y)+k_{2}\times I_{G}(x,y)+k_{3}\times I_{B}(x,y) \tag{4}\]  
\[\overline{B}_{w}=e^{\frac{[\frac{1}{\Gamma\cos\frac{\gamma}{x}},y]}{\Gamma \cos\frac{\gamma}{x}\log(\varphi+B_{w}(x,y))]}} \tag{5}\]  
where \(l\) and \(m\) are the number of rows and columns of the respective images. \(\varphi\) is the adjustment factor used to avoid pixel singularities in the images. \(B_{w}(x,y)\) is the image adjustment luminance function of the logarithmic mean luminance, \(\overline{B}_{w}\), in order to obtain the global and local features of the image. The normalized luminance \(B_{g}(x,y)\) can be expressed with Equations (6) and (7). The original image, \(I(x,y)\), can be adjusted for regional luminance to obtain the processed image \(I^{\prime}(x,y)\). \[B_{g}(x,y)=\frac{\log(B_{w}(x,y)/\overline{B}_{w}+1)}{\log(B_{w}\text{max}/ \overline{B}_{w}+1)\times[k_{1}\times I_{R}(x,y)+k_{2}\times I_{G}(x,y)+k_{3} \times I_{B}(x,y)]} \tag{6}\]  
\[ \begin{cases}Ir_{R}(x,y)=B_{g}(x,y)\times I_{R}(x,y)\\ Ir_{G}(x,y)=B_{g}(x,y)\times I_{G}(x,y)\\ Ir_{B}(x,y)=B_{g}(x,y)\times I_{B}(x,y)\end{cases}  \tag{7}\]  
An accurate light compensation of the reflective region cannot be fully realized by luminance adjustment only. The gamma correction of the image curve is also needed to discriminate the dark and light region parts of the image by means of the nonlinear tone editing of the image to improve the contrast effect of the two parts, thus providing a better detection environment for the reflective region identification operation. Firstly, the image \(I(x,y)\) is converted from RGB space to HSV space. The transformed color space H, S, and V channels satisfy Equation (8). Equation (8) is the expression of the multi-scale Gaussian function \(Q(x,y)\). \[Q(x,y)=\frac{1}{N}\times e^{-\frac{x^{2}+y^{2}}{2^{2}}} \tag{8}\]  
The luminance estimate \(B_{0}(x,y)\) of the original image is obtained through convolution calculation as shown in Equation (9). \[B_{0}(x,y)=Q(x,y)\times I^{\prime}{}_{V}(x,y)=\frac{1}{N}\times I^{\prime}{}_ {V}(x,y)\times e^{-\frac{x^{2}+y^{2}}{2^{2}}} \tag{9}\]  
In order to obtain the global and local features of the image, this paper uses a Gaussian function to simulate the influence of various luminance components on the image. Weuse different weights \(\delta_{i}\) to analyze the influencing factors of luminance and to obtain the luminance estimate of the image \(B_{0}(x,y)\). \[B_{0}(x,y)=\delta_{i}\times Q(x,y)=\sum_{i=1}^{n}\delta_{i}\times[\frac{1}{N} \times e^{-\frac{x^{2}+y^{2}}{x^{2}}}\times I^{\prime}{}_{V}(x,y)] \tag{10}\]  
where \(a\) is the scale factor, \(\frac{1}{N}\) is the normalization constant, and \(\delta_{i}\) is the weight of each luminance component. The corresponding convolution kernel range is set according to the scale factor \(a\) of different sizes. \(a\) is proportional to the convolution kernel range. The larger the value of scale factor \(a\), the better the global feature of the detected image brightness value. \(I_{V}(x,y)\) is the V-component value of the input image in YUV space.