## 2 Materials and Methods
### Variant Genetic Algorithm (VGA)  
The accuracy of the grayscale image as a guidance image affects the transmittance optimization. In this paper, a variant genetic algorithm (VGA) is used to obtain the transfer function. The role of the transfer function is to map the original image to its corresponding high-contrast image. The guidance image \(R_{g}(x)\) for guided filtering is thus obtained. The scheme of the VGA is shown in Figure 3.  
The illumination components from Retinex are firstly converted into grayscale image, which will be used as the guidance image. VGA is used to update the transfer function by varying the parameter set. The feedback function will also be updated every turn for the  
Figure 3: Transfer function optimization based on VGA. Figure 2: Estimation of atmospheric light intensity \(A_{i}\). subsequent update of the transfer function. The fitness function is used to verify the quality of the current transfer function. A new parameter set is generated through crossover and mutation to obtain a new transfer function. The low-contrast image (pixel values range from \(I_{in\_min}\) to \(I_{in\_max}\)) is converted into a high-contrast image (0\(\sim\)255) by mapping the transfer function. The generated transfer function should remain monotonically increasing. All the points less than \(I_{in\_min}\) are set to 0, and the points greater than \(I_{in\_max}\) are set to 255. The generation of  
\[\left\{ \begin{array}{l}STD=\sqrt{\frac{1}{mn}\sum\limits_{i=0}^{m-1}\sum\limits_{j= 0}^{n-0}[R_{g}(i,j)-\overline{R}_{g}]^{2}}\\ ENTROPY=-\sum\limits_{i=0}^{255}p_{i}\cdot\log_{2}p_{i}\end{array} \right. \tag{9}\]  
where \(\overline{R}_{g}\) is the average value of \(R_{g}\) for pixels. \(P_{i}\) refers to the number of pixels whose gray value is \(i\) in the image. Additionally, \(SOBEL\) is the average intensity of the grayscale image obtained by applying the vertical and horizontal Sobel operators, respectively [36]. \(SOBEL\) is defined as:  
\[SOBEL=\text{mean}(|sobel_{v}|+|sobel_{h}|) \tag{10}\]  
where \(sobel_{v}\) and \(sobel_{h}\) are the images obtained by applying the vertical and horizontal Sobel operators, respectively. The mean(.) operator denotes averaging. In VGA, the reproduction stage is carried out by crossover and mutation. The population size is set to 20. The reproduction transfers the parent parameter set (i.e., \(\alpha\), \(\beta\), \(\gamma\), \(C_{up}\) and \(C_{right}\)) into a sequence by binary code (also called chromosomes). This paper adopts a uniform crossing method with a probability of 85%. Mutations change the code for perturbations with a probability of 0.05. In this algorithm, the mutation only changes one of the 5 parameters in the set and is limited to 10% of the original values. VGA controls the generation process of the transfer function. In the initial stage, VGA needs crossovers and mutations in each iteration to achieve fast optimization. However, in the subsequent iterations, the numbers of crossover and mutation need to be reduced. Through the experiment, it is most appropriate to set the number of VGA iterations to 10, considering the final effect and processing speed. At the same time, GA participated in iterations 1, 2, 4, 6, and 9. After the transfer function is obtained, the grayscale image of \(R(x)\) can be enhanced to obtain the guidance image \(R_{g}(x)\), and guided filtering can be used to optimize \(t(x)\). The problem of image color distortion is often caused by inaccurate estimation of \(t(x)\)[37]. In this paper, the tolerance \(K\) is divided by the difference between the pixel value \(R_{i}(x)\) and the atmospheric light intensity \(A_{i}\) to further ensure that the color of the restoration result is not distorted:  
\[J_{i}(x)=\frac{I(x)-A_{i}}{\min(1,t(x)*\max(K/\left|R_{i}(x)-A_{i}\right|,\,1) )}+A_{i}\;i=R,G,B \tag{11}\]  
The tolerance \(K\) is a constant whose value is between 0 and 1. \(R_{i}(x)\) and \(A_{i}\) are normalized values; \(K/\left|R_{i}(x)-A_{i}\right|\) is used to multiply the transmittance \(t(x)\) to amplify \(t(x)\).