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,
Expanding the right-hand side to first order gives the optical flow constraint
where and are the measured spatial gradients, the measured temporal gradient, and 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).
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,
with a symmetric matrix, a vector and a scalar, fitted by weighted least squares. If the second frame is the first translated by , its quadratic has the same and a linear coefficient , so
a linear system for the displacement at each pixel. Where the neighbourhood is edge-like, 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:
| Parameter | What it does |
|---|---|
pyr_scale | Scale between pyramid levels (0.5 halves each level) |
levels | Pyramid depth |
winsize | Averaging window over which the displacement is assumed constant |
iterations | Refinement passes per level |
poly_n | Neighbourhood size for the polynomial fit |
poly_sigma | Gaussian 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 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