## 2 Methods
### Matching Cost Aggregation Method  
Per-pixel-based matching cost is sensitive to noise. Aggregating the matching cost over a local support window is an effective way to improve the accuracy and robustness of local stereo matching methods. Matching cost aggregation can be viewed as filtering on the cost volume. Given a cost volume \(C\), the aggregated matching cost at pixel \(i\) with disparity \(d\) can be computed according to:  
Figure 3: Comparison of different matching cost for Tsukuba and Teddy. (**a**) Left image; (**b**) right image; (**c**) ground truth map; (**d**) absolute difference of image channels; (**e**) absolute difference of image gradients; (**f**) traditional census transform-based matching cost; (**g**) proposed combined matching cost. Figure 2: Initial disparity maps based on different matching costs for Tsukuba. (**a**) Absolute difference in image gradients; (**b**) proposed enhanced image gradients-based matching cost; (**c**) traditional census transform-based matching cost; (**d**) proposed improved census transform-based matching cost. \[C^{\prime}_{i,d}=\sum_{j}W_{ij}C_{j,d} \tag{7}\]  
where \(C_{j,d}\) is the matching cost of pixel \(j\) with disparity \(d\). pixel \(j\) is a neighbor of pixel \(i\). \(W_{ij}\) is the weight coefficient of the pixel \(j\). \(C^{\prime}_{i,d}\) is the aggregated matching cost at pixel \(i\) with disparity \(d\). As an efficient and effective edge-preserving image filter, guided image filter has been successfully adopted in local stereo matching algorithms, achieving commendable disparity maps [23; 33; 34]. After applying guided filter using guidance image \(G\), the kernel \(W_{ij}\) in Equation (7) can be expressed as:  
\[W_{ij}(G)=\frac{1}{|\omega|^{2}}\sum_{k:(i,j)\in\omega_{k}}\left(1+\frac{(G_{i }-\mu_{k})\big{(}G_{j}-\mu_{k}\big{)}}{\sigma_{k}^{2}+\varepsilon}\right) \tag{8}\]  
where \(i\) and \(j\) represent pixel indexes. \(G_{i}\) and \(G_{j}\) are pixel values of guidance image at pixel \(i\) and pixel \(j\). \(\mu_{k}\) and \(\sigma_{k}^{2}\) are the mean and variance of kernel window \(\omega_{k}\) in guided image \(G\), reflecting the statistical characteristics of pixels inside the support window. \(|\omega|\) is the number of pixels in the window \(\omega_{k}\) with a fixed size \(r\times r\). \(\varepsilon\) is a smooth parameter. The matching cost aggregation implicitly assumes that the disparity of the pixels inside the aggregation window are the same, which means that the support window should only contain neighbor pixels that have the same disparity as the center pixel. However, the support window with fixed window size in this traditional guided filter can hardly adapt to objects with different sizes in the scene and guarantee that the pixels inside the window have the same disparity, resulting in inappropriate aggregation results due to pixels with different disparities are involved especially in discontinuous regions. Besides, larger support windows are preferred in textureless regions because more accurate mean value (\(\mu_{k}\)) and variance value (\(\sigma_{k}^{2}\)) can be estimated and thus improve the matching cost aggregation performance. In summary, the fixed size window guided filtering is not suitable for matching cost aggregation of textureless and discontinuous regions. In order to better aggregate matching cost in discontinuous and textureless regions, adaptive shape support window is required. In general, the pixels with similar intensities within a constrained area are more likely captured from the same image structure, and thus have similar disparities. According to this assumption, [PERSON] et al. [19] and [PERSON] et al. [14] proposed to construct cross-based support window.