v9.1.1
Menu

Weighted Depth Fusion

mediumPROMulti-view StereoMVSCV: Depth Estimation

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=∑iwi⋅Zi∑iwiZ_{fused} = \frac{\sum_i w_i \cdot Z_i}{\sum_i w_i}

where:

  • ZiZ_i is the depth estimate from source ii
  • wiw_i is the confidence/weight for that estimate
  • ZfusedZ_{fused} is the final fused depth

Weights typically come from matching confidence, geometric consistency, or photo consistency scores.

Example

Input
fuse_depths([5.0, 5.2, 4.8], [1.0, 0.5, 0.5])
Output
5.0
Reasoning
  • Inputs: depths holds three estimates of the same point's distance, Z=(5.0,5.2,4.8)Z = (5.0, 5.2, 4.8), and weights holds how much each source is trusted, w=(1.0,0.5,0.5)w = (1.0, 0.5, 0.5). Source 1 counts twice as much as each of the others.
  • Numerator: multiply each depth by its weight and add: 5.0⋅1.0+5.2⋅0.5+4.8⋅0.5=5.0+2.6+2.4=10.05.0 \cdot 1.0 + 5.2 \cdot 0.5 + 4.8 \cdot 0.5 = 5.0 + 2.6 + 2.4 = 10.0.
  • Denominator: the total weight, 1.0+0.5+0.5=2.01.0 + 0.5 + 0.5 = 2.0. Dividing by it rescales the weights so they act like fractions summing to 1 (0.5,0.25,0.250.5, 0.25, 0.25).
  • Output: Zfused=10.0/2.0=5.0Z_{fused} = 10.0 / 2.0 = 5.0, a single float rounded to 4 decimal places.
  • Notice: the two low-confidence estimates sit symmetrically around 5.0 (+0.2+0.2 and −0.2-0.2) with equal weight, so they cancel. If the weights were (0.5,1.0,0.5)(0.5, 1.0, 0.5) instead, the result would shift toward 5.2: 10.1/2.0=5.0510.1 / 2.0 = 5.05.

Constraints

  • depths: list of depth values from different sources
  • weights: list of confidence weights (positive values)
  • Return fused depth rounded to 4 decimal places

Learn this in

More from CV: Depth Estimation

PRO

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.

solution.py

Test results

Sign in to run your code against the test cases.