An affine (or first-order) optic flow model has 6 parameters, describing image translation, dilation, rotation and shear. The class affine_flow provides methods to estimates these parameters for two frames of an image sequence.
The class implements a least-squares fit of the parameters to estimates of the spatial and temporal grey-level gradients. This is an extension of the well-known Lucas-Kanade method. The images are either sampled conventionally, on a rectilinear grid, or on a log-polar grid. In the latter case, the class may iteratively refine its estimates by moving the sampling grid to track the motion. Options to specify a region of interest and smoothing and sampling parameters are provided.
The file includes a demonstration of the class, and test images for this. The functions for smoothing images and estimating gradients may be useful independently, and log-polar sampling functions are included (and are available separately in submission 27023).
Can you please provide any reference upon which this work is based? It will be very helpful for me. Thanks
Avi: Thank you. And yes, I would always recommend trying the MathWorks toolbox first if it is available.
Thanks for the great submission.
The Computer Vision System Toolbox now includes optical flow in MATLAB.
Check out this link for information and code examples on optical flow: http://www.mathworks.com/discovery/optical-flow.html
The Matlab OOP capabilities were introduced with version 2008a, so yes, I think it should work with 2009a. It's worth trying, and if there are problems they should be minor ones that can be fixed. For example you may need to replace '~' as an unused argument or result with a variable name such as 'unused'.
The time I ran this I was using MATLAB 2007... you think it might work if I use R2009a?
Alfian: What Matlab version are you using? It may be the problem: this class uses the fairly recent Matlab OO system, and was tested in version 2010a.
Hi. I tried to run the demo code (with Jpeg images)... and got this error (but i think its not due to the jpegs)...
??? Error: File: affine_flow.m Line: 1 Column: 10
A class definition must be in an "@" directory.
MathWorks update: Added Live Script.
Fixed bug which caused error when sample step was greater than 1.
Minor corrections to comments.
Changed order of arguments in gsmooth2 and gradients_xyt.
Changed from a function to a class, for more efficient application to image sequences. (Argument checking etc. can be moved outside a loop, and some intermediate computations can be saved for later use.)
Fixed bug in use of ROI, allowed ROI in conjunction with log-polar sampling, simplified gradient computation by using exindex, minor changes to demo.
Inspired: Muscle fascicle tracking - Ultrasound
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.