# optFlowLk

## PURPOSE

Calculate optical flow using Lucas & Kanade. Fast, parallel code.

## SYNOPSIS

function [Vx,Vy,reliab]=optFlowLk( I1, I2, winN,winSig, sigma, thr, show )

## DESCRIPTION

     Calculate optical flow using Lucas & Kanade.  Fast, parallel code.

     Note that the window of integration can either be a hard square window of
     radius winN or it can be a soft 'gaussian' window with sigma winSig.
     In general the soft window should be more accurate.

     USAGE
      [Vx,Vy,reliab]=optFlowLk( I1, I2, winN, ...
        [winSig], [sigma], [thr], [show] )

     INPUTS
      I1, I2  - input images to calculate flow between
      winN    - window radius for hard window (=[] if winSig provided)
      winSig  - [] sigma for soft 'gauss' window (=[] if winN provided)
      sigma   - [1] amount to smooth by (may be 0)
      thr     - [3e-6] ABSOLUTE reliability threshold (min eigenvalue)
      show    - [0] figure to use for display (no display if == 0)

     OUTPUTS
      Vx, Vy  - x,y components of flow  [Vx>0->right, Vy>0->down]
      reliab  - reliability of flow in given window (cornerness of window)

     EXAMPLE
      % create square + translated square (B) + rotated square (C)
      A=zeros(50,50); A(16:35,16:35)=1;
      B=zeros(50,50); B(17:36,17:36)=1;
      C=imrotate(A,5,'bil','crop');
      optFlowLk( A, B, [], 2, 2, 3e-6, 1 );
      optFlowLk( A, C, [], 2, 2, 3e-6, 2 );
      % compare on stored real images (of mice)
      load optFlowData;
      [Vx,Vy,reliab] = optFlowLk( I5A, I5B, [], 4, 1.2, 3e-6, 1 );
      [Vx,Vy,reliab] = optFlowCorr( I5A, I5B, 3, 5, 1.2, .01, 2 );
      [Vx,Vy] = optFlowHorn( I5A, I5B, 2, 3 );

     See also OPTFLOWHORN, OPTFLOWCORR

     Piotr's Image&Video Toolbox      Version 2.0
     Copyright 2008 Piotr Dollar.  [pdollar-at-caltech.edu]
     Please email me if you find bugs, or have suggestions or questions!
     Licensed under the Lesser GPL [see external/lgpl.txt]

## CROSS-REFERENCE INFORMATION

This function calls:

- gaussSmooth Applies Gaussian smoothing to a (multidimensional) image.
- im Function for displaying grayscale images.
- localSum Fast routine for box filtering.

This function is called by: