# optFlowCorr

## PURPOSE

Calculate optical flow using cross-correlation.

## SYNOPSIS

function [Vx,Vy,reliab] = optFlowCorr( I1, I2, patchR, searchR,sigma, thr, show )

## DESCRIPTION

     Calculate optical flow using cross-correlation.

     Calculate optical flow using correlation, followed by lucas & kanade on
     aligned squares for subpixel accuracy.  Locally, the closest patch within
     some search radius is found.  The distance measure used is the euclidean
     distance between patches -- NOT normalized correlation since we assume
     pixel brightness constancy.  Once the closest matching patch is found,
     the alignment between the two patches is further refined using lucas &
     kanade to find the subpixel translation vector relating the two patches.

     This code has been refined for speed, but since it is nonvectorized code
     it can be fairly slow.  Running time is linear in the number of pixels
     but the constant is fairly large.  Test on small image (150x150) before
     running on anything bigger.

     USAGE
      [Vx,Vy,reliab] = optFlowCorr( I1, I2, patchR, searchR,
                                     [sigma], [thr], [show] )

     INPUTS
      I1, I2      - input images to calculate flow between
      patchR      - determines correlation patch size around each pixel
      searchR     - search radius for corresponding patch
      sigma       - [1] amount to smooth by (may be 0)
      thr         - [.001] RELATIVE reliability threshold
      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 optical flow in given window (cornerness of
                window)

     EXAMPLE

     See also OPTFLOWHORN, OPTFLOWLK

     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.
- arrayToDims Pads or crops I appropriately so that size(IC)==dims.
- c clc - clear command window.

This function is called by: