# Estimation of Wind Turbine Blade Icing Volume Based on Binocular Vision
## 2 Principle and Method
### Stereo Matching
#### 2.1.1 Matching Cost Calculation  
The basic principle of the traditional Census transform involves traversing the image with a rectangular window, typically selecting the gray value of the central pixel as the reference. The gray values of all pixels within the window are compared with this reference value, and the size relationships are represented by 0 or 1. Essentially, the Census transform encodes the gray values of an image into a binary bit stream, indicating the relative size relationships of neighboring pixels to the central pixel. The transformation process can be expressed as  
\[I_{\text{\text{\text{\text{\text{\text{\text{\text{\text{\text{\text{\text{ \text{\texttext  
\(I(p)\) is the intensity value of the central pixel; \(I(q)\) is the intensity value of the neighboring pixel; and \(N_{p}\) is the set of pixels in the neighborhood window centered at \(p\). The function \(\xi[I(p),I(q)]\) is defined as:  
\[\xi[I(p),I(q)]= \begin{cases}0,&I(q)\leq I(p)\\ 1,&I(q)>I(p)\end{cases}  \tag{2}\]  
After these calculations, the Census transform codes of each pixel in the left and right images are obtained. Then, by computing the Hamming distance, the matching cost is derived. For any disparity value \(d\) within the disparity search range, the Hamming distance between the Census transform code of pixel \(p\) in the left image and the corresponding pixel \((p-d)\) in the right image is calculated as follows:  
\[C_{\text{cen}}(p,d)=\text{Hamming}(C_{\text{cen,L}}(p),\ C_{\text{cen,R}}(p-d)) \tag{3}\]  
where \(C_{\text{cen}}(p,d)\) represents the Census cost of pixel \(p\) at disparity \(d\); \(C_{\text{cen,L}}(p)\) is the Census transform code of pixel \(p\) in the left image; and \(C_{\text{cen,R}}(p-d)\) is the Census transform code of pixel \((p-d)\) in the right image. The calculation process described above is illustrated in Figure 2.  
The traditional Census transform heavily relies on the gray value of the central pixel and is sensitive to image noise. This sensitivity may lead to mismatches under noisy conditions, reducing matching accuracy. To mitigate mismatches caused by noise and improve the robustness of the algorithm, this paper proposes an improved Census transform for computing the matching cost. First, the image gradient is calculated, and the window size is dynamically adjusted based on the gradient values. In high-gradient regions, smaller windows are used to accurately capture details; in low-gradient regions, larger windows are employed to suppress noise and enhance the stability of feature extraction. The window size is defined as:  
\[\text{windowSize}= \begin{cases}7\times 7,&\text{if }G_{i,j}>T\\ 9\times 9,&\text{if }G_{i,j}\leq T\end{cases}  \tag{4}\]  
where \(G_{i,j}\) is the gradient magnitude at pixel \((i,j)\), and \(T\) is a predefined gradient threshold. Next, the gray values within the window are sorted, the maximum and minimum values are removed, and the mean of the remaining values is calculated. This mean is used as the new central pixel value and reference value, against which the gray values of neighboring pixels in the window are compared. Figure 3 illustrates the limitations of  
Figure 2: Census transformation process. the traditional Census transform and compares it with the proposed improved Census transform. It can be observed that even when the central pixel is disturbed, the improved bit string is less affected. Therefore, the algorithm reduces dependence on the central pixel. To further enhance robustness, we introduce a noise tolerance parameter to the reference value and use two binary bits to represent three states, defined as:  
\[\xi[I(p),I(q)]= \begin{cases}10,&\text{if }I(q)>\overline{I(p)}+\alpha\\ 01,&\text{if }I(q)<\overline{I(p)}-\alpha\\ 00,&\text{otherwise}\end{cases}  \tag{5}\]  
where \(\overline{I(p)}\) is the reference value, and \(\alpha\) is the noise tolerance parameter. As shown in Figure 4, in flat regions, the gray values of neighboring pixels are similar.