Why large motions are hard
Lucas–Kanade estimates the motion of a window by minimizing , replacing the image with its tangent plane at the current estimate. The tangent only describes the image over about the size of its structures. If the window moved farther than that, the gradient does not know where it went, and the steps run into the nearest local minimum of . The error surface of level 0 shows this: the dark dip at the true shift is surrounded by others.
A full search would find a large motion, but its cost grows with the square of the search range, and it is limited to the grid. Both problems are solved by looking at the images at a coarser scale first.
The image pyramid
Each level of the pyramid is the previous one, low-pass filtered and subsampled by a factor of 2:
The filter removes the frequencies that the smaller image cannot hold. Without it, fine patterns alias into structures that are not in the scene. Every level has a quarter of the pixels of the one below, so the whole pyramid is only a third larger than the image.
A displacement of pixels at full resolution is only pixels at level . The window keeps its size in pixels, so at level it covers times as much of the scene, and its structures are coarse. Measured in pixels of the full image, the basin of convergence grows by a factor of 2 per level, as the error surfaces show.
Coarse to fine
The estimation starts at the coarsest level with , or with a short full search, which is cheap since the image is small. Its result is passed down to the next finer level, where coordinates are twice as large, as the initial guess:
At every level, a few Lucas–Kanade steps only have to correct the small error of the coarser estimate, which lies well within the basin of convergence, and they add the detail the coarser level could not see. At level 0, the estimate reaches subpixel accuracy. Within each level, both images are smoothed slightly, as in the Lucas–Kanade demo, so that full steps do not overshoot at sharp edges.
Limits
- Objects smaller than a few pixels at the coarsest level disappear there, together with their motion.
- At coarse levels the window covers a large area, and if parts of it move differently, their motions blend. An estimate that is too far off cannot be corrected at the finer levels.
- Too many levels leave only a few pixels at the top, which can no longer determine the motion reliably.
Try this
- Press Play with the defaults: the window moves 13.6 px, about its own size, but only 1.7 px at level 3. Each level corrects the estimate a little, and level 0 ends within a few hundredths of a pixel. Lucas–Kanade on level 0 alone (dashed square and curve) gets stuck 14 px away.
- Compare the error surfaces from left to right: the dark basin around the true shift is wide at the coarse levels and narrow at level 0, where other dips compete. The estimate arriving from level 1 is already inside the narrow basin.
- Set the coarsest level to 0, 1 and 2 and find out how many levels this motion needs. Then make the motion small, e.g. (2, −1), where a single level is enough.
- Turn off low-pass first and choose the text image: the letters break up into speckles at the coarse levels, structure that is not in the scene.
- Set to 4: level 4 has only 10 × 8 pixels and the window shrinks to 7 × 7. Its estimate is several pixels off, but still close enough for the levels below.
- Add noise : the coarse levels average it away, while level 0 sees its full strength and ends less accurate than level 1.
- Change the window radius: a small window at level 0 has many competing minima, but the pyramid still finds the right one.