# Research on Two-Dimensional Digital Map Modeling Method Based on UAV Aerial Images
## 3 Image Stitching Based on the Novel Energy Function  
Feature matching using the improved C-SURF algorithm yields relatively ideal results. For multiple images, image stitching is also required. Conventional image stitching methods abound, such as those based on trigonometric function weights, pixel-weighted averaging, and direct averaging methods. However, these methods often fall short, primarily because they struggle to achieve seamless stitching of color images, and when there are moving objects in the images to be stitched, the resulting effect is prone to ghosting and other issues [14]. Therefore, an optimal seam-finding method is needed to address discontinuities and ghosting in the orthoimage sequences obtained by UAVs. This paper transforms the problem of finding the best seam into a pixel labeling problem. By constructing an energy function based on the energy spectrum, smoothness terms, and problem-specific factors, a novel minimum cut and maximum flow connected graph is derived, ultimately generating the optimal seam. Under the consideration of the energy spectrum and the smoothness term, the texture features of neighboring pixels with the same label are introduced as an expansion factor, and the novel energy function formula is shown in Equation (6). \[E(x,y)=E_{data}(x,y)+\lambda E_{smoothness}(x,y)+E_{texture}(x,y) \tag{6}\]  
A crucial step in the minimum cut and maximum flow algorithm is the identification of a connected graph. As depicted in Figure 2, assuming the source node is S and the sink node is T (hereinafter referred to as the S-T connected graph), the process involves the following: Pixels within the overlapping region correspond to nodes in the connected graph, with the nodes comprising a set of vertices \(\mathbf{V}\) and a set of edges \(\mathbf{E}\). The network flow between the source and sink nodes traverses through various nodes within the overlapping region, assigning different weights based on distinct energy spectra. In the graph, the weights of the connections for network t are derived from the data term \(E_{data}\), for network n from the smoothness term \(E_{smoothness}\), and for network m from the texture feature \(E_{texture}\). Within the graph, the thickness of the network lines represents the magnitude of the weights; it is assumed that the closer the pixel values of two adjacent pixels p and q are to each other, the greater the weight assigned, indicating that pixel points p and q are likely from the same image. Conversely, if the pixel values are dissimilar, the two pixels may originate from two different source images. Thus, the S-T connected graph based on the overlapping region's pixel points between different images is essentially formed. The calculation formula for texture features is shown in Equation (7). \[E_{texture}(x,y)=\frac{\sum\limits_{i=x-1}^{x+1}\sum\limits_{j=y-1}^{y+1} \big{(}I_{1}(i,j)-\overline{I}_{1}(i,j)\big{)}\big{(}I_{2}(i,j)-\overline{I}_ {2}(i,j)\big{)}}{\sqrt{\sum\limits_{i=x-1}^{x+1}\sum\limits_{j=y-1}^{y+1} \big{(}I_{1}(i,j)-\overline{I}_{1}(i,j)\big{)}^{2}}\sqrt{\sum\limits_{i=x-1}^{ x+1}\sum\limits_{j=y-1}^{y+1}\big{(}I_{2}(i,j)-\overline{I}_{2}(i,j)\big{)}^{2}}} \tag{7}\]Here, \(\lambda\) represents the adjustment parameter, which is set to a default value of 1 in the experiments; \(\overline{I}_{i}(i,j)\) denotes the pixel points within the overlapping region of the two images; and \(I_{i}(i,j)\) represents the feature spectrum within the central 3 \(\times\) 3 neighborhood. The result of reassigning labels is obtained by optimizing the **S-T** connected graph using the min-cut and max-flow algorithms.