## 2 Methodology
### Content-Aware Multi-Resolution Disparity Estimation Using Semi-Global Block Matching
#### 2.2.4 Multi-Resolution Multi-Window Disparity Estimation Using SGBM  
**Dynamic Window:** Given that the EI's resolution varies from \(50\times 50\) to around \(400\times 400\), it is necessary to select a range of window sizes. The value of \(W_{\text{min}}\) is selected to be around 5% of the minimum resolution, resulting in an amount of 5. Similarly, the value of \(W_{\text{max}}\) is chosen to be roughly 20% of the resolution, resulting in a value of 80. The size of the window adjusts according to the value of the feature map \(F\). The dynamic window size \(W\) at pixel \((x,y)\) can be calculated by:  
\[W(i,j)=W_{\text{min}}+(W_{\text{max}}-W_{\text{min}})\cdot(1-F_{\text{norm}}(i,j)) \tag{5}\]  
Greater values of \(F_{\text{norm}}\), representing the normalised \(F\) values, will result in the selection of smaller windows for more complicated regions, and vice versa. **Semi-Global Block Matching Disparity:** The disparity is calculated by comparing blocks of pixels along the epipolar line and obtaining the associated vertical displacement, as demonstrated in our previous work [17] (see Figure 8). This problem can be represented by a comprehensive cost function:  
\[E(D)=\sum_{d\in D}\left(C(d)+\sum_{d^{\prime}\in N(d)}P_{1}I_{\{|d-d^{\prime} |=1\}}+\sum_{d^{\prime\prime}\in N(d)}P_{2}I_{\{|d-d^{\prime\prime}|>1\}}\right) \tag{6}\]  
where \(I\) is a function that indicates whether an input is true or false and returns 1 or 0 accordingly. \((d)\) is the chosen disparity's data term similarity metric. A 3D cost structure is used to hold each similarity cost, and this process is repeated for each pixel block, with a cost of \(d\). The 3D structure stack's minimal costs stand for possible disparity estimates. **Disparity Aggregation:** The resulting minimum costs may lack significant distinctiveness, thus resulting in an incorrect assessment of disparity. This issue is addressed by employing cost aggregation within these 3D cost structures. The total cost is determined by aggregating the lowest costs across various image paths. A total of eight paths were utilised in this paper. Potential cost values were pooled, and a weighted summing of these cost possibilities was conducted. The weights were obtained from the normalised feature map \(F_{\text{norm}}\)\((x,y)\), which characterises the contents (texture and edges) at each scale level. The feature map underwent normalisation:  
Figure 8: The produced minimal costs are not highly distinctive, which could result in incorrect disparity estimation [17]. \[F_{\text{norm}}\left(x,y\right)=\frac{F(x,y)}{\sum_{L}F_{L}(x,y)} \tag{7}\]  
The function \(F_{\text{norm}}\) represents the normalised feature for pixels \((x,y)\), whereas \(L\) is the scale level. Normalising the feature map guarantees that, throughout the content-aware analysis, disparities from all resolutions contribute proportionally. Thus, the final content-aware disparity map \(D_{\text{final}}\) can be represented as:  
\[D_{\text{final}}\left(x,y\right)=\sum_{i}\left(\frac{F_{i}(x,y)}{\sum_{j}F_{j }(x,y)}\right)\cdot D_{L}(x,y) \tag{8}\]  
where \(D_{L}\) is the disparity optimised at each level of resolution. To achieve greater accuracy, a higher weight is assigned to the original scale, since this method is still sensitive to multiple scales:  
\[ \begin{split} D_{\text{final}}(x,y)=&\left(\frac{ \alpha\cdot F_{L_{0}}(x,y)}{\sum_{j}F_{j}(x,y)+(\alpha-1)\cdot F_{L_{0}}(x,y)} \right)\cdot D_{L_{0}}(x,y)\\ &+\sum_{i\
eq L_{0}}\left(\frac{F_{i}(x,y)}{\sum_{j}F_{j}(x,y)+( \alpha-1)\cdot F_{L_{0}}(x,y)}\right)\cdot D_{L}(x,y)\end{split}  \tag{9}\]  
The expression \(\sum_{j}F_{j}(x,y)+(\alpha-1)\cdot F_{L_{0}}(x,y)\) ensures normalisation for assigning a larger weight to \(F_{L_{0}}\), where \(F_{L_{0}}\) represents the feature map at the original level and \(\alpha\) is the weighting factor. Penalty terms \(P_{1}\) and \(P_{2}\) are introduced, which are based on the difference in neighbourhood disparities, where \(N(d)\) is the neighbour of \(d\).