Computer Vision for Remote SensingPart 3 of 3Intermediate · Updated July 31, 2026

Farnebäck Optical Flow

Optical flow estimates a displacement vector at every pixel between two frames. Local image data determine only part of that motion, so every method adds an assumption.

Brightness constancy gives one equation for two unknowns

If a patch of image keeps its brightness as it moves,

I(x,y,t)=I(x+Δx,  y+Δy,  t+Δt).I(x, y, t) = I(x + \Delta x,\; y + \Delta y,\; t + \Delta t).

Expanding the right-hand side to first order gives the optical flow constraint

Ixu+Iyv+It=0,I_x u + I_y v + I_t = 0,

where IxI_x and IyI_y are the measured spatial gradients, ItI_t the measured temporal gradient, and (u,v)(u, v) the unknown flow. Each pixel provides one equation for two unknowns.

Only the motion across an edge is observable

The constraint determines only the component of motion along the image gradient, perpendicular to an edge. Motion along the edge leaves the brightness unchanged and cannot be detected. Through a small window, a straight edge moving diagonally and one moving straight across look identical if their normal components agree. This is the aperture problem, a failure of uniqueness in Hadamard’s sense: the data are consistent with a one-parameter family of motions. A corner, where two edge orientations meet, constrains both components (Figure 1).

A straight edgethree motions, one appearance— normal component (recoverable)— true motion (unknowable here)A cornertwo orientations pin it down— unique solutionbrightness constancy: 1 equation, 2 unknowns
Figure 1.Left: a straight edge seen through an aperture under three true motions that look identical because they share a normal component. Right: a corner inside the aperture, where two edge orientations constrain both components and the solution is unique.
Directions matching one observation: 11Observed normal component: 1.00
Figure 2.Normal and tangential components of motion as the true direction sweeps a full circle. The tangential component varies freely while the normal component, the only part a local window measures, repeats, so distinct true directions give the same observation. Changing the edge orientation rotates the whole relationship.

Dense flow methods differ in how they resolve this ambiguity. Lucas–Kanade assumes constant flow over a small window, Horn–Schunck adds a global smoothness penalty, and learned methods take the assumption from training data. Farnebäck’s method models the local image signal as a quadratic and solves for the displacement in closed form.

A local quadratic gives the displacement in closed form

The neighbourhood of each pixel is approximated by a quadratic,

f(x)≈x⊤Ax+b⊤x+c,f(\mathbf{x}) \approx \mathbf{x}^{\top} A \mathbf{x} + \mathbf{b}^{\top} \mathbf{x} + c,

with AA a symmetric 2×22 \times 2 matrix, b\mathbf{b} a vector and cc a scalar, fitted by weighted least squares. If the second frame is the first translated by d\mathbf{d}, its quadratic has the same AA and a linear coefficient b2=b1−2Ad\mathbf{b}_2 = \mathbf{b}_1 - 2A\mathbf{d}, so

Ad=−12(b2−b1),A \mathbf{d} = -\tfrac{1}{2} (\mathbf{b}_2 - \mathbf{b}_1),

a 2×22 \times 2 linear system for the displacement at each pixel. Where the neighbourhood is edge-like, AA is nearly singular, which is the aperture problem appearing in the algebra. The method therefore assumes the displacement varies slowly and solves the system in the least-squares sense over a window around each pixel, which constrains both components wherever the window contains more than one edge orientation.

A pyramid extends the method to large displacements

The quadratic model is accurate only for displacements small relative to the neighbourhood. Larger motion is handled with an image pyramid: flow is estimated on a heavily downsampled image, where the displacement is a few pixels, then upsampled, used to warp the next finer level, and refined.

Example: correcting wind-advected contrail masks

Suppose contrail pixels in a satellite frame have been advected forward by numerical weather prediction winds. The advection places each contrail approximately, and the remaining error is small and spatially smooth, which Farnebäck flow can estimate and correct.

The method’s main parameters, as exposed in OpenCV’s implementation:

ParameterWhat it does
pyr_scaleScale between pyramid levels (0.5 halves each level)
levelsPyramid depth
winsizeAveraging window over which the displacement is assumed constant
iterationsRefinement passes per level
poly_nNeighbourhood size for the polynomial fit
poly_sigmaGaussian weighting for that fit

For natural video, winsize is typically a modest value, on the order of ten to twenty pixels (OpenCV’s own example uses 15). For a residual like this one, a much larger window can be appropriate, because the quantity estimated is a slow, large-scale correction rather than sharp local motion; heavy averaging suppresses noise from the binary mask and imposes the smoothness expected of wind error. Capping the displacement magnitude is a common safeguard against a spurious match producing an outlying vector.

Assumptions and failure modes

The method assumes brightness constancy, a locally quadratic signal and a displacement field that varies slowly over the averaging window. It loses accuracy for large, sharp or discontinuous motion, at occlusions, and where the window contains only one edge orientation. For a residual-correction problem like the one above the assumptions hold, and the difficulties of the approaches in the two previous tutorials do not arise:

  • No correspondences. Unlike ICP, dense flow estimates a displacement per location, so a deforming scene is represented directly.
  • No training data. No labelled flow is needed, and no training objective can favour background cloud motion, the objective mismatch seen with RAFT.
  • Deterministic and inexpensive. A handful of interpretable parameters, reproducible output, and a CPU cost modest enough to keep pace with frequently refreshed satellite imagery over large scenes.

Summary

  • Brightness constancy gives one equation per pixel for two unknowns; motion along an edge is unobservable (the aperture problem).
  • Farnebäck’s method fits a quadratic to each neighbourhood and solves a 2×22 \times 2 linear system for the displacement, averaged over a window and refined over a pyramid.
  • It suits small, smooth residual motion on sparse inputs, such as the correction after wind advection of contrail masks, without correspondences or training data.

References

  • Farnebäck, G. (2003). Two-frame motion estimation based on polynomial expansion. In Image Analysis: 13th Scandinavian Conference, SCIA 2003, 363–370. doi:10.1007/3-540-45103-X_50
  • Horn, B. K. P., & Schunck, B. G. (1981). Determining optical flow. Artificial Intelligence, 17(1–3), 185–203. doi:10.1016/0004-3702(81)90024-2
  • Lucas, B. D., & Kanade, T. (1981). An iterative image registration technique with an application to stereo vision. In Proceedings of the 7th International Joint Conference on Artificial Intelligence (IJCAI), 674–679. ijcai.org
  • Barron, J. L., Fleet, D. J., & Beauchemin, S. S. (1994). Performance of optical flow techniques. International Journal of Computer Vision, 12(1), 43–77. doi:10.1007/BF01420984