# Improvement of the Cross-Scale Multi-Feature Stereo Matching Algorithm
## 2 Algorithm Description
### Cost Aggregation  
Cost aggregation is a critical step in stereo matching algorithms, which aims to mitigate the impact of erroneous cost measurements by integrating information from multiple data points [15]. In addition to local filtering-based methods, semi-global matching (SGM) [16] has been widely adopted for disparity estimation. A local cost aggregation strategy typically  
Figure 5: Disparity maps with different cost-computation methods. involves considering disparity costs within the neighborhood of each pixel, where the aggregated costs from neighboring pixels are incorporated into the current pixel. This process recomputes the pixel-wise cost values to enhance the consistency of matching costs. In contrast to local aggregation strategies, semi-global matching (SGM) [17] employs a semi-global optimization framework that aggregates costs along multiple 1D paths (8 or 16 directions) using dynamic programming [18]. The core idea is to minimize the energy function [19]:  
\[E(D)=\sum_{p}\Big{(}C\big{(}p,D_{p}\big{)}+\sum_{q\in N_{p}}P_{1}T(|\Delta X| =1)+\sum_{q\in N_{p}}P_{2}T(|\Delta X|>1)\Big{)} \tag{7}\]  
where \(C\big{(}p,D_{p}\big{)}\) denotes the matching cost of pixel \(p\) at disparity \(D_{p}\), \(N_{p}\) represents the neighborhood centered at \(p\), \(P_{1}\) and \(P_{2}\) represent penalty terms, and \(T(\cdot)\) is an indicator function that outputs 1 if the specified condition is satisfied and 0 otherwise. However, SGM's reliance on single-scale cost volumes may lead to over-smoothing in fine structures or insufficient constraints in weakly textured areas. [PERSON] et al. [20] proposed a guided image-filtering-based cost aggregation method within a multi-scale framework. To better preserve edge contours in weakly textured regions, their approach first constructs an image pyramid via Gaussian downsampling to capture multi-scale representations [21]. Cost-aggregation values are computed independently across different scale spaces, while a regularization term is introduced to enforce cross-scale consistency, ultimately deriving the optimal aggregated cost through inter-scale optimization [22]. The guided image filtering function can be expressed as  
\[C^{\prime}(p,d)=mG(p)+n\,\forall\ p\in\ \omega_{k} \tag{8}\]  
where \(m\) and \(n\) represent the coefficients of the linear function, \(G(p)\) denotes the input guidance image, and \(C^{\prime}(p,d)\) corresponds to the cost-aggregated matching cost volume. The guided filtering algorithm is employed for cost aggregation across multi-scale images. During the cost aggregation stage, a cross-scale aggregation model is proposed to integrate spatial information across different scales. Specifically, distinct aggregation parameters are employed for cost volumes at varying scales, while a regularization term is introduced to reinforce inter-scale relationships. This formulation maximizes cost consistency within neighboring scales, namely:  
\[B_{S}(z)=\lambda\|z^{s}-z^{s-1}\|_{2}^{2} \tag{9}\]  
where \(\lambda\) denotes the regularization factor, \(s\) represents the ordinal index in scale space, and \(z^{s}\) indicates the difference in corresponding pixel costs across scale spaces. A larger \(\lambda\) value enforces stronger cross-scale consistency constraints on identical pixels, thereby enhancing the improved algorithm's capacity for visual estimation in weakly textured regions and boosting its overall robustness. Following multi-scale cost aggregation, the disparity map generated through the winner-takes-all (WTA) strategy is illustrated in Figure 6. A comparative analysis of weakly textured regions between the baseline and improved methods reveals that the proposed cross-scale cost aggregation achieves:  
1. Reduced mismatch rate compared to the unmodified approach
2. Smooth disparity transitions in continuous regions
3. Effective restoration of disparity values in weakly textured areas.