File Exchange

image thumbnail

Affine optic flow

version 1.3 (1.03 MB) by

Estimates the parameters of an affine (first-order) optic flow model from two images.

22 Downloads

Updated

View License

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).

Comments and Ratings (9)

paperboat

Can you please provide any reference upon which this work is based? It will be very helpful for me. Thanks

David Young

David Young (view profile)

Avi: Thank you. And yes, I would always recommend trying the MathWorks toolbox first if it is available.

Avi Nehemiah

Avi Nehemiah (view profile)

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

Michael

Works great!

David Young

David Young (view profile)

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?

David Young

David Young (view profile)

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.

Glen Lichtwark

Glen Lichtwark (view profile)

Updates

1.3

MathWorks update: Added Live Script.

1.3

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.

1.2

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.)

1.1

Fixed bug in use of ROI, allowed ROI in conjunction with log-polar sampling, simplified gradient computation by using exindex, minor changes to demo.

MATLAB Release
MATLAB 9.0 (R2016a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video