# Inhomogeneous Illumination Image Enhancement Under Extremely Low Visibility Condition
## 2 Materials and Methods
### Hmhe
#### 2.2.2. SDIF  
Here, we propose an effective method to filter the optimal target for a desired image. For images corrupted by inhomogeneous illumination, estimating the background light is crucial. Based on the assumption that illumination is a low-frequency signal, the LPF was applied to estimate and remove it. Compared to other methods, such as top-hat transformation, the LPF effectively preserves high frequency information. However, in complex scenes, the selecting of filter parameters is critical. Choosing a kernel size that is either too small or too large could lead to ineffective enhancement. An adaptive algorithm based on image features to automatically estimate the appropriate kernel and effectively removing inhomogeneous illumination while preserving image details was proposed. A windowed Gaussian function was chosen for its naturalness in signal processing [29] as the convolution kernel of the LPF. The standard variance \(\sigma\) of the Gaussian function and its kernel size satisfies \(k=2\lceil 2\sigma\rceil+1\). Here, \(\lceil\cdot\rceil\) means rounding up to the nearest integer. The expression for the SSIM of the original image and the filtered image is given by the following:  
\[SSIM(X,Y)=\frac{2\mu_{X}\mu_{Y}(2\sigma_{XY}+C_{2})}{\big{(}\mu_{X}^{2}+\mu_{Y} ^{2}+C_{1}\big{)}\big{(}\sigma_{X}^{2}+\sigma_{Y}^{2}+C_{2}\big{)}} \tag{11}\]  
where \(X\), \(Y\) are the original and filtered image, \(\mu_{X,Y}\), \(\sigma_{X,Y}\) are the average and variances of \(X\), \(Y\), \(\sigma_{xy}\) is the covariance, \(C_{1}=\left(K_{1}L\right)^{2}\), \(C_{2}=\left(K_{2}L\right)^{2}\) are the regulation constants, and \(K_{1}\), \(K_{2}\) are two small constants. The SSIM has sufficient resolution to judge the structural  
Figure 2: Overview of the HMHE flow chart. The input image \(U\) was initially processed by SDIF to estimate the optimal filtering kernel. This kernel was used to compute the illumination of the image, \(U_{Illu}\). The illumination was then optimized using the visual optimization module to produce an enhanced \(U_{Illu}\). The input image was subtracted from this illumination to obtain the target signal \(U_{homo}\). These two components were enhanced by MHE and then linearly combined to result in the final output of HMHE. similarity between two images. In our study, the determination of the cutoff kernel \(k_{cutoff}\) is given by the following expression:  
\[k_{cutoff}=\Sigma_{i}d_{i}*\text{argmin}\Big{[}\Big{|}\
abla_{k}^{i}SSIM\Big{(} I,I_{filtered}\Big{)}\Big{|}\Big{]},\ for\ i=1,\ 2 \tag{12}\]  
where \(d_{1}=0.7\), \(d_{2}=0.3\) are empirical coefficients, \(|\cdot|\) and \(\
abla_{k}^{i}\) denote taking the absolute and \(i^{th}\) derivative of the variable \(k\). The adjustment of \(k_{cutoff}\) has instrumental impact on image quality. The pseudocode for SDIF (Algorithm 1) is given as follows:  
```
1. Compress the input image \(U\): \(U_{com}=\text{imresize}(U,0.25)\)
2. Initialize variables: \([d_{1},d_{2}]=[0.7,0.3]\)
3. Compute the SSIM for kernels within range [a, b]: \(FU_{com}=\text{fft2}(U_{com})\) for kernel = [a, b] \(FGAu=\text{fft2}(\text{Gaussian}(\text{kernel}))\) \(RI=FU_{Com}*FGAu\) \(U_{out}=\text{fft2}(RI)\) \(\text{SSIM}(\text{kernel})=\text{ssim}(U,\,U_{out})\) end
```  
4. Selection of the optimal kernel: \(\text{Index\_d}=\text{min}(\text{abs}(\text{diff}(\text{SSIM})))\) Index_d2 = min(abs(diff(diff(\text{SSIM})))) kernel = a + \(d_{1}\)*index_d + \(d_{2}\)*index_d2 ```  
**Algorithm 1** Pseudocode of SDIF  
For a complete filtering process, initially, as the kernel began to exclude the detailed and effective information, the SSIM experienced a notable decrease. The interpretation of the two derivatives is as follows: the first derivative captures how swiftly structural similarity diminishes; the second derivative identifies the critical point where this rate of change shifts.