View License

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

» Watch video

Highlights from
Figure to play and analyze videos with custom plots on top

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

5.0 | 2 ratings Rate this file 13 Downloads (last 30 days) File Size: 3.79 KB File ID: #29544 Version: 1.1
image thumbnail

Figure to play and analyze videos with custom plots on top


Joao Henriques (view profile)


26 Nov 2010 (Updated )

A figure ready to scroll through and play videos. You can also draw any custom graphics on it.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

VIDEOFIG(NUM_FRAMES, @REDRAW_FUNC) creates a figure with a horizontal scrollbar and shortcuts to scroll automatically. The scroll range is 1 to NUM_FRAMES. The function REDRAW_FUNC(F) is called to redraw at scroll position F (for example, REDRAW_FUNC can show the frame F of a video).

This can be used not only to play and analyze standard videos, but it also lets you place any custom Matlab plots and graphics on top.

Jiro posted a great example on the Pick of the Week blog, along with a nice GIF animation so you can see it in motion:


Place this in a file called "redraw.m":
  function redraw(frame)
      imshow(['AT3_1m4_' num2str(frame, '%02.0f') '.tif'])
Then from a script or the command line, call:
  videofig(10, @redraw);
The images "AT3_1m4_01.tif" ... "AT3_1m4_10.tif" are part of the Image
Processing Toolbox and there's no need to download them elsewhere.


Change the redraw function to visualize the contour of a single cell:
  function redraw(frame)
      im = imread(['AT3_1m4_' num2str(frame, '%02.0f') '.tif']);
      slice = im(210:310, 210:340);
      [ys, xs] = find(slice < 50 | slice > 100);
      pos = 210 + median([xs, ys]);
      siz = 3.5 * std([xs, ys]);
      imshow(im), hold on
      rectangle('Position',[pos - siz/2, siz], 'EdgeColor','g', 'Curvature',[1, 1])
      hold off
The keyboard shortcuts are:
  Enter (Return) -- play/pause video (25 frames-per-second default).
  Backspace -- play/pause video 5 times slower.
  Right/left arrow keys -- advance/go back one frame.
  Page down/page up -- advance/go back 30 frames.
  Home/end -- go to first/last frame of video.
See HELP VIDEOFIG for more options.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
12 Dec 2015 Renaud

Renaud (view profile)

Very Helpful function!!!
One question: Is there a way to save the processed frames into an .avi file?


09 Aug 2013 Iván

Iván (view profile)

This is excellent!!
It's more than what I was looking for!
Thanks! =)

12 Dec 2010 1.1

Added a link to Jiro's example, and rearranged the file's description a bit.

Contact us