# Utilization of Merge-Sorting Method to Improve Stitching Efficiency in Multi-Scene Image Stitching
## 3 Image Registration  
Image registration is the core step of image stitching. The result of image registration directly affects the result of the subsequent image fusion. For the same scene, images with overlapping areas generally have overlapping areas of about 30% to 60%. If there is an overlapping area between two images, the image fusion algorithm can be used after image registration to stitch the two images into a wide-field image. Other images with overlapping areas are also registered and fused in the same way, and then they are stitched in sequence. Finally, the scene can be stitched into a complete image. The detection of feature points by the A-KAAZE algorithm can be divided into three main steps. The first step is the building of the nonlinear scale space, which is followed by the detection of feature points. The last step is the generation of feature descriptors; that is, feature point matching. When building nonlinear scale spaces, the A-KAAZE algorithm uses a nonlinear diffusion filter that often employs a divergence of a certain flow function to describe the variation in luminance in different spaces. The nonlinear partial differential equation is:  
\[\frac{\partial L}{\partial t}=div(c(x,\,y,\,t)\cdot\
abla L \tag{1}\]  
where _div_ and \(\
abla\) represent the divergence and gradient, respectively; \(L\) represents the brightness of the image; \(c\) is the transfer diffusion function used to adapt to the local structure of the image to ensure its local accuracy; and \(t\) in the function \(c\) is the scale parameter of the image: the larger the value of \(t\), the greater the scale of the image. The function c is defined as:  
\[c(x,y,t)=g(\
abla L_{\sigma}(x,y,t) \tag{2}\]  
where \(g\) is defined as:  
\[g=\frac{1}{1+\frac{\left|\
abla L_{\sigma}\right|^{2}}{\lambda^{2}}} \tag{3}\]  
Here, \(\
abla L_{\sigma}\) represents the image gradient for the Gaussian smoothing with the image brightness as the standard deviation \(\sigma\), and the parameter \(\lambda\) is the contrast factor that controls the degree of diffusion. The size of \(\lambda\) determines the boundary of the image to be enhanced or weakened during the smoothing process. The larger the value of \(\lambda\) is, the less boundary information is preserved and the smoother the image; in contrast, the more boundary information is preserved, the clearer the image is. After the nonlinear scale space is constructed, the detection and localization of feature points are carried out. Similar to the SIFT algorithm, A-KAAZE feature point detection uses the non-maximum suppression method to calculate the Hessian matrix for each pixel in the image pyramid. The formula for calculating the determinant of the Hessian matrix is:  
\[L_{Hession}=\sigma^{2}\Big{(}L_{xx}L_{yy}-L^{2}_{xy}\Big{)} \tag{4}\]  
where \(\sigma\) is the integer value of the scale parameter \(\sigma_{i}\) of a certain layer; \(L_{xx}\) and \(L_{yy}\) represent the second-order partial derivatives of the image in the horizontal and vertical directions, respectively; and \(L_{xy}\) represents the partial derivatives of \(x\) and \(y\), respectively. Then, the Taylor expansion is used to determine the coordinates of the feature points, and the solution formula is as follows:  
\[L(x)=L+\left(\frac{\partial L}{\partial x}\right)^{T}x+\frac{1}{2}x^{T}\frac {\partial^{2}L}{\partial x^{2}}x \tag{5}\]  
where \(L(x)\) represents the spatial scale function of the image brightness, and \(x\) represents the coordinates of the feature points. The formula to solve for these coordinates is:  
\[\hat{x}=-\left(\frac{\partial^{2}L}{\partial x^{2}}\right)^{-1}\frac{\partial L }{\partial x} \tag{6}\]  
Feature point matching involves constructing a KD tree of the two images to be matched and then selecting the first image as a reference image for KNN matching. The public matching pairs after two matches are used as the initial matching pairs.