Personal page of the author:

Original paper:

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:



  1. Iterate flow computation

  2. Linearization update, for j = 1:this.max_linear. In the simple case max_linear==1, when I use x = A\b solver for linear system. Probably for more complicated solvers max_linear > 1


calls pre_process_data (preprocessing, normalization, image pyramyd). Loop through iterations:

for ignc = 1:this.gnc_iters   

Calls compute_flow_base.m


– several preptocessing options for images. The first is texture decomposition. if no texture decomposition, scale image to [0, 255] range. Build image pyramyd. there is also following code:

% For segmentation purpose
    data.org_pyramid_images = compute_image_pyramid(this.images, f,...
        this.pyramid_levels, 1/this.pyramid_spacing);
    data.org_color_pyramid_images = compute_image_pyramid(this.color_images,...
        f, this.pyramid_levels, 1/this.pyramid_spacing);

In my case I don’t need segmentation and use simple OF method. It seems it’s just bad code design. Dig deeper.



– switcher that recursively initializes members of OF object. E.g. if you want to load ‘classic+nl-brightness’ method, it loads ‘classic+nl’ first:

case 'classic+nl'        
        ope = classic_nl_optical_flow;
        ope.texture  = true;
        ope.median_filter_size   = median_filter_size;
        ope.alp = 0.95;
        ope.area_hsz = 7;
        ope.sigma_i  = 7;
        ope.color_images = ones(1,1,3);
        ope.lambda = 3;
        ope.lambda_q =3;
        %ope.display  = true;    

and then applies the difference:

case 'classic+nl-fast-brightness'
        ope = load_of_method('classic+nl');        
        ope.max_iters       = 3;
        ope.gnc_iters       = 2;
        ope.texture         = false;