## 2 Theoretical Foundations of Algorithms
### Retinex Model Analysis  
Retinex [10] is an image enhancement algorithm, which is often used on an experimental and analytical basis. The principle is that the colour of an object is determined by the reflectance of the object for long-, medium-, and short-wave light, so the algorithm can achieve good results in three aspects--edge enhancement, dynamic compression, and colour constancy--and can perform adaptive enhancement for different types of images. The primary expression for the Retinex model is shown in Equation (5):  
\[S(x,y)=L(x,y)\bullet R(x,y) \tag{5}\]  
where \(S(x,y)\) represents the original image, which is decomposed into an illuminance component and a reflection component; the \(L(x,y)\) component expresses the smoothed information of the input image; and the \(R(x,y)\) component expresses the original properties of the original image. Therefore, the key to using the Retinex model is to evaluate the illuminance component and calculate the reflection component \(R\) from \(L\).  
The single-scale Retinex algorithm (SSR) uses a logarithmic model when evaluating the reflectance component. The image is filtered using a centre surround function to approximate the illumination component, with the best centre surround function being a Gaussian kernel function [18].  
The single-scale Retinex algorithm better maintains the image's brightness, reducing the loss of image detail caused by noise while improving information capture in dark areas. If the image being processed contains a large number of similar grey scale areas, the halo's edges will blur.  
The multi-scale Retinex algorithm (MSR) adds multiple scales to the SSR, which is universally divided into three scales, with the scale features still represented by \(\sigma\). Its calculation is shown in Equations (6)-(8):  
\[L_{i}(x,y)=S_{i}(x,y)\ast G_{i}(x,y) \tag{6}\]  
\[G_{i}(x,y)=\frac{1}{2\pi\sigma_{i}^{2}}e^{-\left(\frac{x^{2}+y^{2}}{2\sigma_{ i}^{2}}\right)} \tag{7}\]  
\[R_{MSR}(x,y)=\sum_{i=1}^{n}\omega_{i}R_{SSRi}=\sum_{i=1}^{n}\omega_{i}[\log S_ {i}(x,y)-\log L_{i}(x,y)] \tag{8}\]The value of \(i\) can be taken as 1, 2 or 3, with \(i=1\) for low scale, \(i=2\) for medium scale, and \(i=3\) for large scale; \(\omega_{i}\) is the weighting factor of the i-th scale when weighting is performed.  
During the enhancement process of the MSR algorithm, the image may be distorted by the addition of noise, which distorts the colour of local details of the image and does not reveal the object's true colour, making the overall visual effect worse.  
To address this deficiency, the multi-scale Retinex algorithm with colour recovery factor (MSRCR) [19] adds a colour recovery factor C to MSR to adjust the defects of colour distortion due to enhanced contrast in local areas of the image. The MSRCR algorithm uses the colour recovery factor C to adjust the proportional relationship between the three colour channels in the original image, thus bringing out the information in relatively darker areas and eliminating the defects of colour distortion in the image.  
To date, MSR and MSRCR algorithms have commonly been used to solve filter-dependent problems, and they can effectively improve image contrast without relying on many filters, but they also increase the number of halo artefacts in the image, which is a significant drawback.