Near real-time stereo based on effective cost aggregation is a local matching algorithm, it can achieve good accuracy and meet near real-time requirements. However, addition of supplementary window cost function in this method makes the edges of objects lose some precision. This paper proposes a novel stereo matching algorithm, whose aggregation strategies rely on segmentation. It can improve the matching accuracy and computational efficiency. First, dividing the left image into segments of homogeneous color with assume that disparity inside segments varies smoothly, then using the segmented image block as the matching window to search similar region in the right image. Second, the existing matching cost function includes segmentation window function and supplementary window cost function, former one tends to assign the same disparity value to all points belonging to the same segment, the latter reduces the dependence of the center pixel point on segmentation block in the high texture area and more dependent on pixels in neighborhood. However, this function makes the edges of objects lose some precision. Therefore, this paper proposes an adaptive supplementary window cost function using the image segmentation block size as adaptive parameter for added window, this function can not only solve mismatching in the high texture regions but also improve the precision at the edges of the objects. The experimental results demonstrate that our method shows the capabilities to improve the accuracy of fast local methods and can be regarded as an interesting trade-off between accuracy and speed, especially in regions of high texture and close to boundaries.