introduction to Lucas-Kanade algorithm
- 格式:pdf
- 大小:2.50 MB
- 文档页数:70
前言:最近由于工作的关系,接触到了很多篇以前都没有听说过的经典文章,在感叹这些文章伟大的同时,也顿感自己视野的狭小。
想在网上找找计算机视觉界的经典文章汇总,一直没有找到。
失望之余,我决定自己总结一篇,希望对 CV领域的童鞋们有所帮助。
由于自
己的视野比较狭窄,肯定也有很多疏漏,权当抛砖引玉了
1990年之前
1990年
1991年
1992年
1993年
1994年
1995年
1996年
1997年
1998年
1998年是图像处理和计算机视觉经典文章井喷的一年。
大概从这一年开始,开始有了新的趋势。
由于竞争的加剧,一些好的算法都先发在会议上了,先占个坑,等过一两年之后再扩展到会议上。
1999年
2000年
世纪之交,各种综述都出来了
2001年
2002年
2003年
2004年
2005年
2006年
2007年
2008年
2009年
2010年
2011年
2012年。
lucas-kanade optic flow 原理
Lucas-Kanade光流法是一种用于估计图像中像素或特征点运动的方法。
它的基本原理基于两个连续的图像帧,通过寻找像素或特征点在两个帧之间的位移来估计它们的运动。
这种方法的核心假设是局部亮度恒定,即相邻帧之间的像素亮度不变。
具体来说,Lucas-Kanade光流法的工作流程如下:
1. 首先,在前后两帧图像里分别建立一个固定大小窗口。
这个窗口包含了需要估计运动的像素或特征点及其邻域像素。
2. 然后,算法会找到使两个窗口间像素强度差的平方和最小的位移。
这个位移向量近似地代表了窗口内像素的移动。
3. 接着,算法通过最小化特征点周围邻域内的亮度变化误差来估计这个位移。
这是通过泰勒级数展开亮度变化并求解误差函数的最小值来实现的。
需要注意的是,虽然Lucas-Kanade光流法基于局部亮度恒定假设,但实际上像素的移动可能并不那么简单,窗口内像素也并不都是同样的移动方式。
因此,选择合适的窗口或特征点对于获得精确的运动估计非常重要。
KLT角点检测方法就是为了选择一个适合跟踪的特征点而设计的。
此外,Lucas-Kanade光流法还用于目标检测。
在这个应用中,算法会给图像中的每个像素点赋予一个速度矢量,形成一个运动矢量场。
当图像中有运动物体时,目标和背景之间会存在相对运动,这样就可以通过检测运动矢量来识别出运动目标。
总的来说,Lucas-Kanade光流法是一种基于局部亮度恒定假设的运动估计方法,它通过最小化亮度变化误差来估计像素或特征点的运动。
这种方法在运动分析、目标跟踪和计算机视觉等领域有广泛的应用。
Lucas-Kanade20Years On:A Unifying Framework:Part3 Simon Baker,Ralph Gross,and Iain MatthewsCMU-RI-TR-03-35AbstractSince the Lucas-Kanade algorithm was proposed in1981image alignment has become one of the most widely used techniques in computer vision.Applications range from opticalflow,tracking, and layered motion,to mosaic construction,medical image registration,and face coding.Numer-ous algorithms have been proposed and a variety of extensions have been made to the original formulation.We present an overview of image alignment,describing most of the algorithms in a consistent framework.We concentrate on the inverse compositional algorithm,an efficient al-gorithm that we recently proposed.We examine which of the extensions to the Lucas-Kanade algorithm can be used with the inverse compositional algorithm without any significant loss of efficiency,and which cannot.In this paper,Part3in a series of papers,we cover the extension of image alignment to allow linear appearance variation.Wefirst consider linear appearance varia-tion when the error function is the Euclidean L2norm.We describe three different algorithms,the simultaneous,project out,and normalization inverse compositional algorithms,and empirically compare them.Afterwards we consider the combination of linear appearance variation with the robust error functions described in Part2of this series.Wefirst derive robust versions of the si-multaneous and normalization algorithms.Since both of these algorithms are very inefficient,as in Part2we derive efficient approximations based on spatial coherence.We end with an empirical evaluation of the robust algorithms.Keywords:Image alignment,unifying framework,the Lucas-Kanade algorithm,the inverse com-positional algorithm,linear appearance variation,robust error functions.1IntroductionImage alignment consists of moving,and possibly deforming,a template to minimize the differ-ence between the template and an image.Since itsfirst use in the Lucas-Kanade algorithm[13], image alignment has become one of the most widely used techniques in computer vision.Besides opticalflow,some of its other applications include tracking[5,11],parametric and layered motion estimation[4],mosaic construction[15],medical image registration[6],and face coding[14,7].The usual approach to image alignment is gradient descent.A variety of other numerical al-gorithms have also been proposed[10],but gradient descent is the defacto standard.We propose a unifying framework for image alignment,describing the various algorithms and their extensions in a consistent manner.Throughout the framework we concentrate on the inverse compositional algorithm,an efficient algorithm that we recently proposed[2,3].We examine which of the exten-sions to the Lucas-Kanade algorithm can be applied to the inverse compositional algorithm without any significant loss of efficiency,and which extensions require additional computation.Wherever possible we provide empirical results to illustrate the various algorithms and their extensions.In this paper,Part3in the series,we cover image alignment with linear appearance variation. Linear appearance variation has been considered by a number of authors,most notably by Hager and Belhumeur for illumination[11],by Black and Jepson for general appearance variation[5], and by Cootes and Taylor for non-rigid face modeling[7].As in Part2,we distinguish two cases: (1)when the error function is the Euclidean L2norm(the case that the error function is a general weighted L2norm is similar),and(2)when the error function is a robust error function.We consider the Euclidean case in Section3.Wefirst derive the“simultaneous”inverse com-positional algorithm which,as the name implies,performs a simultaneous optimization over the warp and appearance parameters.We then derive an efficient approximation to the simultaneous inverse compositional algorithm and also describe the extremely efficient“project out”algorithm proposed by Hager and Belhumeur[11].The project out algorithmfirst projects out the appear-ance variation and just solves for the warp parameters.Then in a second step,it solves for theappearance parameters.We study the project out algorithm in the case that the appearance vari-ation contains a“gain”term,show that the step size can be computed incorrectly,and propose a way of correcting the error.We also describe the“normalization”algorithm which attempts to nor-malize the input image so that it has the same appearance component as the template.A variant of the normalization algorithm is frequently used when the appearance variation consists of gain and bias.We end Section3by empirically comparing all three Euclidean algorithms and their variants.We consider the robust case in Section4.Wefirst derive robust versions of the simultaneous and normalization algorithms.Since both of these algorithms are inefficient,as in Part2we derive efficient approximations based on spatial coherence of the outliers.It is not possible to directly generalize the project out algorithm because there is no notion of orthogonality for a robust error function.We end with an empirical evaluation of the robust appearance variation algorithms.2Background:Image Alignment Algorithms2.1The Lucas-Kanade AlgorithmThe original image alignment algorithm was the Lucas-Kanade algorithm[13].The goal of the Lucas-Kanade algorithm is to align a template image to an input image,where is a column vector containing the pixel coordinates.Let denote the parameterized set of allowed warps,where is a vector of parameters.The warp takes the pixel in the template and maps it to the sub-pixel location in the image.2.1.1Goal of the Lucas-Kanade AlgorithmThe goal of the Lucas-Kanade algorithm is to minimize the sum of squared error between two images,the template and the image warped back onto the coordinate frame of the template:(1)Warping back to compute requires interpolating the image at the sub-pixel loca-tions.The minimization in Equation(1)is performed with respect to and the sum is performed over all of the pixels in the template image.Minimizing the expression in Equa-tion(1)is a non-linear optimization task even if is linear in because the pixel values are,in general,non-linear in.In fact,the pixel values are essentially un-related to the pixel coordinates.To optimize the expression in Equation(1),the Lucas-Kanade algorithm assumes that a current estimate of is known and then iteratively solves for increments to the parameters;i.e.the following expression is(approximately)minimized:(2) with respect to,and then the parameters are updated:(3)These two steps are iterated until the estimates of the parameters converge.Typically the test for convergence is whether some norm of the vector is below a threshold;i.e..2.1.2Derivation of the Lucas-Kanade AlgorithmThe Lucas-Kanade algorithm(which is a Gauss-Newton gradient descent non-linear optimization algorithm)is then derived as follows.The non-linear expression in Equation(2)is linearized by performing afirst order Taylor expansion on to give:advantage that the chain rule results in a matrix multiplication,as in Equation(4).)The term(5)Equation(4)is a least squares problem and has a closed from solution which can be derived as follows.The partial derivative of the expression in Equation(4)with respect to is:(6) Then denote:at,they both depend on.In general,therefore,both the steepest-descent images and the Hessian must be recomputed in every iteration of the algorithm.See Figure1.Assume that the number of warp parameters is and the number of pixels in is.The total computational cost of each iteration of the Lucas-Kanade algorithm is.The most expensive step by far is Step6.See Table1for a summary and[3]for the details.The Lucas-Kanade AlgorithmIterate:(1)Warp with to compute(2)Compute the error image using Equation(10)(3)Warp the gradient with(4)Evaluate the Jacobianmust be evaluated at,all9steps must be repeated in every iteration of the algorithm.Table1:The computation cost of one iteration of the Lucas-Kanade algorithm.If is the number of warp parameters and is the number of pixels in the template,the cost of each iteration is.The most expensive step by far is Step6,the computation of the Hessian,which alone takes time.Step1Step3Step5Step7Step9Totalwith respect to and then updates the warp:(12) The expression:(13) is the composition of2warps and the expression is the inverse of.The Lucas-Kanade algorithm iteratively applies Equations(2)and(3).The inverse composi-tional algorithm iteratively applies Equations(11)and(12).Perhaps somewhat surprisingly,these two algorithms can be shown to be equivalent tofirst order in.They take(approximately)the same steps as they minimize the expression in Equation(1).See[3]for the proof of equivalence.2.2.2Derivation of the Inverse Compositional AlgorithmPerforming afirst order Taylor expansion on Equation(11)gives:(16)is the Hessian matrix computed using the new steepest-descent images:(17)The Inverse Compositional AlgorithmPre-compute:(3)Evaluate the gradient of the template(4)Evaluate the Jacobianis evaluated at.Since there is nothing in either the steepest-descent im-ages or the Hessian that depends on,they can both be pre-computed.The inverse compositional algorithm is summarized in Figure2.(See[1]for a schematic diagram of the algorithm.) The inverse compositional algorithm is far more computationally efficient than the Lucas-Kanade algorithm.See Table2for a summary.The most time consuming steps,Steps3–6,can be performed once as a pre-computation taking time.The only additional cost is in-verting and composing it with.These two steps typically require oper-ations.See[3].Potentially these2steps could be fairly involved,as in[14],but the computational overhead is almost always completely negligible.Overall the cost of the inverse compositional algorithm is per iteration rather than,a substantial saving.3Linear Appearance Variation with the Euclidean L2NormAll of the algorithms in[3](there are9of them)aim to minimize the expression in Equation(1). Performing this minimization implicitly assumes that the template appears in the input imageTable2:The computation cost of the inverse compositional algorithm.The one time pre-computation cost of computing the steepest descent images and the Hessian in Steps3-6is.After that,the cost of each iteration is a substantial saving over the Lucas-Kanade iteration cost of.Pre-Step3Step5ComputationStep2Step8Iteration,albeit warped by.In various scenarios we may instead want to assume that:(18)appears in the input image(warped appropriately)where,,is a set of known appearance variation images and,,is a set of unknown appearance parameters.For example,if we want to allow an arbitrary change in gain and bias between the template and the input image we might set to be and to be the“all one”image.Given appropriate values of and,the expression in Equation(18)can then model any possible gain and bias.More generally,the appearance images can be used to model arbitrary linear illumination variation [11]or general appearance variation[5,14].If the expression in Equation(18)should appear (appropriately warped)in the input image,instead of Equation(1)we should minimize:(19)simultaneously with respect to the warp and appearance parameters,and.In the remainder of this section we derive three different algorithms(and several variants of them)to minimize the expression in Equation(19),before evaluating all of the algorithms in Section3.4.3.1The Simultaneous Inverse Compositional Algorithm3.1.1Goal of the AlgorithmOurfirst algorithm performs Gauss-Newton gradient descent simultaneously on the warp and appearance parameters.We use the inverse compositional parameter update on the warp param-eters.The appearance parameters are updated with the usual additive position does not have any meaning for them.Replacing with in Equation(11),the inverse compositional algorithm to minimize Equation(19)operates by iteratively minimizing:(20)simultaneously with respect to and,and then updating the warpand the appearance parameters.3.1.2Derivation of the AlgorithmPerforming afirst order Taylor expansion on and in Equation(20), and assuming as in Section2.2.2that is the identity warp,gives:(21) Neglecting second order terms,the above expression simplifies to:i.e.is an dimensional column vector containing the warp parameters concatenated with the appearance parameters.Similarly,denote the dimensional steepest-descent images:(24) Finally,denote the modified error image:(25) Equation(22)then simplifies to:(26) the minimum of which is attained at:(27) where is the Hessian with appearance variation:(28)In summary,the simultaneous inverse compositional algorithm for appearance variation proceeds by iteratively applying Equations(24),(25),(27),and(28)to compute.The incremental updates to the warp and appearance parameters are then extracted from and used to update the warp and the appearance parameters. Unfortunately the steepest descent images depend on the(appearance)parameters and so must be re-computed in every iteration.The result is the algorithm summarized in Figure3.Overall the algorithm is even slower than the original Lucas-Kanade algorithm because the computational cost of most of the steps depends on the total number of parameters rather than just the number of warp parameters.See Table3for a summary of the computation cost.The Simultaneous Inverse Compositional AlgorithmPre-compute:(3)Evaluate the gradients and for(4)Evaluate the JacobianStep4TotalPer Step1Step5IterationStep83.1.3An Efficient ApproximationThe main reason the simultaneous inverse compositional algorithm is so slow is because the steep-est descent images depend on the appearance parameters.See Equation(24).One possible ap-proximation to the algorithm is to assume that the appearance parameters do not vary significantly. The steepest descent images are only computed once using the initial estimates of the appearanceparameters.Afterwards they are never updated.As a result Steps(5)and(6)can be moved to pre-computation.The one time pre-computation cost therefore becomesand the cost per iteration becomes.This approximation results in a huge performance increase.However,the result is still not as efficient as the inverse compositional algorithm without appearance variation because the computational cost of most of the steps still depends on the total number of parameters rather than just the number of warp parameters. In Section3.4we empirically investigate the extent to which this efficiency approximation reduces the robustness and speed of convergence of the simultaneous inverse compositional algorithm.3.2The Project Out Inverse Compositional Algorithm3.2.1Goal of the AlgorithmAlthough the optimization in Equation(19)is non-linear with respect to the warp parameters,it is linear with respect to the appearance parameters.In[11],Hager and Belhumeur proposed a way of decomposing a very similar optimization into two steps.Thefirst step is a non-linear opti-mization with respect to the warp parameters,but performed in a subspace in which the appearance variation can be ignored.The second step is a closed form linear optimization with respect to the appearance parameters.We refer to this type of algorithm as a“project out”algorithm because in thefirst step the appearance variation is“projected out.”We now derive the equivalent project out inverse compositional algorithm.(Hager and Belhumeur[11]used an algorithm that is less general than the inverse compositional algorithm[3].)We also point out one failing of the project out algorithm,namely the estimation of the step size,and propose a method of correcting it.3.2.2Derivation of the AlgorithmIf we treat the images as vectors over the pixels we can rewrite Equation(19)as:(29)where is the unweighted(Euclidean)L2norm.This expression must be minimized simultane-ously with respect to and.If we denote the linear subspace spanned by a collection of vectors by and its orthogonal complement by Equation(29)can be rewritten as:(30) where denotes the Euclidean L2norm of a vector projected into the linear subspace. The second of these two terms immediately simplifies.Since the norm in the second term only considers the component of the vector in the orthogonal complement of,any component in can be dropped.We therefore wish to minimize:(31)The second of these two terms does not depend upon.For any,the minimum value of thefirst term is always exactly because the term can represent any vector in.As a result,the simultaneous minimum over both and can be found sequentially byfirst minimizing the second term with respect to alone,and then treating the optimal value of as a constant to minimize thefirst term with respect to.Assuming that the appearance variation vectors are orthonormal(if they are not they can easily be orthonormalized using Gram-Schmidt)the minimization of thefirst term has the closed-form solution:(32)The only difference between minimizing the second term in Equation(31)and the original goal of the Lucas-Kanade algorithm(see Equation(1))is that we need to work in the linear subspace .Working in this subspace can be achieved by using a weighted L2norm[1]with:(33)(assuming again that the vectors are orthonormal)and minimizing:(34)i.e.minimizing the second term of Equation(31)and minimizing the expression in Equations(33) and(34)are exactly the same thing.See[1]for the details.We can therefore use the inverse compositional algorithm with this weighted L2norm(described in Part2[1])to minimize the second term in Equation(31).The weighted steepest descent images are:are projected into by remov-ing the component in the direction of,for in turn.The weighted Hessian matrix:(37) can then also be computed as:(38)because the inner product of two vectors projected into a linear subspace is the same as if just one of the two is projected into the linear subspace.Again,see[1]for more details.In summary,minimizing the expression in Equation(19)simultaneously with respect to and can be performed byfirst minimizing the second term in Equation(31)with respect to using the inverse compositional algorithm with the quadratic form in Equation(33).The only changesThe Project Out Inverse Compositional Algorithm Pre-compute:(3)Evaluate the gradient of the template(4)Evaluate the JacobianTable4:The computational cost of the project out inverse compositional algorithm is almost identical to the original inverse compositional algorithm.The only additional cost is:(1)computing the steepest descent images in Step5,and(2)the one off extra cost of computing the appearance parameters in Step10.Pre-Step3Step5ComputationStep2Step8IterationPost-Step10TotalSo,although the project out algorithm with the two inputs and should converge to the same warp parameters,the algorithm takes steps that are larger by a factor of in the second case.If the algorithm will therefore likely diverge because it takes too big steps.Ifthe algorithm will probably still converge,but the rate of convergence will be very slow.There are various ways to correct for this“step-size”problem.One possibility is to use a dynamic step-size adjustment algorithm like Levenberg-Marquardt[3].Such algorithms check that each step of the algorithm results in an improvement in the error.If the error does not improve and the algorithm is diverging,a smaller step size is tried.Another possibility is to compute the magnitude of the component of in the direction of(normalized appropriately):(43)As can be seen,when the gain is approximately and,then and so the step-size correction does not affect the algorithm.Similarly,when the gain is and ,then and the step-size is corrected appropriately.The additional computational cost of evaluating Equations(42)and(43)is just and so is negligible.In Section3.4we empirically evaluate the step-size correction algorithm defined by Equations(42)and(43).3.2.4DiscussionSuppose that.The set of images spanned by is then the same if for any,or even for any other image in;i.e.the appearance model is the same for a variety of different templates.Any of these templates could be used with the project out algorithm and the result should theoretically be the same.In particular,if the modelincludes a bias term,the“all one”image is a very bad choice for the template.In this case,the gradient of the template and the steepest descent images would all be exactly zero,a degenerate case,and the algorithm would not be applicable.This degeneracy suggests that some images are not as good a choice for the template as others.The question of what is the best choice for the template,and whether the choice of the template affects the project out algorithm differently than it does the simultaneous algorithm are outside the scope of this paper and are left for future study.3.3The Normalization Inverse Compositional Algorithm3.3.1Goal of the AlgorithmOne frequently used way of coping with gain and bias variation is to“normalize”both the template and the input image.In particular,in many applications such as face recognition using eigenfaces the mean pixel intensities,or colors,are set to zero via:Equation(44)can therefore be regarded as projecting out the(unit)vector.Our proposal for a normalization algorithm is to perform an analogous step for each appearance vector .A minor difference,however,is that instead of projecting out the entire component in the direction from both and,we instead project out only enough so that the component of is the same as that of the template.One possible way to do this would be to apply the appropriate normalization to directly after Step1of the algorithm(see Figure2).In turns out,however,that after some simple algebra,this normalization can be achieved by normalizing the error image so that the component of the error image in the direction is zero;i.e.this makes the component of and in the direction the same.As an added benefit,an estimate of the appearance parameter can be computed in the process.In particular,the normalization step consists of:(47)where again we assume that the are orthonormal.Inserting this step into the inverse composi-tional algorithm gives the normalization inverse compositional algorithm summarized in Figure5. The only difference between the normalization algorithm and the inverse compositional algorithm is the addition of Step2a.Hence,the computation cost of the two algorithms is similar.See Ta-ble5for a summary.Step2a must be performed in every iteration(unlike the analogous Step10 in the project out algorithm)and so the normalization algorithm can be substantially slower than the project out inverse compositional algorithm when.3.3.3Step Size Adjustment Modeling GainThe normalization inverse compositional algorithm is prone to the same error in the step size esti-mate that the project out algorithm is.See Section3.2.3.The same correction can be applied.We can even use the normalization algorithm to compute the step size correction even more efficiently.The Normalization Inverse Compositional AlgorithmPre-compute:(3)Evaluate the gradient of the template(4)Evaluate the JacobianStep4Step6TotalPer Step1Step2a Step8Iteration(49) In Section3.4we empirically evaluate the step-size correction defined by Equations(48)and(49).3.4Experimental ResultsWe conducted a variety of experiments to compare the performance of the3linear appearance variation algorithms(simultaneous inverse compositional,project out,and normalization)and their variants.Our experimental procedure is similar to that in[3].In particular,we started with the image in Figure2of[3].We manually selected a pixel template in the center of the face.We then added the appearance variation to.The exact choice of, ,and depends on the experiment in question and is described in detail below.We then randomly generated affine warps in the following manner.(We use the same procedure that was used in[3].)We selected3canonical points in the template.We used the bottom left corner,the bottom right corner,and the center top pixel as the canonical points.We then randomly perturbed these points with additive white Gaussian noise of a certain variance andfit for the affine warp parameters that these3perturbed points define.We then warped with the affine warp and run the various algorithms starting from the identity warp.Where appropriate,the appearance parameters are initialized to.Since the6parameters in the affine warp have different units,they must be combined in some way.We use the same error measure as in[3].Given the current estimate of the warp,we compute the destinations of the3canonical points and compare them with the correct locations.We compute the RMS error over the3points of the distance between their current and the correct locations.(We prefer this error measure to normalizing the units so that the6parameters error are comparable.) As in[3],we compute the“average rate of convergence”and the“average frequency of conver-gence”over a large number of randomly generated inputs(5000to be precise).Each input consists of a different randomly generated affine warp.For the simultaneous and normalization algorithms we sometimes also plot a“rate of convergence of the appearance parameters”.This measure is only meaningful for the project out algorithm after the algorithm has converged.The error measure for the appearance parameters is the Euclidean L2norm of the appearance parameter vector.3.4.1Experiment1:Comparison with Inverse CompositionalThe goal of Experiment1is to show that all of the linear appearance variation algorithms can cope with some appearance variation,and yet still perform as well as the original inverse compositional algorithm when there is no appearance variation.In other experiments we will investigate how the algorithms compare with varying degrees of appearance variation,and in the presence of additive noise.For now,we just consider a very simple case.In particular,we just use appearance variation image.The specific image that we used is the image of a different face approximately aligned with the face in the template.(As described in Section5.4we are making all of our code available so that the reader can experiment with other choices for.)The results are shown in Figure6.In Figures6(a)and(b)we include plots of the convergence rate and frequency of convergence for,no appearance variation.In Figures6(c)and(d) we include similar plots forthe original inverse compositional algorithm performs far worse,whereas all four of the appearance variation algorithms perform very well,and similarly.These results demonstrate that all4of the appearance variation algorithms can cope with fairly substantial linear appearance variation,whereas the original inverse compositional algorithm cannot.3.4.2Experiment2:VaryingIn Experiment2we investigate how the performance of the4appearance variation algorithms(SIC, SIC-EA,PO,and NIC)varies with the amount of appearance variation.We re-ran Experiment1IterationR M S P o i n t E r r o rFigure 6:A comparison of the inverse compositional algorithm with no appearance variation modeling(IC)with 4different linear appearance variation algorithms:(1)the simultaneous inverse compositional al-gorithm (SIC),(2)the efficient variant of the simultaneous algorithm (SIC-EA),(3)the project out algorithm (PO),and (4)the normalization algorithm (NIC).(a)and (b)contain results for and demonstrate that all of the algorithms perform similarly with no appearance variation.(c)and (d)contain results forandthe contribution。
lucas-kanade原理引言概述:Lucas-Kanade算法是一种用于光流估计的经典方法,它通过分析图像序列中的像素强度变化来估计物体的运动。
该算法在计算机视觉和图像处理领域具有广泛的应用。
本文将详细介绍Lucas-Kanade算法的原理及其在光流估计中的应用。
正文内容:1. Lucas-Kanade算法的基本原理1.1 图像亮度恒定假设Lucas-Kanade算法基于一个重要的假设,即在一个像素的领域内,其亮度保持不变。
这意味着物体的运动引起的像素强度变化主要是由于光照变化或者物体表面的阴影等因素引起的。
1.2 光流方程Lucas-Kanade算法通过求解光流方程来估计物体的运动。
光流方程描述了像素在图像序列中的运动关系,它可以表示为一个方程组。
通过求解这个方程组,可以得到物体的运动速度。
2. Lucas-Kanade算法的求解过程2.1 特征点的选择在Lucas-Kanade算法中,需要选择一些特征点来进行光流估计。
通常情况下,选择图像中的角点或者边缘点作为特征点,因为这些点在不同图像帧中的位置变化较大,更容易进行光流估计。
2.2 光流金字塔为了提高算法的效果,Lucas-Kanade算法通常会使用光流金字塔来进行多尺度的光流估计。
光流金字塔通过对图像进行多次降采样,得到不同尺度的图像,从而可以在不同尺度上进行光流估计。
2.3 高斯金字塔为了减小噪声对光流估计的影响,Lucas-Kanade算法通常会使用高斯金字塔来对图像进行平滑处理。
高斯金字塔通过对图像进行多次高斯模糊,得到不同尺度的图像,从而可以减小噪声的干扰。
2.4 光流估计在Lucas-Kanade算法中,通过求解光流方程组来估计物体的运动速度。
光流方程组可以通过最小二乘法来求解,得到物体在图像上的运动向量。
3. Lucas-Kanade算法的应用3.1 视频稳定Lucas-Kanade算法可以用于视频稳定,通过对视频中的每一帧进行光流估计,可以得到物体的运动轨迹,从而实现视频的稳定。
Introduction to Algorithms第二版教学设计1. 教学目标本教学设计的最终目标是让学生能够:•了解算法基本概念和分类;•掌握常见的算法设计和分析方法;•学会运用算法解决实际问题;•熟悉各种常见的算法在计算机科学领域中的应用。
2. 教学内容本教学设计主要涵盖Introduction to Algorithms第二版中的以下内容:第一部分基础知识•算法基础:–算法概述–算法复杂度分析–渐进符号法•排序算法:–插入排序–归并排序–快速排序第二部分数据结构•基本数据结构:–栈、队列–链表、树、图•高级数据结构:–线段树–并查集–哈希表第三部分高级主题•动态规划•贪心算法•分治策略•网络流算法3. 教学方法•理论讲解:通过PPT和授课讲解来介绍算法基本概念和分类,以及常见的算法设计和分析方法,加深学生的理论知识。
•课堂练习:通过一些小型的算法题目,在课堂上让学生在限定时间内完成,加强学生的算法思维能力和实战能力。
•设计实践:在一些具体的应用案例中,让学生设计算法方案,并通过实践调试和优化算法,加深学生的实践能力。
•课外资料阅读:提供一些额外的算法学习资料,帮助学生对知识点进行深度拓展和延伸。
4. 评估方式•在课堂上进行小型算法题目的测试;•作业:设计算法解决一些具体的实际问题;•考试:针对Introduction to Algorithms第二版中的知识点进行考查,主要测试学生的理论知识和实践能力。
5. 教学工具•PPT•IDE•模拟环境6. 教学评价通过本次Introduction to Algorithms第二版的教学,学生应该能够对算法的基本概念、分类、常见算法设计和分析方法、以及各种常见的算法应用有深入的了解,掌握常用的算法设计和分析方法,能够熟练运用各种算法解决实际问题,具备较强的算法分析和设计能力,同时培养学生的团队合作精神和创新意识。
lucas-kanada稀疏光流算法原理摘要:本文将详细介绍Lucas-Kanade稀疏光流算法的原理,该算法是一种广泛应用于计算机视觉领域的运动估计方法。
通过对算法的原理、实现过程和应用场景的深入剖析,旨在帮助读者更好地理解和应用该算法。
一、引言光流法是一种用于估计图像中像素或特征点运动的方法,广泛应用于运动估计、目标跟踪、视频处理等领域。
Lucas-Kanade稀疏光流算法是其中一种具有代表性的算法,具有计算速度快、精度高的优点。
二、算法原理Lucas-Kanade稀疏光流算法的基本思想是利用运动估计的方法,通过比较相邻帧之间的特征点像素变化来估计运动矢量。
该算法首先在视频的每一帧中检测出特征点,然后对这些特征点进行匹配,得到运动矢量。
1. 特征点检测:算法通过图像处理技术,如Sobel滤波器和Harris角点检测算法,在视频帧中检测出具有明显运动特性的特征点。
2. 特征点匹配:将相邻帧中的特征点进行匹配,通过计算特征点之间的距离和角度,确定运动矢量。
3. 稀疏光流计算:根据匹配得到的运动矢量,计算出视频流中每个特征点的运动矢量,得到稀疏光流。
三、实现过程1. 特征点检测与提取:使用图像处理技术对输入视频帧进行预处理,提取出具有明显运动特性的特征点。
2. 特征点匹配算法:使用相似性度量方法,如欧氏距离或余弦相似性,对相邻帧中的特征点进行匹配。
3. 运动矢量计算:根据匹配结果,使用Lucas-Kanade算法计算出每个特征点的运动矢量。
4. 迭代优化:对于计算出的初始稀疏光流,可以通过迭代优化方法进行修正,以提高光流计算的精度。
5. 输出结果:最后输出经过优化后的稀疏光流结果。
四、应用场景Lucas-Kanade稀疏光流算法在许多应用场景中具有广泛的应用,如运动目标跟踪、视频分析、人机交互等。
具体应用包括:1. 人脸识别:通过在人脸图像中检测并跟踪特征点,实现人脸识别和表情分析。
2. 自动驾驶:在自动驾驶系统中,通过检测车辆和障碍物的运动,实现车辆的路径规划和避障。
Introduction to Lucas-KanadeAlgorithmXiaopeng Hong(洪晓鹏)xphong@2008-07-31说明•只讲经典,不讲最新•只讲LK,不求全面•由易入难•抛砖引玉•历史的眼光Outline•LK Algorithm•LK Optical Flow •Application•Lucas B D and Kanade T, An iterative image registration technique with an application to stereo vision. IJCAI, 1981. •被引用次数:2330. by Google scholarBruce D. LucasNo longer a member of RI/CS/CMU ?Takeo KanadeU.A. and Helen Whitaker University Prof., RI/CS/CMU Elected to the National Academy of Engineeringand the American Academy of Arts and Sciencesa Fellow of the IEEEa Fellow of the ACMa Founding Fellow of AAAIthe former and founding editor of IJCV获得了包括Marr Prize Award (1990) 在内的诸多荣誉•知识点–什么是图像配准(Image Registration/Alignment Problem)–什么是经典LK算法–LK 光流法Image Registration Problem Image Alignment ProblemFrom Lihi Zelnik-Manor’s SlideLucas-Kanade 1981•Use spatial Intensity gradient information to direct the search for the position that yields the best match•Can be generalized to deal with arbitrary linear distortions of the image, including rotation.•Function F(x)and G(x):–which give the respective pixel values at each location x in two images.•We wish to find the disparity vector h that minimizes some measure of the differencebetween F(x+h)and G(x),for x in some region of interest R (ROI). ()()()min xnorm h x R h F x h G x ∈=+−∑ 待配准图像(模型)测试图像平移向量()()F x G x : 模型: 测试图像()()()min xnorm h x R h F x h G x ∈=+−∑Existing Methods (by 1981)•Calculating all possible values of the disparity vector h.–G(x): N * N–Searching space of h: M * M–•Solution:–Hill-climbing–SSDA–Coarse to fine Search Strategy()22O MN•One Dimension Translational Problem •Multiple Dimension Translational Problem •Further Extension1D The translational ImageRegistration Problem •That means:–no rotation–no scale–no other affine transformations!–Brightness Constancy–Only translation will be discussed.An Example in the 1D situation •First 1D, then generalized to multi-dimensionsh 的表达Æ第1种推导方式()()()min xnorm h x R h F x h G x ∈=+−∑ 当h 比较小的时候Requires that h is small enough!!!Notes that:当F(x)接近线性,近似程度好当F(x)不接近线性,近似程度差每一个像素的贡献Notes that:当F(x)接近线性,近似程度好反比当F(x)不接近线性,近似程度差每一项可以用二阶导的大小来加权加权平均估计Newton–Raphson methodby Wikipedia方程求根()0f x =00x =()()1n n n n f x x x f x +=−′Newton–RaphsonIteration个人认为,其与梯度下降法是紧密联系的Recall()()()min xnormhx Rh G x F x h ∈=−+∑ ()()()f h G x F x h =−+()()f h F x h ′′=−+Letthen00h =()()()()()()()()1k k k k k n n k k k f h G x F x h G x F x h h h h h f h F x h F x h +−+−+=−=−=+′′′−++00h =()()()()()()()()1k k k k k n n k k k f h G x F x h G x F x h h h h h f h F x h F x h +−+−+=−=−=+′′′−++00h =()()()()()()1k k n xxk w x G x F x h h h w x F x h +−+==+′+∑∑加权平均估计第2种推导方式•为了能够推广到多维,避免F’(x) = 0无定义容易扩展到多维避免分母为0的情况???00h =()()()()()()1k k n xxk w x G x F x h h h w x F x h +−+==+′+∑∑00h =()()()()()()()12kkxk nkxw x F x h G x F x h h h w x F x h +′+−+==+′+∑∑NOWPREVIOUSTricks•Smooth–降低频率,增大带宽,可以扩大收敛区域•Coarse to fine–可以解决h较大的问题•Weighting–Improve the accuracy–Speed up the convergenceImplementation00h =()()()()()()()12kkxk nkxw x F x h G x F x h h h w x F x h +′+−+==+′+∑∑•One Dimension Translational Problem •Multiple Dimension Translational Problem •Further ExtensionMultiple Dimensions CaseMD case: 1D case:the n ×n (Gauss-Newton approximation to the) Hessian matrix00h =()()()()()()()12k kx k n kx w x F x h G x F x h h h w x F x h +′+−+==+′+∑∑00h =()()()()()()()()()()()11T k n k k x T k k x h h w x F x h G x F x h w x F x h F x h +−=+∇+−+•⎡⎤•∇+∇+⎣⎦∑∑NOWPREVIOUS•One Dimension Translational Problem •Multiple Dimension Translational Problem •Further ExtensionGeneralization to affinetransformationLucas-Kanade 20 Years On()2 A diag x I h Δ⎡⎤⎡⎤⎢⎥⎣⎦Δ⎣⎦与之前的推导是和谐的Set = 0−:x G yG()2 diag x I ⎡⎤⎣⎦Generalization to brightness valuechangeSummary•Introduce ‘gradient descent’/Difference to Image Registration Problem•Use Newton-Raphson Iteration to get the solution•Coarse to fine deductionReferences on Lucas-KanadeMethod•Lucas and Kanade, An iterative image registration technique with an application to stereo vision. IJCAI,1981.•Lucas, Generalized Image Matching by the Method of Differences, doctoral dissertation, 1984•Simon Baker and Iain Matthews. Lucas-Kanade 20 Years On: A Unifying Framework. IJCV2004•Sourcecode–OpenCV–An Implementation of the Kanade–Lucas–TomasiFeature Tracker, /~stb/klt/Outline•LK Algorithm•LK Optical Flow •ApplicationOptical Flow (LK)•光流是空间运动物体在观测成像面上的像素运动的瞬时速度。
光流的研究是利用图像序列中的像素强度数据的时域变化和相关性来确定各自像素位置的“运动”•研究光流场的目的就是为了从序列图像中近似计算不能直接得到的运动场。