# Underwater Image Mosaic Algorithm Based on Improved Image Registration
## 2 Materials and Methods
### Accurate Matching of Feature Points Based on the IIR Algorithm
#### 2.3.2 The IIR Algorithm  
In the improved RANSAC (I-RANSAC) algorithm [12], the fundamental purpose is to construct the optimal Homography matrix \(\mathbf{H}\), which refers to the invertible homogeneous transformations between two planes, plays a very important role in multi-view image. Then, the coordinate transformation can be shown as follows:  
\[\left[ \begin{array}{c}x_{b}\\ y_{b}\\ 1\end{array} \right]=\left[ \begin{array}{ccc}h_{0}&h_{1}&h_{2}\\ h_{3}&h_{4}&h_{5}\\ h_{6}&h_{7}&1\end{array} \right]\left[ \begin{array}{c}x_{a}\\ y_{a}\\ 1\end{array} \right]. \tag{11}\]  
In Equation (11), \((x_{a},y_{a})\) and \((x_{b},y_{b})\) are respectively the image coordinates before and after the transformation. \[\mathbf{H}=\left[ \begin{array}{ccc}h_{0}&h_{1}&h_{2}\\ h_{3}&h_{4}&h_{5}\\ h_{6}&h_{7}&1\end{array} \right]. \tag{12}\]  
In Equation (12), \(h_{0}\)-\(h_{7}\) are eight parameters in the Homography matrix \(\mathbf{H}\), which can be calculated by selecting 4 feature points, i.e., four-point algorithm [12; 40], on each of the two images. However, when the I-RANSAC algorithm shown in Ref. [12] is adopted to achieve image matching, if the number of image feature points obtained after SIFT processing is large and the degree of correlation between feature points is small, then the difficulty of acquiring the Homography matrix increases, which affects the matching accuracy and matching time of the image feature points. To meet the requirements of simultaneously improving the accuracy and speed, on the basis of RANSAC universal framework, this  
Figure 1: SIFT key point detection. (**a**) is the input image [37]. and (**b**) is the key point description image, which is represented by a small circle at the function position, and the direction of the feature points will be displayed inside the circle. (Source: The Oxford Buildings Dataset). paper proposes IIR in the module of model generation to optimize the Homography matrix through a decision rule for the total number of interior points. The specific implementation process is given below. Firstly, 4 pairs of feature points that are not on the same line are randomly selected after the rough matching with SIFT, and the distance among the matching points can be calculated, which is denoted as a set \(d_{H}\). The purpose of selecting 4 pairs of non-collinear matching points is to solve the 8 parameters in the Homography matrix \(\mathbf{H}\) and obtain the unique Homography matrix \(\mathbf{H}\)[41]. Secondly, the ratio of the nearest distance \(d_{\text{min}}\) and sub-nearest distance \(d_{\text{min0}}\) should be calculated according to the nearest-neighbor principle in \(d_{H}\), and then the results will be divided into 4 groups from large to small. Thirdly, the number of inner points \(T_{H}\) for the 4 groups of matching pairs that are randomly selected in the group with the smallest ratio are calculated. If \(T_{H}\geq 3\), then the selected matching pair is retained, and the remaining matching pairs are successively executed in the above process; otherwise, 4 groups of feature points are randomly selected again for the operation. Finally, a comparison is made between the accumulated inner points \(T_{Hall}\) and the pre-set threshold \(T_{H0}\). If \(T_{Hall}\geq T_{H0}\), then the total process finishes; otherwise, it is restarted. A flow chart for IIR is shown in Figure 2.  
Depending on the aforementioned steps and flow chart, in IIR algorithm, the distance among the matching points can be calculated, while the ratios of the nearest distance \(d_{\text{min}}\) and sub-nearest distance \(d_{\text{min0}}\) are divided into 4 groups from large to small, with the principle of nearest-neighbor. Thus, when selecting matching pairs from the smallest ratio group, it can ensure that the selected matching pairs are evenly distributed in the image, which can avoid selecting some isolated feature points.