# Estimation of Wind Turbine Blade Icing Volume Based on Binocular Vision
## 2 Principle and Method
### Stereo Matching
#### 2.1.2 Cross-Based Cost Aggregation  
Cost aggregation plays a crucial role in stereo matching and image processing by smoothing matching costs, reducing the influence of noise, and enhancing the stability and robustness of the matching process. It is particularly important in scenarios involving illumination changes, occlusions, and viewpoint differences. Cost aggregation can smooth disparity maps, reduce jagged effects and discontinuities, and improve matching performance in low-texture regions, thereby achieving higher-quality disparity estimations. In this paper, we adopt the improved cross-based region method from reference [24] for cost aggregation, where the construction rules for the cross arms are defined as:  
1. \(D_{c}(p_{1},p)<\tau_{1}\) and \(D_{c}(p_{1},p_{1}+(1,0))<\tau_{1}\);
2. \(D_{s}(p_{1},p)<L_{1}\);
3. \(D_{c}(p_{1},p)<\tau_{2}\), when \(L_{2}<D_{s}(p_{1},p)<L_{1}\). Rule 1 ensures that the color difference between pixels \(p_{1}\) and \(p\) is less than the threshold \(\tau_{1}\), while also limiting the color difference between \(p_{1}\) and its forward pixel \(p_{1}+(1,0)\) to be less than \(\tau_{1}\). This prevents the cross arm from crossing edge pixels. Rules 2 and 3 provide more flexible control by introducing a larger threshold \(L_{1}\), allowing more pixels to be included in weakly textured regions. When the color difference exceeds a smaller threshold \(L_{2}\) (\(L_{2}<L_{1}\)), the cross arm only extends to points with significantly smaller color differences, ensuring it does not extend beyond \(L_{1}\). After successfully constructing the cross arms, the support region of pixel \(p\) is formed by merging the horizontal arms of all pixels on its vertical arm, as shown in Figure 6.  
Once the support region of pixel \(p\) has been constructed, a two-pass cost aggregation can be performed:  
Pass 1: For all pixels, sum the cost values of the pixels on their horizontal arms and store them as temporary values. Pass 2: For all pixels, sum the temporary values stored in the first step for the pixels on their vertical arms to obtain the final aggregated cost value for that pixel. To keep the aggregated value within a small and controllable range, the final aggregated cost value needs to be divided by the total number of pixels in the support region, as illustrated in Figure 7.  
To further enhance the accuracy of cost aggregation and reduce matching errors, a unidirectional dynamic programming cost aggregation algorithm is introduced. This algorithm optimizes along eight directions: left, right, up, down, upper right, lower right, upper left. The path cost for pixel \(p\) along a certain path \(r\) is defined as:  
\[L_{r}(p,d)=\ C(p,d)+\min\left\{ \begin{array}{l}L_{r}(p-r,d)\\ L_{r}(p-r,d-1)+P_{1}\\ L_{r}(p-r,d+1)+P_{1}\\ \min_{t}L_{r}(p-r,t)+P_{2}\end{array} \right\}-\min_{t}L_{r}(p-r,t) \tag{11}\]This formula calculates the aggregated cost of pixel \(p\) at disparity \(d\), incorporating penalty terms \(P_{1}\) and \(P_{2}\) for disparity changes. Here, \(P_{1}\) penalizes small disparity variations, while \(P_{2}\) controls larger disparity jumps. The subtraction of \(\underset{t}{\min}\ L_{r}(p-r,t)\) normalizes the current cost relative to the minimum cost of the previous pixel along the path, preventing instability due to excessively large values. The specific rules for setting \(P_{1}\) and \(P_{2}\) are as follows:  
1. \(P_{1}=\Pi_{1}\), \(P_{2}=\Pi_{2}\), if \(D_{1}<\tau_{50}\) and \(D_{2}<\tau_{50}\);
2. \(P_{1}=\Pi_{1}/4\), \(P_{2}=\Pi_{2}/4\), if \(D_{1}<\tau_{50}\) and \(D_{2}>\tau_{50}\);
3. \(P_{1}=\Pi_{1}/4\), \(P_{2}=\Pi_{2}/4\), if \(D_{1}>\tau_{50}\) and \(D_{2}<\tau_{50}\);
4. \(P_{1}=\Pi_{1}/10\), \(P_{2}=\Pi_{2}/10\), if \(D_{1}>\tau_{50}\) and \(D_{2}>\tau_{50}\). In these equations, \(D_{1}\) represents the color difference between pixel \(p\) and its preceding pixel \(p-r\), and \(D_{2}\) represents the color difference between pixel \(p-r\) and its preceding pixel \(p-2r\).