We present a real-time correlation-based stereo algorithm with improved accuracy. Encouraged by the success of recent stereo algorithms that aggregate the matching cost based on color segmentation, a novel image-gradient-guided cost aggregation scheme is presented in this paper. The new scheme is designed to fit the architecture of recent graphics processing units (GPUs). As a result, our stereo algorithm can run completely on the graphics board: from rectification, matching cost computation, cost aggregation, to the final disparity selection. Compared with many real-time stereo algorithms that use fixed windows, noticeable accuracy improvement has been obtained without sacrificing realtime performance. In addition, existing global optimization algorithms can also benefit from the new cost aggregation scheme. The effectiveness of our approach is demonstrated with several widely used stereo datasets and live data captured from a stereo camera.