# An Improved SIFT Underwater Image Stitching Method
## 3 Materials and Methods
### Underwater Image Stitching  
#### 3.2.1 The Traditional SIFT Method  
As described in the literature [9], the SIFT algorithm utilizes a 128-dimensional feature vector to describe feature points in an image with scale, rotation, and translation invariance. The matching process is based on the similarity between these feature point descriptors.  
Firstly, SIFT detects preliminary extrema points through the construction of a Gaussian difference pyramid. It then filters low-contrast and edge-response points to obtain robust key points. Subsequently, SIFT assigns an orientation to each key point, calculates the gradient magnitude and orientation, and generates orientation gradient histograms. The  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Database** & **Tentative Matches** & **Inlier Matches** & **Accuracy Rate** \\ \hline Original images & 210 & 94 & 44.76\% \\ ICM & 187 & 103 & 55.08\% \\ ULAP & 191 & 103 & 53.93\% \\ UDCP & 151 & 71 & 47.02\% \\ IBLA & 166 & 89 & 53.61\% \\ Our method & 171 & 101 & 59.06\% \\ \hline \hline \end{tabular}
\end{table}
Table 1: Underwater image quality evaluations.  
Figure 2: (**a,b**) The original underwater images; (**c,d**) the preprocessed underwater images generated by our method.  
radius of the image area to be calculated is then determined, and the coordinate axis is rotated to align with the main direction of the key point. An \(8\times 8\) window surrounding the key point is selected as the feature descriptor, and a feature point descriptor is generated [9]. Finally, SIFT performs feature point matching.  
In the feature point matching, the reference image (image A) is denoted by \(I\) and the training image (image B) is denoted by \(I^{\prime}\). The expression is as follows:  
\[\mathbf{x}^{\prime}=\mathbf{H}\mathbf{x}, \tag{1}\]  
where \(\mathbf{x}=\begin{bmatrix}x&y\end{bmatrix}^{T}\) and \(\mathbf{x}^{\prime}=\begin{bmatrix}x^{\prime}&y^{\prime}\end{bmatrix}^{T}\) denote the pixel coordinates of the reference image and the pixel coordinates of the training image, respectively, while \(\mathbf{H}\in\mathbb{R}^{3\times 3}\) represents the homography matrix. The flush coordinates of the target image and the reference image pixel points are expressed as follows:  
\[\begin{bmatrix}x^{\prime}\\ y^{\prime}\\ 1\end{bmatrix}=\begin{bmatrix}h_{1}&h_{2}&h_{3}\\ h_{4}&h_{5}&h_{6}\\ h_{7}&h_{8}&h_{9}\end{bmatrix}\begin{bmatrix}x\\ y\\ 1\end{bmatrix}. \tag{2}\]  
The homography matrix has a degree of freedom of 8. Therefore, we assume that \(h_{9}=1\), and the above equation can be organized as follows:  
\[x^{\prime}=\frac{h_{1}x+h_{2}y+h_{3}}{h_{7}x+h_{8}y+1} \tag{3}\]  
\[y^{\prime}=\frac{h_{4}x+h_{5}y+h_{6}}{h_{7}x+h_{8}y+1}. \tag{4}\]  
Organize Equations (3) and (4) into the following form:  
\[\begin{bmatrix}x_{1}y_{1}1\ 0&0\ 0\!-\!x_{1}x_{1}^{\prime}\!-\!y_{1}x_{1}^{ \prime}\!-\!x_{1}^{\prime}\\ 0\ 0\ 0x_{1}y_{1}\!-\!x_{1}y_{1}^{\prime}\!-\!y_{1}y_{1}^{\prime}\!-\!y_{1}^{ \prime}\end{bmatrix}\begin{bmatrix}h_{1}&h_{2}&h_{3}&h_{4}&h_{5}&h_{6}&h_{7}&h_ {8}&1\end{bmatrix}^{T}=\begin{bmatrix}0\\ 0\end{bmatrix}, \tag{5}\]  
where \(\begin{bmatrix}x_{1}&y_{1}\end{bmatrix}^{T}\) and \(\begin{bmatrix}x_{1}^{\prime}&y_{1}^{\prime}\end{bmatrix}^{T}\) indicate the coordinates of the first set of matched pairs. When we obtain the coordinates of the 4 sets of matched pairs, we can solve the above system of equations to obtain the homography matrix.