Simple tests of classic OF methods

BA method, simple synthetic images

For simple synthetic images:

I0 =

         0    0.5000         0
         0    1.0000         0
         0    0.5000         0
    0.1000         0         0
    0.0500         0         0
    0.0500    0.1000         0

I1 =

    0.5000         0         0
    1.0000         0         0
    0.5000         0         0
         0    0.1000         0
         0    0.0500         0
         0    0.0500    0.1000


Running code by D.Sun. Disabled texture decomposition, disabled multiscale processing.
uv = estimate_flow_interface(I0, I1, 'classic-c-brightness', [], {'display', 1, 'pyramid_levels', 1, 'gnc_pyramid_levels', 1});

Graduated non convexity scheme (GNC)

Optimization of energy terms can be difficult in OF, because of non-convexity and local optima.
Construct a series of energy functions





EQ is convex, quadratic
alpha changes from 1 to 0, so Energy Ec changes from quadratic to original.
for each alpha they find optimum through setting derivatives of Ec to 0.
Solution on each stage becomes initialization on the next one.


Proposed in: D. Sun, S. Roth, J. Lewis, and M. J. Black. Learning optical flow. In ECCV, volume 3, pages 83–97, 2008. [pdf]

Investigating optical flow by D. Sun (Secrets of optical flow)

Personal page of the author: http://cs.brown.edu/~dqsun/research/index.html
Original paper: http://cs.brown.edu/~dqsun/pubs/cvpr_2010_flow.pdf
Newer paper: Deqing Sun, Stefan Roth, and Michael J. Black. "A Quantitative Analysis of Current Practices in Optical Flow Estimation and the Principles Behind Them". International Journal of Computer Vision (IJCV), 2013 [pdf] [Source code]

Look inside the sources:

Code highlight in blogger

Source

place following code before your <head> tag in the HTML of your blogger template:

Save Ipython notebook as script with the same filename

# creating a variable theNotebook with the name of notebook
# source: http://stackoverflow.com/a/23619544
# In[1]:

%%javascript
var kernel = IPython.notebook.kernel;
var thename = window.document.getElementById("notebook_name").innerHTML;
var command = "theNotebook = " + "'"+thename+"'";
kernel.execute(command);

# saving to a directory 'backup'. create the directory if it doesn't exist
# source http://stackoverflow.com/a/19067979
# In[2]:

try :
    if(__IPYTHON__) :
        print "saving", theNotebook
        import os
        dir_backup = 'backup'
        if not os.path.exists(dir_backup):
            os.makedirs(dir_backup)
        get_ipython().system(u'ipython nbconvert --to python {0} --output {1}'.format(theNotebook, os.path.join(dir_backup, theNotebook)) )
except NameError :
    print "Unable to save"

Python equivalent of interp2

I wrote python version of  interp2(z, xi, yi,'linear') from matlab

https://github.com/serge-m/pyinterp2

Simple occlusion filling for depth maps

As an example I use images from middleburry.
Solution is very dirty and slow.


https://github.com/serge-m/depth_map_occlusion

# In[1]:

import numpy
import scipy
import matplotlib.pyplot as plt


# In[2]:

from scipy import ndimage
import numpy as np

# kernels for shift
k = np.array([
[[0,0,0],
 [0,0,1],
 [0,0,0],],
[[0,1,0],
 [0,0,0],
 [0,0,0],],
[[0,0,0],
 [1,0,0],
 [0,0,0],],
[[0,0,0],
 [0,0,0],
 [0,1,0],],
[[1,0,0],
 [0,0,0],
 [0,0,0],],
[[0,0,1],
 [0,0,0],
 [0,0,0],],
[[0,0,0],
 [0,0,0],
 [0,0,1],],
[[0,0,0],
 [0,0,0],
 [1,0,0],],
])