# Improvement of the Cross-Scale Multi-Feature Stereo Matching Algorithm
## 2 Algorithm Description
### Cost Computation  
Cost computation measures the similarity between the corresponding pixels in the left and right images, but it is often influenced by factors such as image noise and illumination variations, which can result in mismatches. Common cost-computation methods include simple measures like absolute difference (AD), census, and normalized cross-correlation (NCC) [12]. The traditional census transform [13], a non-parametric local transform, is widely adopted for matching cost computation. The core idea is as follows: A rectangular window is defined within the image region and slides across the entire image. For each position, it takes the central pixel \(p\) within the window as the reference pixel, then compares the intensity value of \(p\) against those of all neighboring pixels \(q\) in the window. If the intensity value of a neighboring pixel is less than or equal to the reference value, it is assigned a value of 0; otherwise, it is marked as 1. This operation can be formally expressed as:  
\[\delta[I(p),\ I(q)]= \begin{cases}1,\ I(p)\leq I(q)\\ 0,\ I(p)\geq I(q)\end{cases}  \tag{1}\]  
Here, \(p\) denotes the central pixel of the window, \(q\) represents the non-central pixels within the window, and \(I(\cdot)\) indicates the intensity value at a given pixel. \(\delta[I(p),\ I(q)]\) represents the result of census transformation. A binary bit-string of the input image, known as the census transform, is obtained via Equation (1). The census-based matching cost-computation method involves calculating the \(Hamming\) distance [14] between the census transform values of the corresponding pixels in the left and right images, which can be formulated as:  
\[C_{Census}(u,v,d)=Hamming(C_{SR}(u,v),C_{ST}(u-d,v)) \tag{2}\]  
In the equation, \(d\) denotes the disparity value, \(C_{SR}(u,v)\) represents the binary bit-string generated from the left image, \(C_{ST}(u-d,v)\) corresponds to the binary bit-string from the right image, and the \(Hamming\) distance quantifies the number of positions at which the corresponding bits in the two bit-strings differ. In traditional implementations, the census transform constructs a bit-string representation by comparing the intensity of each pixel within a local window against the central pixel's intensity value, as illustrated in Figure 2.  
Figure 1: Flowchart of the proposed algorithm. In challenging environments, however, images are subject to noise and other adverse factors that may induce abrupt intensity variations, as demonstrated in Figure 3.  
When the central pixel's intensity abruptly changes from 121 to 101, the corresponding bit-string transitions from 11,100,000 to 11,111,110, and this drastic numerical variation significantly impacts the matching error. To address the over-reliance on the central pixel in conventional census transform operations (as manifested in bit-string generation), this paper proposes an improved census transform methodology. Based on the continuous and coherent intensity distribution characteristics of local neighborhoods, our method first computes the average intensity within the processing window. A dynamic threshold is then established according to the statistical deviation between individual pixel intensities and this average intensity. When the intensity difference between any pixel and the average exceeds the predefined threshold, the central pixel's intensity is adaptively reassigned to match the computed mean value. As demonstrated in Figure 4, the enhanced census transform employs a predefined threshold of 12. The computed mean intensity within the local window is 112.7. Given the original central pixel intensity of 101, the absolute difference (1112.7 \(-\) 101 \(|\) = 11.7) exceeds the threshold. Consequently, the central pixel intensity is adaptively updated to the mean value (112.7). This adjustment modifies the generated bit-string from 11,111,110 to 11,110,010, thereby significantly improving robustness against abrupt pixel variations caused by adverse environmental conditions.