## 3 Image-Enhancement-Related Algorithms
### Improved Adaptive Contrast Enhancement(IACE)  
Different from traditional global contrast enhancement algorithms, the adaptive contrast enhancement algorithm [19] adjusts the intensity of contrast enhancement based on local features. Combined with the adaptive contrast enhancement algorithm to improve the dynamic range utilization of the image, the local gray level information within each gradient level is corrected. Assuming \(x(r,c)\) is a pixel point in the image, the image window size is set to \((2n+1)*(2n+1)\) centered on \(x(r,c)\). The local mean and local variance within each gradient level are represented as follows:  
\[\mu_{x}(r,c)=\frac{1}{(2n+1)^{2}}{\sum_{k=r-n}^{r+n}}\sum_{d=c-n}^{c+n}x(k,l) \tag{8}\]  
\[\sigma_{x}^{2}(r,c)=\frac{1}{(2n+1)^{2}}{\sum_{k=r-n}^{r+n}}{\sum_{l=c-n}^{c+ n}}[x(k,l)-\mu_{x}(r,c)]^{2} \tag{9}\]  
where, \(\mu_{x}(r,c)\) is the mean value in the window region centered on pixel point \(x(r,c)\), \(\sigma_{x}^{2}(r,c)\) is the variance in the window region centered on pixel point \(x(r,c)\), and \((2n+1)^{2}\) is the total number of pixels in the window region centered on pixel point \(x(r,c)\). The mean value can be approximated as the background part, when \(x(k,l)-\mu_{x}(r,c)\) is the high-frequency part. Multiplying the gain factor for the high-frequency part can enhance  
Figure 7: Flowchart of GTIE-IACE algorithm. the details in the image. In this paper, we modified the calculation method of the gain factor based on adaptive contrast enhancement so that the gain factor is inversely proportional to the local mean-square error. This processing can be represented as follows:  
\[f(r,c)=\mu_{x}(r,c)+\frac{D}{\sigma_{x}(r,c)}[x(r,c)-\mu_{x}(r,c)] \tag{10}\]  
In the high frequency part of the image, the local variance is larger and the value of the gain factor is smaller. However, in the smoothed region, the local mean-square error is smaller, and the gain factor increases, which causes the amplification of the noise, so it is necessary to make some limitations on the maximum value of the gain factor to obtain better results. In this paper, the global mean-square error is used as the value of parameter \(D\) to avoid the gain factor being too large. After being processed by the IACE, the contrast of the image is enhanced, resulting in a new gray level mapping. Gradient Three-Interval Equalization Algorithm Combined with Improved Adaptive Contrast Enhancement (GTIE-IACE)  
After applying the IACE to obtain a new gray level mapping of the image, the image gradient is divided into three intervals. By dividing the gradient into three intervals, the details and contrast of the image in different gradient ranges are better displayed and enhanced. First, the gradient information of the pixel points in the image is obtained by performing a convolution operation on the image by the Sobel operator. Given that the gradient of the image at \((x,y)\) is denoted as \(G(x,y)\), and that \(I\) is the input image, the following is obtained:  
\[G_{x}=g_{x}*I= \begin{bmatrix}-1&0&1\\ -2&0&2\\ -1&0&1\end{bmatrix} *I\qquad G_{y}=g_{y}*I= \begin{bmatrix}-1&-2&-1\\ 0&0&0\\ 1&2&1\end{bmatrix} *I \tag{11}\]  
\[G(x,y)=\sqrt{G_{x}{}^{2}+G_{y}{}^{2}} \tag{12}\]  
After calculating the gradient of each pixel, the Canny edge detection algorithm is used to further emphasize the edges of the image, retain the edge gradients, and set the non-edge regions to zero. The gradient strengths are categorized into three classes. Smaller gradient strengths indicate smooth regions or insignificant edge structures in the image. Regions with moderate gradient strengths contain some slight edges or texture features in the image. Lastly, regions with higher gradients have noticeable edges, textures, or structures.