Category Archives: Techniques

Levenberg-Marquardt algorithm

http://en.wikipedia.org/wiki/Levenberg-Marquardt_algorithm

In mathematics and computing, the Levenberg-Marquardt algorithm (or LMA) provides a numerical solution to the problem of minimizing a function, generally nonlinear, over a space of parameters of the function. These minimization problems arise especially in least squares curve fitting and nonlinear programming.
The LMA interpolates between the Gauss-Newton algorithm (GNA) and the method of gradient descent. The LMA is more robust than the GNA, which means that in many cases it finds a solution even if it starts very far off the final minimum. On the other hand, for well-behaved functions and reasonable starting parameters, the LMA tends to be a bit slower than the GNA.
The LMA is a very popular curve-fitting algorithm; most software with generic curve-fitting capabilities provides an implementation of it.

那个sba就是使用LMA算法求解的。

structure from motion

查了一下资料,发现SfM这个问题已经在Multiple view geometry这本书中讲的比较清楚了。SfM的最后一步,bundle adjustment网上也有现成的程序,
http://www.ics.forth.gr/~lourakis/sba/#Download。剩下得就是好好研究这些资料了。

今天在查SfM的时候想起来了Photo tourism这篇paper,就又看了一下。发现这个paper已经被微软做成产品了,photosynth,很cool。
http://labs.live.com/photosynth/default.html

Structure and Motion的matlab code
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4576&objectType=File
http://homepages.inf.ed.ac.uk/s0346435/projects/sfm/sfm_sift.html

Matlab的dos command line使用

以前在看别人写的Multi-Camera Calibration的matlab code时,发现他配了一个cluster,通过ssh在每台电脑上都运行相同的matlab程序来处理获得的图片。其中matlab是这样调用的
>matlab -nosplash -nojvm func
-nojvm是unix下机子专用的,设置了该参数matlab的窗口就不会打开,感觉很爽。

在windows下,matlab的窗口是一定会打开的,但是也可以设置-minimize让其最小化,然后在.m文件最后加上exit,这样效果也还可以。
>matlab -nosplash -nodesktop -minimize -r myfunc -logfile C:\log.txt

Matlab Startup Options
http://www.mathworks.com/support/solutions/data/1-16B8X.html?solution=1-16B8X
http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_env/f8-4994.html

Image Deconvolution

花了一天的时间,到目前为止觉得Intel IPP只实现了1d的lucy richardson deconvolution,还没有发现怎么使用2d的psf。现在只好使用matlab的code,matlab的code是现成的,应该很容易使用。最多就是在c程序里调用一下matlab函数,程序看起来应该不算太ugly。

在这一天中,又重新认识了一下vxl,发现其功能还是很强大的。主要是它实现了多个版本的structure from motion,这正是我需要的。看来这一天还是挺值的。

Vonoroi Tessellation

最近求motion deblur的psf function,用到了1D vonoroi tessellation, 或者它的duality形式,delaunay triangulation. 看OpenCV的document,根本没有一点sense,就上网google了一下。发现opencv用到了quad-edge这个数据结构,在这个数据结构中edge包含了整个graph的topology information;vertices包含了graph的geometry information。这种数据结构比obj文件对应的数据结构要有效的很多,确实很cool。

Quad-Edge Data Structure and Library
http://www.cs.cmu.edu/afs/andrew/scs/cs/15-463/2001/pub/src/a2/quadedge.html
vertface
edge

Lucas Kanade Optical flow

Opencv里已经实现了LK optical flow算法,但是我要求的是affine optical flow,而且是整个object的global flow,跟原始的of算法有些差异,所以就自己也实现了一下。写到最后发现自己的结果跟ground truth差的很多,感觉无法理解。因而耽误了将近一个星期的时间。

昨天晚上在找问题的原因,搜到了一篇讲OpenCV的LK of实现的方法,“Jean-Yves Bouguet. Pyramidal Implementation of the Lucas Kanade Feature Tracker”。看到了有些细节自己没有注意到,可能是因为这些细节自己的结果才很差吧,希望今天能有些发现。原以为自己这方面应该还可以了,没想到还是漏考虑了一些细节。

……………

中午又修改了一下code,基本上work了,但是正如Bouguet said,使用LK估计更多的参数(affine 6个参数),效果不如只估计2个参数(displacement of x,y)accurate, robust。做到现在,看来是被motion deblur那篇paper给忽悠了,他列了一个affine的式子,最后只求了x和y的偏移量,即:用了经典的LK算法。

graph cut

Graph cut是一种energy minimization的方法,用来解first-order markov Random Field比用Belief Propagation感觉更好,比用dynamic programming(只用1D求解), gradient decedent, simulated annealing, etc 要好得更多;特别是使用a-b-swap, 和 a-expansion的时候。刚开始看graph cut的时候不着门道,走了很多弯路,现在总结起来可以这样学习:

1。学习algorithm课本里的关于graph那一节,或者google maxflow/mincut相关的内容,有介绍mincut的两种解法;
2。然后就开始看用graphcut解决computer vision里的问题,首先要看的是《Interactive Graph Cuts for Optimal Boundary & Region Segmentation of Objects in N-D Images》iccv 01。这篇paper讲怎么用graphcut来做image segmentation;
3。看Fast Approximate Energy Minimization via Graph Cuts (Boykov, Veksler and Zabih, PAMI ’01),这篇paper系统介绍了如何构造graph和energy term来解stereo disparity, motion等问题,也比较直观的介绍了a-expansion。后面的关于graphcut的TPAMI的文章都没有介绍如何构造graph来解问题,这篇比较关键;

看了以上几个文章后,基本就可以看懂关于graphcut的论文了,就可以深入下去了。