# Deep-Space Background Low-Light Image Enhancement Method Based on Multi-Image Fusion
## 3 Method
### Enhancement of Satellite Images Containing Celestial Bodies
#### 3.2.1 Extract the Earth Region  
The Earth region mask construction module is illustrated in Figure 5. This module serves to extract the Earth region while effectively suppressing and eliminating the halo effect. It primarily involves several key steps: calculating the segmentation threshold and conducting binarization, determining the halo range, extracting and separating the halo, performing contour analysis and optimizing the region, as well as executing post-processing to generate the final mask. Figure 4: The flowchart for enhancing satellite images containing the Earth. Figure 5: The Earth region mask construction module. Calculate segmentation threshold and binarization  
To calculate the global segmentation threshold, the most commonly used method is [PERSON]'s [22], which determines the optimal segmentation threshold T by maximizing between-class variance. The segmentation threshold T satisfies the following equation. \[\sigma_{w}^{2}(T)=\omega_{0}(T)\sigma_{0}^{2}(T)+\omega_{1}(T)\sigma_{1}^{2}(T) \tag{6}\]  
where \(\omega_{0}\) and \(\omega_{1}\) represent the foreground and background pixel occupancy, respectively, \(\sigma_{0}\) and \(\sigma_{1}\) denote the corresponding variance. This threshold is used to initially separate the salient regions from the background in the image to generate an initial binary image. Threshold segmentation of the original image \(I(x,y)\) to obtain a binary image \(B_{raw}\) containing halos. \[B_{raw}(x,y)= \begin{cases}1&\text{if }\ I(x,y)\geq T\\ 0&\text{otherwise}\end{cases}  \tag{7}\]  
where T represents the segmentation threshold and \(B_{raw}\) denotes the initial binary image. The algorithm is a common method for obtaining the global threshold of the image and applies to most occasions where the global threshold of the image is required. However, because the Earth's surface has oceans, clouds, land, etc., leading to sometimes when using the OTSU algorithm, the calculated segmentation threshold will make the extracted Earth region incomplete, not in line with the actual situation, affecting the image enhancement effect. In this paper, we consider that the region occupied by the Earth and the target in the whole image is small, and the rest is the black background region. Combined with this particularity of satellite images, a threshold segmentation algorithm for satellite images containing celestial bodies is designed, i.e., multi-segment threshold segmentation based on average brightness, which is formulated as follows:  
\[\text{{threshold value}}= \begin{cases}\max(0.8\times\varpi,36)&\text{if }\varpi>40\\ \min(\varpi,36)&\text{if }30<\varpi\leq 40\\ \min(0.75\times\varpi,22.5)&\text{if }10<\varpi\leq 30\\ \varpi&\text{if }\varpi\leq 10\end{cases}  \tag{8}\]  
where \(\varpi\) denotes the average brightness of the image, based on the distribution of the average brightness value, to calculate and determine the segmentation threshold. If the average brightness is greater than 40, set the segmentation to 80% of the average brightness, because a higher average brightness means that the image is brighter overall, and setting a smaller threshold can effectively separate the background from the target; if the average brightness is between 30 and 40, use the average brightness itself as the threshold, but not more than 36, which maintains the details while avoiding over-binarization in the case of a relatively high image brightness; if the average brightness is low (between 10 and 30), to prevent loss of dark information, the threshold is set to 75% of the average brightness, up to a maximum of 22.5. This ensures that details are preserved even in darker images; if the average brightness is very low (less than 10, close to black), the threshold is set to the average brightness itself. This prevents noise from being misclassified as a target area.