Tutorial 1 – URAPIV analysis of AVI video clip

Tutorial 1: Use of URAPIV with the AVI files

Matlab allows to read AVI files with the aviread() function, so we change the input subroutine from ReadImDir() to:

A = aviread(‘test.avi’);

One can also specify a region of the image that is of interest and crop out the rest, saving some computational time during the batch run:


A(i).cdata is an access to the ‘cdata’, the image of the frame ‘i’. imcrop(), and imshow() should be known to our users. For more info, please use the >> help imshow command. Thus, reading the two successive frames in a loop by:

I = imcrop(imadjust(A(fileind).cdata),rect);
J = imcrop(imadjust(A(fileind+jump).cdata),rect);

where jump is a number of frames ‘to jump’ for the correlation analysis. It’s an important parameter that defines the time interval between the successive images that are correlated, thus defining the velocity to displacement scale, but also important for the PIV analysis in a (typical) case of oversampling. The high-speed cameras, used more and more often today, easily over-sample the flow, recording the images at the frame rates higher than the flow changes. Therefore, most recent versions of URAPIV (available on the Sourceforge.net ) all include the ‘jump’ parameter. It’s an important advantage over some sophisticated commercial packages that does not allow such an option without renaming actually the images.

We also use an additional trick for visualizing the pair of images. The two gray level images, I and J, are concatenated together in a 3D, RGB image, becoming a layers of two distinct colors, e.g. red and blue. Then, an image shows instantaneously the displacement between two at all points of the image:


So, one can use the urapiv_avi.m file, run it as the help command says:

vel = urapiv_avi(‘test.avi’,[32 32],[16 16],2,1,1,10,[40 361 1241 365],3,1);

Note that ‘crop’ now is also in pixels and not in the units of 32 pixels, as it was before. It’s actually easy to read the first frame, show it and crop it manually, generating once the ‘crop_vector’ parameter and providing it as an input to the urapiv_avi.m file. After the crop_vector, there are two new inputs: JUMP and VERBOSE. The last is 1 for the visualization and verbose output, or 0 for a faster and silent batch run.


URAPIV group

The result of this run should look like this:


The story behind this image is in our blog section, press here to read it.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s