Binocular stereo matching is one of the core algorithms in stereo vision. The edge-aware filter-based cost aggregation methods can produce precise disparity maps on the famous Middlebury benchmark (indoor). However, they perform poorly on the KITTI vision benchmark (outdoor) because frontal-parallel surfaces are assumed in the filter-based methods. We propose a new cost aggregation algorithm which discards the frontal-parallel surfaces assumption. The proposed algorithm performs like optimizing an energy function via dynamic programming. The proposed energy function integrates the pairwise smooth energy by the edge-aware filtering approach, which makes the proposed method adapt to slanted surfaces. The proposed algorithm not only outperforms the edge-aware filter-based local methods on the Middlebury benchmark but also performs well on the KITTI vision benchmark.