# Enhancing Underwater Images via Color Correction and Multiscale Fusion
## 3 Method of This Article
### Color Correction  
Light travels differently underwater, resulting in a green (or blue) int in underwater images due to the attenuation of blue and red light being more severe than green light. However, if the unique characteristics of color degradation in underwater scenes are not considered, this may cause additional color distortion, such as the introduction of red artifacts. To tackle this issue, our method uses an adaptive local compensation strategy to remove color distortion in underwater images, providing significant compensation for pixels with severe attenuation and limited compensation for others. The mathematical definition of this method is presented below. \[I_{rc}(x,y)=I_{r}(x,y)+\left(I_{g}(x,y)-I_{r}(x,y)\right)\times\left(\overline{ I}_{g}-\overline{I}_{r}\right) \tag{1}\]\[I_{bc}(x,y)=I_{b}(x,y)+\left(I_{g}(x,y)-I_{b}(x,y)\right)\times\left(\overline{I}_ {g}-\overline{I}_{b}\right) \tag{2}\]  
where \(I_{r}(x,y)\) represents the pixel value of the red channel at the pixel location (\(x\), \(y\)), \(I_{g}(x,y)\) represents the pixel value of the green channel at the pixel location (\(x\), \(y\)), \(I_{b}(x,y)\) represents the pixel value of the blue channel at the pixel location (\(x\), \(y\)), \(I_{rc}(x,y)\) represents the pixel value of the red channel at the pixel location (\(x\), \(y\)) after compensation, \(I_{bc}(x,y)\) represents the pixel value of the blue channel at the pixel location (\(x\), \(y\)) after compensation, \(\overline{I}_{g}\) represents the average value of the entire green channel, and \(\overline{I}_{r}\) represents the average value of all the red channel. \((\overline{I}_{g}-\overline{I}_{r})\) is crucial in describing the local attenuation of the red channel in comparison to the green channel, and pixels with significant attenuation of the red channel receive more compensation accordingly. The same principle applies to the blue channel. After compensation processing, the grayscale value distribution of each color channel of the degraded underwater image remains uneven, and it is necessary to adjust the pixel value range of the image to enhance the visual effect and readability of the image. The linear stretching method can make the pixel value range more uniform, thereby making some detailed information that was originally compressed into a smaller pixel value range more visible. However, in some cases, linear stretching may also make the detailed information that was originally in the low pixel value range become blurrier or lost. This paper proposes using the image histogram to subsequently correct the gray value distribution of each color channel in the underwater degraded image, even after the color compensation. The following section describes the process using the red channel as an example, with the same operation performed for the blue and green channels. The histogram of the red channel is defined as follows:  
\[H(i)=n_{i}\,i\in[0,255] \tag{3}\]  
Figure 1: The framework of the proposed method. R, G and B are the color channels of RGB format images, respectively. \(n_{i}\) is the count of pixels in the compensated red channel with a pixel value of \(i\). \[H_{\text{C}}(i)=\left\{ \begin{array}{cc}\text{{th}}&\text{{if }}H(i)>\text{{th}}\\ H(i)&\text{{else}}\end{array} \right. \tag{4}\]  
In Equation (4), \(H_{\text{C}}(i)\) represents the histogram after clipping, while \(\text{{th}}\) is the clipping threshold set in this paper, which can be mathematically expressed as follows:  
\[\text{{th}}=\text{{mean}}(H(i))+\text{{std}}(H(i)) \tag{5}\]  
In Equation (5), the term \(\text{{mean}}(H(i))\) is the mean value of \(H(i)\), while \(\text{{std}}(H(i))\) is the standard deviation of \(H(i)\). The next step is to assign the number of pixels in the clipped histogram. The mathematical definition is outlined below:  
\[H_{\text{F}}(i)=H_{\text{C}}(i)+(\sum_{i=0}^{255}\text{{val}}(i))/255 \tag{6}\]  
\[\text{{val}}(i)=\left\{ \begin{array}{cc}H(i)-\text{{th}}&\text{{if }}H(i)>\text{{th}}\\ 0&\text{{else}}\end{array} \right.