## 2 Methods
### Matching Cost Computation  
In this step, cost volume is built by computing per-pixel matching cost at all given disparity values under consideration. This cost volume is a three-dimensional array with a size of \(H\times W\times D\), and \(H\), \(W\) and \(D\) denote the height, width and disparity range of the images respectively. Although absolute difference on intensity or color channels is very simple and fast, it is too sensitive to radiometric differences and noises. Stereo matching methods using absolute difference on intensity or color have lots of errors on the disparity maps especially for outdoor images, in which radiometric changes and noises are unavoidable. By contrast, gradient similarity [29] and census transform [30] are more robust to radiometric distortion. To make the matching cost more robust to radiometric changes and noises, we propose a matching cost function that combines the enhanced image gradient-based cost with improved census transform-based cost. In order to obtain stronger edge information, an image enhancement algorithm is first applied to the input stereo images. Here, the input images are first enhanced using Contrast Limited Adaptive Histogram Equalization (CLAHE) algorithm [31]. Then the sum of absolute derivative differences of the left and right enhanced images in the \(x\) and \(y\) directions is used as a gradient-based cost measure. The enhanced image gradient-based matching cost \(\mathcal{C}_{GRAD}^{CLAHE}(p,d)\) is computed according to Equation (1):  
\[\mathcal{C}_{GRAD}^{CLAHE}(p,d)=\left|\
abla_{x}I_{L}(p)-\
abla_{x}I_{R}(p-d) \right|+\left|\
abla_{y}I_{L}(p)-\
abla_{y}I_{R}(p-d)\right| \tag{1}\]  
Figure 1: The workflow of the proposed method. where \(I_{L}\) represents the enhanced left image and \(I_{R}\) represents the enhanced right image. \(\
abla_{x}I_{L}(p)\) and \(\
abla_{y}I_{L}(p)\) denote the gradients in \(x\) and \(y\) direction of the enhanced left image at a pixel \(p\). Accordingly, \(\
abla_{x}I_{R}(p-d)\) and \(\
abla_{y}I_{R}(p-d)\) denote the gradients in \(x\) and \(y\) direction of the enhanced right image at the pixel \(p-d\). \(d\) is the disparity. Besides the gradients-based cost, the census transform-based cost is also computed using the enhanced left and right images. The original census transform is based on local intensity relations between the center pixel and its neighbor pixels. It only relies on the relative ordering of intensities and not their values, and thus it compensates for all radiometric distortions that preserving this ordering. However, [PERSON] et al. [14] has displayed that the traditional census transform would produce wrong matches in regions with repetitive local structures in stereo matching. To address the limitations of traditional census transform, we present an improved census transform using gradients rather than intensity itself. The improved census transform in this paper is formulated as follows:  
\[CTg(p)=\otimes_{q\in N(p)}\xi\Big{(}\big{|}\
abla I(p)\big{|},\big{|}\
abla I (q)\big{|}\Big{)} \tag{2}\]  
\[\xi(p,q)=\left\{ \begin{array}{ll}1,&q<p\\ 0,&\text{otherwise}\end{array} \right. \tag{3}\]  
where operator \(\otimes\) denotes a bit-wise catenation and \(N(p)\) represents the neighbor pixels of anchor pixel \(p\). \(q\) is a neighbor of \(p\). \(\
abla I(p)\) and \(\
abla I(q)\) are the gradient of enhanced images at pixel \(p\) and neighbor pixel \(q\). \(\mid\mid\) means the magnitude of gradient. \(\xi\) is a function to determine the bit value as described in Equation (3). Then the Hamming distance is used to calculate the difference between the two bit-strings in left and right images and used as the improved Census transform-based matching cost. \[C_{CTg}(p,d)=\text{Hamming}(CTg_{L}(p),CTg_{R}(p-d)) \tag{4}\]  
In Equation (4), \(CTg_{L}\) and \(CTg_{R}\) are the Census transform bit strings of pixel \(p\) and \(p-d\) in the left image and right image respectively, and \(d\) denotes the disparity of two pixels in the left and right images.