# Underwater Image Mosaic Algorithm Based on Improved Image Registration
## 2 Materials and Methods  
### Method of Image Enhancement  
#### 2.1.1 Mixed Method for Image Contrast Enhancement  
Due to the influence of the complex underwater environment, the underwater images have different degrees of degradation, resulting in low contrast of the original image performance, which directly affects the subsequent image registration and image fusion. The method of piecewise linear transformation is actually to enhance the contrast of various parts of the original image [23]. It enhances the gray area of interest in the image and suppresses that of no interest.  
\[l_{out}=\left\{\begin{array}{ll}0&l_{inp}<l_{\min}\\ 255\times\left(\frac{l_{inp}-l_{\min}}{l_{\max}-l_{\min}}\right)&l_{\min}\leq l _{inp}\leq l_{\max}\\ 255&l_{inp}>l_{\max}\end{array}\right. \tag{1}\]  
In Equation (1), \(l_{inp}\) is the pixel value of the input pixel, \(l_{out}\) is the pixel value of the output pixel, \(l_{\min}\) is the set minimum pixel threshold, \(l_{\max}\) is the set maximum threshold of the pixel, and the maximum grayscale value of the pixel is 255. The piecewise linear method is simple and produces very good results, but is not effective for areas that contain a lot of darkness or light.  
The method of histogram equalization is adopted to map the pixel gray level and stretch the image nonlinearly [24; 25; 26; 27; 28], and thus the probability density of the transformed image gray level is evenly distributed and the overall contrast of the image is improved. In two-dimensional image space, it is assumed that \(r\) and \(s\) are the gray level of the image before and after transformation, respectively, and the probability density of \(r\) is \(p(r)\). Then, for the gray level \(r_{k}\), the corresponding probability density after transformation is \(S_{k}\) as follows:  
\[s_{k}=\sum_{c=0}^{k}p(r_{c})=\sum_{c=0}^{k}\frac{n_{c}}{N_{n}},\;k=0,1,\ldots, 255 \tag{2}\]  
In Equation (2), \(n_{c}\) is the number of pixels of \(r_{k}\), \(N_{n}\) is the total number of pixels of the image, and \(k\) is the gray level of the transformed image. When \(k\) is 255, it is the maximum gray level. However, if the original image contains many pixels and the grayscale value is equal to the minimum brightness, the formula will scale up the grayscale value of these pixels, making histogram equalization difficult to apply and may reduce the image contrast.  
Therefore, the combination of piecewise linear method and histogram equalization method is called mixed method, which is used to improve image contrast. The idea of our algorithm is to first map the interval between the set minimum brightness and maximum brightness to the whole interval using piecewise linear method, so that the number of pixels whose brightness is less than \(l_{\min}\) and \(l_{\max}\) is less than 1% of all the pixels of the image, thus reducing the serious impact of those few very low or very high pixels on histogram equalization. Then all the pixels are evenly distributed on as many gray levels as possible through histogram equalization. The hybrid method produces enhanced images with high contrast and a large dynamic range.