# Research on Two-Dimensional Digital Map Modeling Method Based on UAV Aerial Images
## 3 Image Stitching Based on the Novel Energy Function
Set \(E_{data}\) to a specified value, that is, divide the pixel labels into three categories: pixel points in the overlapping area are in the source image \(\mathbf{I}_{1}\) but not in the source image \(\mathbf{I}_{2}\); pixel points in the overlapping area are not in the source image \(\mathbf{I}_{1}\) but are in the source image \(\mathbf{I}_{2}\); pixel points in the overlapping area are in both the source image \(\mathbf{I}_{1}\) and the source image \(\mathbf{I}_{2}\). The expression is as follows in Equation (8):  
\[E_{data}(x,y) =\left\{ \begin{array}{l}\infty,f(\text{x},\text{y})=0\\ 0,f(\text{x},\text{y})=1\end{array} \right.,(x,y)\in I_{1} \tag{8}\] \[E_{data}(x,y) =\left\{ \begin{array}{l}\infty,f(\text{x},\text{y})=1\\ 0,f(\text{x},\text{y})=0\end{array} \right.,(x,y)\in I_{2}\] \[E_{data}(x,y) =0,(x,y)\in R\]  
In this context, \(f(x,y)\) denotes the label of the pixel, and \((x,y)\) represents the coordinates of the pixel. The \(E_{smoothness}\) smoothness term, which defines the discontinuity between adjacent pixels within a four-neighborhood \(\mathbf{N}\), plays a crucial role in the entire energy function definition. It represents the difference between adjacent pixels in the overlapping region and directly influences the quality of the entire image after stitching. However, in traditional energy functions, to optimize the regularization term of the objective function and enhance the model's generalization ability, as well as to simplify the fitting scenario, the smoothness term is often based on the \(\mathbf{L}_{2}\) norm. The expression is as follows in Equation (9):  
\[f(x)=\left|\left|x\right|\right|_{2} \tag{9}\]  
A well-designed seam should ideally traverse through the moving objects within the overlapping region to minimize the creation of artifacts, yet the smoothness term based on the \(\mathbf{L}_{2}\) norm fails to adequately distinguish between misaligned areas within the overlap. This is because the \(\mathbf{L}_{2}\) norm-based smoothness term does not provide an appropriate penalty when dealing with moving objects within the overlap. To mitigate this issue, this paper reconsiders the choice of norm for the smoothness term. In order for the novel energy function to more effectively differentiate between aligned and misaligned regions of moving objects within the overlap, it is necessary to find a suitable function that allows the seam to better avoid these objects. The goal is to maximize the penalty of the smoothness term in misaligned regions and minimize it in aligned  
Figure 2: S-T flow chart. regions, thereby distinguishing between them. Assuming that pixels with the same label in source images \(\mathbf{I}_{1}\) and \(\mathbf{I}_{2}\) are denoted as \(\mathbf{x}\), the aim is to identify differences in the same moving objects across the overlapping regions of the two source images as much as possible to effectively avoid them. In this chapter, a new function is defined based on the \(\mathbf{L}_{1}\) norm, as shown in Equation (10):  
\[f(x)=\left(||\mathbf{x}||_{1}\right)^{5/2} \tag{10}\]  
The expression for the new smoothness term function is as follows in Equation (11):  
\[ \begin{split} E_{smoothness}((x_{1},y_{1}),(x_{2},y_{2}),f(x_{1},y_{1}),f(x_{2},y_{2}))\\ =|f(x_{1},y_{1})-f(x_{2},y_{2})|\\ \cdot\left[\|f_{(x_{1},y_{1})}(x_{1},y_{1})-I_{(x_{2},y_{2})}(x_{ 1},y_{1})\|^{5/2}\right.\\ +\left.\|f_{(x_{1},y_{1})}(x_{2},y_{2})-I_{f(x_{2},y_{2})}(x_{2}, y_{2})\|^{5/2}\right]\end{split}  \tag{11}\]  
The specific procedure of the algorithm is detailed in Algorithm 1. Initially, feature extraction and matching are performed on the images to calculate a global perspective transformation matrix \(\mathbf{H}\). Based on matrix \(\mathbf{H}\), the overlapping region \(\mathbf{R}\) and boundaries of the two source images are identified. Subsequently, the data term, smoothness term, and texture term of the novel energy function are computed.