Stereo matching is a challenging task due to stereo images being affected by many factors such as radiometric distortion, sun and rain flare, flying snow, occlusion and object boundaries. However, most of the existing stereo matching methods assume that corresponding pixels in left and right images have the same intensity; accordingly, the stereo matching methods use simple matching cost functions. As a result, they degrade their performance significantly when operating with real-world stereo images whose intensities of corresponding pixels can be arbitrarily transformed. State-of-the-art matching cost functions under conditions of distorted intensities between stereo images, such as the census transform, adaptive normalized cross-correlation, and the support local binary pattern perform with limited accuracy. In this paper, we propose a novel matching cost function based on a robust order statistic coefficient and segmentation that can operate accurately under various conditions of transformed intensities between stereo images. Based on the robust order statistic coefficient, the proposed matching cost function can tolerate local, monotonically nonlinear changes in intensities between the left and right images. By using the information of segmentation, the matching cost function operates accurately at object boundaries. The qualitative and quantitative experimental results obtained using stereo images in different datasets under various conditions show that our proposed matching cost function outperforms state-of-the-art matching cost functions in indoor and outdoor stereo images with various radiometric distortions.