Misplaced Pages

Kanade–Lucas–Tomasi feature tracker

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
(Redirected from Kanade–Lucas–Tomasi Feature Tracker)

In computer vision, the Kanade–Lucas–Tomasi (KLT) feature tracker is an approach to feature extraction. It is proposed mainly for the purpose of dealing with the problem that traditional image registration techniques are generally costly. KLT makes use of spatial intensity information to direct the search for the position that yields the best match. It is faster than traditional techniques for examining far fewer potential matches between the images.

The registration problem

The traditional image registration problem can be characterized as follows: Given two functions F ( x ) {\displaystyle F(x)} and G ( x ) {\displaystyle G(x)} , representing pixel values at each location x {\displaystyle x} in two images, respectively, where x {\displaystyle x} is a vector. We wish to find the disparity vector h {\displaystyle h} that minimizes some measure of the difference between F ( x + h ) {\displaystyle F(x+h)} and G ( x ) {\displaystyle G(x)} , for x {\displaystyle x} in some region of interest R {\displaystyle R} .

Some measures of the difference between F ( x + h ) {\displaystyle F(x+h)} and G ( x ) {\displaystyle G(x)} :

  • L1 norm: x R | F ( x + h ) G ( x ) | {\displaystyle \sum _{x\in R}\left\vert F(x+h)-G(x)\right\vert }
  • L2 norm: x R [ F ( x + h ) G ( x ) ] 2 {\displaystyle {\sqrt {\sum _{x\in R}\left^{2}}}}
  • Negative of normalized correlation: x R F ( x + h ) G ( x ) x R F ( x + h ) 2 x R G ( x ) 2 {\displaystyle {\dfrac {-\sum _{x\in R}F(x+h)G(x)}{{\sqrt {\sum _{x\in R}F(x+h)^{2}}}{\sqrt {\sum _{x\in R}G(x)^{2}}}}}}

Basic description of the registration algorithm

The KLT feature tracker is based on two papers:

In the first paper, Lucas and Kanade developed the idea of a local search using gradients weighted by an approximation to the second derivative of the image.

One-dimensional case

If h {\displaystyle h} is the displacement between two images F ( x ) {\displaystyle F(x)} and G ( x ) = F ( x + h ) {\displaystyle G(x)=F(x+h)} then the approximation is made that

F ( x ) F ( x + h ) F ( x ) h = G ( x ) F ( x ) h {\displaystyle F'(x)\approx {\dfrac {F(x+h)-F(x)}{h}}={\dfrac {G(x)-F(x)}{h}}\,}

so that

h G ( x ) F ( x ) F ( x ) {\displaystyle h\approx {\dfrac {G(x)-F(x)}{F'(x)}}\,}

This approximation to the gradient of the image is only accurate if the displacement of the local area between the two images to be registered is not too large. The approximation to h {\displaystyle h} depends on x {\displaystyle x} . For combining the various estimates of h {\displaystyle h} at various values of x {\displaystyle x} , it is natural to average them:

h x G ( x ) F ( x ) F ( x ) x 1 . {\displaystyle h\approx {\dfrac {\sum _{x}{\dfrac {G(x)-F(x)}{F'(x)}}}{\sum _{x}1}}.}

The average can be further improved by weighting the contribution of each term to it, which is inversely proportional to an estimate of | F ( x ) | {\displaystyle \left\vert F''(x)\right\vert } , where

F ( x ) G ( x ) F ( x ) h . {\displaystyle F''(x)\approx {\dfrac {G'(x)-F'(x)}{h}}.}

For the purpose of facilitating the expression, a weighting function is defined:

w ( x ) = 1 | G ( x ) F ( x ) | . {\displaystyle w(x)={\dfrac {1}{\left\vert G'(x)-F'(x)\right\vert }}.}

The average with weighting is thereby:

h = x w ( x ) [ G ( x ) F ( x ) ] F ( x ) x w ( x ) . {\displaystyle h={\dfrac {\sum _{x}{\dfrac {w(x)\left}{F'(x)}}}{\sum _{x}w(x)}}.}

Upon obtaining the estimate F ( x ) {\displaystyle F(x)} can be moved by the estimate of h {\displaystyle h} . The procedure is applied repeatedly, yielding a type of Newton–Raphson iteration. The sequence of estimates will ideally converge to the best h {\displaystyle h} . The iteration can be expressed by

{ h 0 = 0 h k + 1 = h k + x w ( x ) [ G ( x ) F ( x + h k ) ] F ( x + h k ) x w ( x ) {\displaystyle {\begin{cases}h_{0}=0\\h_{k+1}=h_{k}+{\dfrac {\sum _{x}{\dfrac {w(x)\left}{F'(x+h_{k})}}}{\sum _{x}w(x)}}\end{cases}}}

An alternative derivation

The derivation above cannot be generalized well to two dimensions for the 2-D linear approximation occurs differently. This can be corrected by applying the linear approximation in the form:

F ( x + h ) F ( x ) + h F ( x ) , {\displaystyle F(x+h)\approx F(x)+hF'(x),}

to find the h {\displaystyle h} which minimizes the L2 norm measure of the difference (or error) between the curves, where the error can be expressed as:

E = x [ F ( x + h ) G ( x ) ] 2 . {\displaystyle E=\sum _{x}\left^{2}.}

To minimize the error with respect to h {\displaystyle h} , partially differentiate E {\displaystyle E} and set it to zero:

0 = E h h x [ F ( x ) + h F ( x ) G ( x ) ] 2 = x 2 F ( x ) [ F ( x ) + h F ( x ) G ( x ) ] , {\displaystyle {\begin{aligned}0={\dfrac {\partial E}{\partial h}}&\approx {\dfrac {\partial }{\partial h}}\sum _{x}\left^{2}\\&=\sum _{x}2F'(x)\left,\end{aligned}}} h x F ( x ) [ G ( x ) F ( x ) ] x F ( x ) 2 {\displaystyle \Rightarrow h\approx {\dfrac {\sum _{x}F'(x)}{\sum _{x}F'(x)^{2}}}\,}

This is basically the same as the 1-D case, except for the fact that the weighting function w ( x ) = F ( x ) 2 . {\displaystyle w(x)=F'(x)^{2}.} And the iteration form with weighting can be expressed as:

{ h 0 = 0 h k + 1 = h k + x w ( x ) F ( x + h k ) [ G ( x ) F ( x + h k ) ] x w ( x ) F ( x + h k ) 2 {\displaystyle {\begin{cases}h_{0}=0\\h_{k+1}=h_{k}+{\dfrac {\sum _{x}w(x)F'(x+h_{k})\left}{\sum _{x}w(x)F'(x+h_{k})^{2}}}\end{cases}}}

Performance

To evaluate the performance of the algorithm, we are naturally curious about under what conditions and how fast the sequence of h k {\displaystyle h_{k}} 's converges to the real h {\displaystyle h} .

Consider the case:

F ( x ) = sin x , G ( x ) = F ( x + h ) = sin ( x + h ) . {\displaystyle {\begin{aligned}F(x)&=\sin x,\\G(x)&=F(x+h)=\sin(x+h).\end{aligned}}}

Both versions of the registration algorithm will converge to the correct h {\displaystyle h} for | h | < π {\displaystyle \left\vert h\right\vert <\pi } , i.e. for initial misregistrations as large as one-half wavelength. The range of convergence can be improved by suppressing high spatial frequencies in the image, which could be achieved by smoothing the image, that will also undesirably suppress small details of it. If the window of smoothing is much larger than the size of the object being matched, the object may be suppressed entirely, so that a match would be no longer possible.

Since lowpass-filtered images can be sampled at lower resolution with no loss of information, a coarse-to-fine strategy is adopted. A low-resolution smoothed version of the image can be used to obtain an approximate match. Applying the algorithm to higher resolution images will refine the match obtained at lower resolution.

As smoothing extends the range of convergence, the weighting function improves the accuracy of approximation, speeding up the convergence. Without weighting, the calculated displacement h 1 {\displaystyle h_{1}} of the first iteration with F ( x ) = sin x {\displaystyle F(x)=\sin x} falls off to zero as the displacement approaches one-half wavelength.

Implementation

The implementation requires the calculation of the weighted sums of the quantities F G , {\displaystyle F'G,} F F , {\displaystyle F'F,} and ( F ) 2 {\displaystyle (F')^{2}} over the region of interest R . {\displaystyle R.} Although F ( x ) {\displaystyle F'(x)} cannot be calculated exactly, it can be estimated by:

F ( x ) F ( x + Δ x ) F ( x ) Δ x , {\displaystyle F'(x)\approx {\dfrac {F(x+\Delta x)-F(x)}{\Delta x}},}

where Δ x {\displaystyle \Delta x} is chosen appropriately small.

Some sophisticated technique can be used for estimating the first derivatives, but in general such techniques are equivalent to first smoothing the function, and then taking the difference.

Generalization to multiple dimensions

The registration algorithm for 1-D and 2-D can be generalized to more dimensions. To do so, we try to minimize the L2 norm measure of error:

E = x R [ F ( x + h ) G ( x ) ] 2 , {\displaystyle E=\sum _{\mathbf {x} \in R}\left^{2},}

where x {\displaystyle \mathbf {x} } and h {\displaystyle \mathbf {h} } are n-dimensional row vectors.

A linear approximation analogous:

F ( x + h ) F ( x ) + h ( x F ( x ) ) T . {\displaystyle F(\mathbf {x} +\mathbf {h} )\approx F(\mathbf {x} )+\mathbf {h} \left({\dfrac {\partial }{\partial \mathbf {x} }}F(\mathbf {x} )\right)^{T}.}

And partially differentiate E {\displaystyle E} with respect to h {\displaystyle \mathbf {h} } :

0 = E h h x [ F ( x ) + h ( F x ) T G ( x ) ] 2 = x 2 [ F ( x ) + h ( F x ) T G ( x ) ] ( F x ) , {\displaystyle {\begin{aligned}0={\dfrac {\partial E}{\partial \mathbf {h} }}&\approx {\dfrac {\partial }{\partial \mathbf {h} }}\sum _{\mathbf {x} }\left^{2}\\&=\sum _{\mathbf {x} }2\left\left({\dfrac {\partial F}{\partial \mathbf {x} }}\right),\end{aligned}}} h [ x [ G ( x ) F ( x ) ] ( F x ) ] [ x ( F x ) T ( F x ) ] 1 , {\displaystyle \Rightarrow \mathbf {h} \approx \left\left({\dfrac {\partial F}{\partial \mathbf {x} }}\right)\right]\left^{-1},}

which has much the same form as the 1-D version.

Further generalizations

The method can also be extended to take into account registration based on more complex transformations, such as rotation, scaling, and shearing, by considering

G ( x ) = F ( A x + h ) , {\displaystyle G(x)=F(Ax+h),}

where A {\displaystyle A} is a linear spatial transform. The error to be minimized is then

E = x [ F ( A x + h ) G ( x ) ] 2 . {\displaystyle E=\sum _{x}\left^{2}.}

To determine the amount Δ A {\displaystyle \Delta A} to adjust A {\displaystyle A} and Δ h {\displaystyle \Delta h} to adjust h {\displaystyle h} , again, use the linear approximation:

F ( x ( A + Δ A ) + ( h + Δ h ) ) F ( A x + h ) + ( Δ A x + Δ h ) x F ( x ) . {\displaystyle F(x(A+\Delta A)+(h+\Delta h))\approx F(Ax+h)+(\Delta Ax+\Delta h){\dfrac {\partial }{\partial x}}F(x).}

The approximation can be used similarly to find the error expression, which becomes quadratic in the quantities to be minimized with respect to. After figuring out the error expression, differentiate it with respect to the quantities to be minimized and set the results zero, yielding a set of linear equations, then solve them.

A further generalization is designed for accounting for the fact that the brightness may be different in the two views, due to the difference of the viewpoints of the cameras or to differences in the processing of the two images. Assume the difference as linear transformation:

F ( x ) = α G ( x ) + β , {\displaystyle F(x)=\alpha G(x)+\beta ,}

where α {\displaystyle \alpha } represents a contrast adjustment and β {\displaystyle \beta } represents a brightness adjustment.

Combining this expression with the general linear transformation registration problem:

E = x [ F ( A x + h ) ( α G ( x ) + β ) ] 2 {\displaystyle E=\sum _{x}\left^{2}}

as the quantity to minimize with respect to α , {\displaystyle \alpha ,} β , {\displaystyle \beta ,} A , {\displaystyle A,} and h . {\displaystyle h.}

Detection and tracking of point features

In the second paper Tomasi and Kanade used the same basic method for finding the registration due to the translation but improved the technique by tracking features that are suitable for the tracking algorithm. The proposed features would be selected if both the eigenvalues of the gradient matrix were larger than some threshold.

By a very similar derivation, the problem is formulated as

d = e {\displaystyle \nabla d=e}

where {\displaystyle \nabla } is the gradient. This is the same as the last formula of Lucas–Kanade above. A local patch is considered a good feature to track if both of the two eigenvalues ( λ 1 {\displaystyle \lambda _{1}} and λ 2 {\displaystyle \lambda _{2}} ) of {\displaystyle \nabla } are larger than a threshold.

A tracking method based on these two papers is generally considered a KLT tracker.

Improvements and variations

In a third paper, Shi and Tomasi proposed an additional stage of verifying that features were tracked correctly.

An affine transformation is fit between the image of the currently tracked feature and its image from a non-consecutive previous frame. If the affine compensated image is too dissimilar the feature is dropped.

The reasoning is that between consecutive frames a translation is a sufficient model for tracking but due to more complex motion, perspective effects, etc. a more complex model is required when frames are further apart.

Using a similar derivation as for the KLT, Shi and Tomasi showed that the search can be performed using the formula

T z = a {\displaystyle Tz=a}

where T {\displaystyle T} is a matrix of gradients, z {\displaystyle z} is a vector of affine coefficients and a {\displaystyle a} is an error vector. Compare this to d = e {\displaystyle \nabla d=e} .

References

  1. Bruce D. Lucas and Takeo Kanade. An Iterative Image Registration Technique with an Application to Stereo Vision. International Joint Conference on Artificial Intelligence, pages 674–679, 1981.
  2. Carlo Tomasi and Takeo Kanade. Detection and Tracking of Point Features. Carnegie Mellon University Technical Report CMU-CS-91-132, April 1991.
  3. Jianbo Shi and Carlo Tomasi. Good Features to Track. IEEE Conference on Computer Vision and Pattern Recognition, pages 593–600, 1994.

See also

Category: