Weighted Depth Fusion
Fuse multiple depth estimates using weighted averaging.
When we have depth estimates from multiple stereo pairs or viewpoints, we can combine them to get a more robust estimate. Weighted averaging gives more influence to confident estimates:
Zfusedβ=βiβwiββiβwiββ Ziββ
where:
- Ziβ is the depth estimate from source i
- wiβ is the confidence/weight for that estimate
- Zfusedβ is the final fused depth
Weights typically come from matching confidence, geometric consistency, or photo consistency scores.
Example:
fuse_depths([5.0, 5.2, 4.8], [1.0, 0.5, 0.5])
5.0
Fusing 3 depth estimates with different weights:
- Weighted sum: 5.0Γ1.0 + 5.2Γ0.5 + 4.8Γ0.5 = 5.0 + 2.6 + 2.4 = 10.0
- Total weight: 1.0 + 0.5 + 0.5 = 2.0
- Fused depth: 10.0 / 2.0 = 5.0
- The high-confidence estimate (5.0) dominates.
Constraints:
- depths: list of depth values from different sources
- weights: list of confidence weights (positive values)
- Return fused depth rounded to 4 decimal places
-
In multi-view stereo, each stereo pair or viewpoint often produces its own depth map with its own confidence or reliability score per pixel (e.g., from matching cost, variance, or probability distribution). These per-view estimates are noisy and may contain outliers due to occlusions, low texture, or specularities. The goal of depth fusion is to combine multiple such estimates into a single, more robust depth value per pixel or 3D point. A simple and widely used way to do this is weighted averaging, where more reliable estimates contribute more to the final depth.
-
Mathematically, if you have depth estimates Ziβ with corresponding weights wiβ, the fused depth is
This is the weighted mean, which is optimal (in the least-squares sense) if each estimate has Gaussian noise with variance proportional to 1/wiβ. In practice, wiβ can come from:
- a confidence score from the stereo matcher,
- inverse of an estimated depth variance,
- photo-consistency measures,
- geometric consistency checks (e.g., reproject to other views and measure agreement).
2. Algorithm / Approach
The general pattern for this problem:
- For each pixel (or 3D point), collect all available depth estimates Ziβ and their weights wiβ.
- Optionally filter or clamp estimates with very low confidence or invalid values.
- Compute the weighted sum of depths and the sum of weights.
- Return the normalized weighted average Z_{\text{fused}}; handle cases where the sum of weights is zero.
This is essentially a per-pixel (or per-point) reduction operation over views.
3. Step-by-Step Strategy
Assume youβre given, for each pixel index p:
- A list/array of depth estimates Z[i] (for views i),
- A corresponding list/array of weights w[i].
Steps:
- Initialize accumulators:
- num = 0.0 (for βiβwiβZiβ)
- den = 0.0 (for βiβwiβ)
- Loop over all sources i:
- If w[i] <= 0 or Z[i] is invalid (NaN, inf, or sentinel value), skip it.
- Optionally cap or normalize weights if they are on very different scales.
- Accumulate:
num += w[i] * Z[i]
den += w[i]
Continue the full explanation
You're reading the free preview. Unlock the complete walkthrough, the code editor, test runner and reference solution with Premium.
Editor locked
The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.