FlowJ
Class FlowJLucas

java.lang.Object
  extended by FlowJ.FlowJLucas

public class FlowJLucas
extends java.lang.Object

This is a class that implements the Lucas and Kanade optical flow algorithm. Implementation based on convolutions, with local field properties, gradient computation with different kernels including scalable Gaussian derivatives.

 References:
      Lucas and Kanade, Proc IJNA 1981
      Barron, Fleet, Beauchemin, 1994, IJCV 12, 1, 43-77
      Abramoff et al, 2002, IEEE TMI.
 
Copyright (c) 1999-2002, Michael Abramoff. All rights reserved.


Field Summary
 boolean debug
           
 boolean displayon
           
static java.lang.String[] sderiv
           
static java.lang.String[] sregul
           
 
Constructor Summary
FlowJLucas()
           
 
Method Summary
 void computeFull(FlowJFlow flow, boolean includeNormals, float sigmaw, float tau, int regularizationMethod)
          Compute full flow field from the first order gradients in dx, dy, dt for a weighted local neighborhood omega (weighted by G defined by sigmaw) around every image location.
 void filterAll(ij.ImageStack is, int center, float sigmat, float sigmas, int gradientType)
          Do filtering.
static int firstFrame(ij.ImageStack is, float sigmat, int gradientType)
          Return the first frame for which you can compute the flow.
static int getSupport(float sigmat, int gradientType)
          Return the number of frames needed for specific sigmat and gradient type.
static int lastFrame(ij.ImageStack is, float sigmat, int gradientType)
          Return the last frame for which you can compute the flow.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public final boolean debug
See Also:
Constant Field Values

displayon

public final boolean displayon
See Also:
Constant Field Values

sderiv

public static java.lang.String[] sderiv

sregul

public static java.lang.String[] sregul
Constructor Detail

FlowJLucas

public FlowJLucas()
Method Detail

getSupport

public static int getSupport(float sigmat,
                             int gradientType)
Return the number of frames needed for specific sigmat and gradient type.

Parameters:
sigmat - temporal sigma of the kernel.
gradientType - the type of gradient, one of GAUSSIANDERIV, CENTRALDIFF, SOBEL2D, SOBEL3D, SUBTRACT
Returns:
number of frames needed.

firstFrame

public static int firstFrame(ij.ImageStack is,
                             float sigmat,
                             int gradientType)
Return the first frame for which you can compute the flow.

Parameters:
is - an ImageStack containing the images.
sigmat - temporal sigma of the kernel.
gradientType - the type of gradient, one of GAUSSIANDERIV, CENTRALDIFF, SOBEL2D, SOBEL3D, SUBTRACT

lastFrame

public static int lastFrame(ij.ImageStack is,
                            float sigmat,
                            int gradientType)
Return the last frame for which you can compute the flow.

Parameters:
is - an ImageStack containing the images.
sigmat - temporal sigma of the kernel.
gradientType - the type of gradient, one of GAUSSIANDERIV, CENTRALDIFF, SOBEL2D, SOBEL3D, SUBTRACT

filterAll

public void filterAll(ij.ImageStack is,
                      int center,
                      float sigmat,
                      float sigmas,
                      int gradientType)
               throws FlowJException
Do filtering.

Throws:
FlowJException

computeFull

public void computeFull(FlowJFlow flow,
                        boolean includeNormals,
                        float sigmaw,
                        float tau,
                        int regularizationMethod)
Compute full flow field from the first order gradients in dx, dy, dt for a weighted local neighborhood omega (weighted by G defined by sigmaw) around every image location. Find the best fit for that location using a LSE using the pseudoinverse. A SVD decreased speed and did not influence errors. All elements with eigenvalues of the pseudoinverse matrix m smaller than threshold tau are rejected. Only if the second eigenvalue of the pseudoinverse is larger than tau, normal flow instead of full flow is computed for that location.

Parameters:
flow - will contain the x,y flows.
includeNormals - a flag whether to include normals or not.
sigmaw - SD of the probability function associated with the Gaussian defining the size of the neighborhood
tau - the eigenvalue threshold
regularizationMethod - is one of REG_GAUSSIAN, REG_GAUSSIAN_1D, 0 defines how the local neighborhood is filtered.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object