# A Segmentation-Based Optimal Seamline Generation Method for SAR Image Mosaic
## 2 Materials and Methods
### Segmentation-Based Optimal Seamline Generation Model
#### 2.3.3 Cost Matrix Construction  
In the context of optical remote sensing images, an optimal seamline is expected to traverse the most similar portion of the overlapping areas of two images, minimizing inconsistencies [37]. Similarly, for SAR images a high-quality seamline should pass through homogeneous areas. Thus, the optimal seamline in SAR images should preferably traverse similar homogeneous areas, especially the joint homogeneous areas with lower weights identified during the screening process described above.  
Treating optimal seamline generation as a shortest path problem in a matrix, the objective is to find a path in the overlapping area that minimizes the cost [37]. In the case of two SAR images, a cost matrix of dimensions \(W*H\) is created, encompassing pixels in the overlapping area, where \(W\) and \(H\) denote the width and height of the overlapping area, respectively. Each pixel in this matrix is assigned a non-negative cost, and the optimal  
Figure 3: The process of extracting consistent and stable parcels. (**a**) Stability classification map \(\omega_{A}\) and \(\omega_{B}\) for \(I_{A}\) and \(I_{B}\), where darker areas indicate higher stability. (**b**) Visualization results obtained by overlaying \(\omega_{A}\) and \(\omega_{B}\) onto \(I_{A}\) and \(I_{B}\), with enhanced stability indicated by the direction of arrows. (**c**) A unified classification map \(\omega\) generated \(\omega_{A}\) and \(\omega_{B}\). (**d**) Color-coded visualization obtained by overlaying \(\omega\) onto \(I_{A}\) and \(I_{B}\), depicting stability enhancement in the direction of the arrows.  
seamline should exclude high-cost pixels. Contrasting with a costly short-segment seamline, a low-cost long-segment seamline has the advantage of bypassing feature targets. This transformation turns the optimal seamline problem into finding the path that minimizes the cost in the cost matrix.  
The construction of the cost matrix involves calculating the cost for each pixel in the overlapping area. Using pixel-based methods may be susceptible to speckle noise; the proposed method extracts joint homogeneous areas and searches for seamlines in joint homogeneous areas with lower weights to achieve building avoidance. In order to make the seamlines lie inside the joint homogeneous areas, a combination of parcel and pixel intensity difference is used to construct the cost matrix, which also reduces the effect of speckle noise compared to using only pixel-based methods. In this paper, the cost function is constructed using joint homogeneous areas and image intensity differences, which reflects both the results of the joint segmentation as well as the relationship between the image pixels. For two images, \(I_{A}\) and \(I_{B}\), the cost function, \(C(x,y)\), is defined as:  
\[C(x,y)=\omega(p_{i})\cdot C_{d}(x,y), \tag{4}\]  
where \((x,y)\) represents the pixel with coordinates \((x,y)\) in the overlap area and \(C_{d}(x,y)\) is the intensity difference of pixels \((x,y)\) in the overlapping areas of neighboring images, which is defined as:  
\[C_{d}(x,y)=|I_{A}(x,y)-I_{B}(x,y)|, \tag{5}\]  
where \(I_{A}(x,y)\) and \(I_{B}(x,y)\) denote the pixel gray values of the \((x,y)\) of \(I_{A}\) and \(I_{B}\), respectively. \(|\cdot|\) represents the absolute value.  
By utilizing Equation (4), the cost for each pixel in the overlapping area is calculated, thereby completing the construction of the cost matrix. Finally, the Dijkstra algorithm is applied to identify the optimal path in the cost matrix. [PERSON]'s algorithm is a widely used method for searching the shortest path in graph theory. It systematically extends outward layer by layer from the starting point (following the breadth-first search idea) until reaching the endpoint. Once the initial seam network is constructed, the intersection points of the image boundary are extracted, designating these points as the starting and ending points for the Dijkstra algorithm.  
Guided by the optimal seamline, the SAR image mosaic is successfully executed.