PYME.Analysis.optic_flow module¶
Created on Wed Apr 13 10:45:44 2016
@author: david

PYME.Analysis.optic_flow.
of
(im1, im2, filt_rad=10, support_rad=10)¶

PYME.Analysis.optic_flow.
reg_of
(im1, im2, filt_rad=10, support_rad=10, reg_l=0)¶ Calculates the optical flow between im1 and im2.
Images are smoothed first, using a filter of radius filt_rad. The flow is then calculated with a Gaussian support function of radius support_rad. An optional regularization term, reg_l allows penalization of high flow velocities.
Parameters: im1, im2 : numpy.ndarray
The two images to calculate the flow between
filt_rad : float
The radius of the lowpass filter used before estimating flow. This is mostly useful for noise reduction, and is essential for getting robust gradient estimates.
support_rad : float
The radius of the support region. All pixels in this region are assumed to be moving together (i.e. we take the weighted average of the motion over the support region).
reg_l : float, optional
Regularization \(\lambda\) which penalizes large flow velocities. This is useful in obtaining a robust estimate in darker areas of the image where apparent motion is mostly due to noise.
Notes
See “Optical Flow Estimation”, Fleet and Weiss, 2006 for underlying maths. Our implementation is based on Section 2, “Basic gradientbased estimation”, and attempts to find a leastsquares solution which minimizes:
\[E(\tilde{u}) = \sum_{\tilde{x}} g(\tilde{x}) \left[\tilde{u} \cdot \nabla I(\tilde{x}, t) + I_t(\tilde{x}, t)\right]^2\]Note that the reglarization is not described in Fleet and Wiess, but works by adding an L1norm term to the equation to be minimized, resulting in the following equation:
\[E(\tilde{u}) = \sum_{\tilde{x}}g(\tilde{x})\left[\tilde{u} \cdot \nabla I(\tilde{x}, t) + I_t(\tilde{x}, t)\right]^2 + \lambda \\tilde{u}\^2\]Setting \(\lambda\) (reg_l) to zero is equivalent to standard unregularized flow estimation.