# Overcoming Adverse Conditions in Rescue Scenarios: A Deep Learning and Image Processing Approach
## 2 Materials and Methods
### Pipeline Design
#### 2.1.2 Exposure Segmentation (ES)  
EC outputs complementary results, which need to be merged based on the exposure conditions of the original image. The ES module identifies the overexposed or underexposed regions of the original image, thus allowing the construction of a final image with a more balanced exposure and a wider range of details. Specifically, the module outputs three binary images (\(M_{OE}\), \(M_{UE}\), and \(M_{CE}\)), which refer to the Over, Under, and Correctly-Exposed Masks, respectively (see Figure 4). We created the segmentation masks using lightness, saturation, and contrast information, as detailed in Equations (1)-(5). The first two components are retrieved from the HSV (Hue, Saturation, Value) color space, which separates the chromatic (H and S) from the lightness information (V). The Contrast (C) information is obtained by taking the absolute value of the Laplacian of the grayscale version of the images and then applying a threshold to the resulting Laplacian image. This thresholding step helps suppress low-amplitude noise and retain only the most prominent features, resulting in the thresholded version of C, denoted as \(T_{\text{C}}\). The three visual attributes that contribute to mask generation are determined by the properties of the regions being segmented. Overexposed regions occur when too much light enters the camera, resulting in washed-out or overly bright images that appear white and blown out. Conversely, underexposure happens when too little light enters the camera, resulting in dark images with less vibrant colours. Figure 2: Exposure correction (EC). The figure illustrates the EC module, comprising two parallel branches. The upper branch, labelled as the Under-Exposure Branch (\(UE_{b}\)), displays the direct application of the Low-Light DL model to the original image. The second branch, identified as the Over-Exposure Branch (\(OE_{b}\)), exhibits the intermediate processing steps required for correction. Masks were obtained using the following thresholding relationships:  
\[M_{OE}(i,j)=\left\{ \begin{array}{ll}1,&\quad V(i,j)>0.9\wedge S(i,j)<0.1\\ 0,&\quad V(i,j)\leq 0.9\lor S(i,j)\geq 0.1\end{array} \right. \tag{1}\]  
\[M_{UE}(i,j)=\left\{ \begin{array}{ll}1,&\quad V(i,j)<0.1\\ 0,&\quad V(i,j)\geq 0.1\end{array} \right. \tag{2}\]  
\[M_{CE}(i,j)=\
eg(M_{OE}(i,j)\lor M_{UE}(i,j)) \tag{3}\]  
Figure 4: Exposure segmentation (ES). The input is the image under the original lighting conditions. The outputs are three binary images (\(M_{OE}\), \(M_{UE}\) and \(M_{CE}\)), which represent the Over, Under and Correctly-Exposed Masks, respectively. Figure 3: \(OE_{b}\) input generation. The image on the left is the original, and the image on the right is after pre-processing. Above each image is the histogram distribution of their lightness (\(L^{*}\)) channel. The conversion from (**c**) to (**d**) enabled us to treat the overexposure correction as an underexposure recovery problem. where \(M_{OE}\), \(M_{UE}\), and \(M_{CE}\) are the Over-Exposed, Under-Exposed, and Correctly-Exposed Masks. \(V\) and \(S\) are the Value and the Saturation channels of the HSV version of the image scaled between \([0,1]\). To include edges and textures information, for each mask \(M_{*}\), we applied:  
\[M_{*}\lor T_{C} \tag{4}\]  
where \(T_{C}\) is the following binary mask:  
\[T_{C}(i,j)=\left\{ \begin{array}{ll}1,&\quad C(i,j)\geq 0.9\\ 0,&\quad C(i,j)<0.9\end{array} \right. \tag{5}\]  
The selection of threshold values for the over- and underexposed masks was guided by both empirical observation and domain knowledge, the latter being derived from a literature review of typical brightness and saturation ranges for such regions. This knowledge allowed us to narrow the range of values to test empirically and helped us select threshold values that were more likely to capture the relevant characteristics of the image [28; 29; 30; 31; 32].