## 3 Improvement of the Retinex Algorithm
### Improvement of the Luminance Component V  
#### 3.2.1 Fusion Algorithm  
The centre surround function used by the MSR algorithm and MSRCR algorithm is a Gaussian filter function [21] that considers that the spatial distance of pixels affects the points of the target pixel (the expression is shown in Equation (7)). The closer the points are to the central pixel, the stronger the connection; the further away the points are, the weaker the connection. \(\sigma\) is the scale function of the centre surround function and is equivalent to the standard deviation of the Gaussian function. \(\sigma\) remains constant throughout the Retinex image enhancement algorithm, and the value of \(\sigma\) strongly influences the final image enhancement. If the standard deviation \(\sigma\) is taken to be significant, the image contrast is poor, and if \(\sigma\) is taken to be minor, the image will show halos, leading to blurring and distortion, where \(\sigma\) is shown in Equation (7). This paper proposes replacing Gaussian filtering with bilateral filtering to solve the above problem. The illuminance component of the luminance component V is enhanced using the multi-scale Retinex algorithm with the colour recovery factor based on bilateral filtering with gamma correction for the incident component [22], and the reflection component of the luminance component V is enhanced using the histogram equalisation function for contrast pull-up as well as the image enhancement using the Laplace operator. The MSRCR algorithm is an excellent solution to the problem of the small dynamic range and rich colour of the MSR algorithm, and also has a considerable degree of recovery of image details. The related equations are shown in Equations (9)-(11):  
\[R_{MSCRi}(x,y)=C_{i}(x,y)R_{MSRi}(x,y) \tag{9}\]  
\[C_{i}(x,y)=\beta\bigg{\{}\log_{a}[\bullet I_{i}(x,y)]-\log_{a}\bigg{[}\sum_{i =1}^{N}I_{i}(x,y)\bigg{]}\bigg{\}} \tag{10}\]  
\[R_{MSR}(x,y)=\sum_{n=1}^{m}\lambda_{n}\big{\{}\log_{a}I(x,y)-\log_{a}[I(x,y) \cdot G_{n}(x,y)]\big{\}} \tag{11}\]  
The parameters are described below: \(R_{MSR}(x,y)\) denotes the recovered image of the \(i\)-th channel after using this algorithm; \(C_{i}(x,y)\) denotes the colour recovery factor of the \(i\)-th channel, which is used to adjust the scale of the three-channel colours; \(R_{MSR}(x,y)\) denotes the recovered image after multi-scale filtering for the colours of the \(i\)-th channel; \(\beta\) is the gain constant; \(\alpha\) is the controlled non-linear intensity, \(\lambda_{n}\) denotes the weight coefficient under the \(n\)-th scale, and \(n\) and \(m\) are different scales, \(n\)-\(m\), that is, the range of values of the scale. Figure 3: Network structure diagram. The bilateral filter function [23] was used as the central surround function instead of the Gaussian kernel function. The advantage of the bilateral filter function compared to the Gaussian kernel function is that the edge information is preserved and kept intact, and the distortion in the image enhancement process can be removed with better effect. The formula used for calculating the bilateral filter weight coefficients is shown in Equation (12):  
\[G(x,y)=\exp\left[-\frac{(x-x_{c})^{2}+(y-y_{c})^{2}}{2\sigma_{s} ^{2}}\right]\times\exp\left[-\frac{(f(x,y)-f(x_{c},y_{c}))^{2}}{2\sigma_{r}^{2 }}\right] \tag{12}\]  
where \((x_{c},y_{c})\) is the centroid position of the image; \(f(x_{c},y_{c})\) is the grey value of the pixel at the centroid of the image; \(\sigma_{s}\) is the standard deviation of the null Gaussian function, and \(\sigma_{r}\) is the standard deviation of the value Gaussian function.