Tutorial for the iterative PIV plugin

Introduction

This iterative PIV program implements two methods for image correlation. The first one is the most conventional cross-correlation method. It is a rather primitive implementation using the ImageJ's built-in FHT.conjugateMultiply function. As a result, only interrogation window with a power of 2 size will be accepted. Each PIV result will serve as window preshift for the next PIV iteration, so that large displacement could still be catch when small interrogation window was used. However, if this window preshift value was not correct, then the subsequent PIV could be made on two irrelevant interrogation windows and cause erroneous result.

The second method employs the template matching method using normalized correlation coefficient algorithm. It has several advantages: first, the interrogation window is compared against a larger searching window, ensuring the feature (image under the interrogation window) will be presented in the searching area. The PIV information from previous round only served as a guidance for determining the correlation peak. Second, the normalized algorithm is less sensitive to background intensity variation and allows one to define a threshold to distinguish high and low image correlations, so that the correlation made on small interrogation window presenting insufficient features which tends to be erroneous can be easily filtered out and replaced by interpolated value.

It is highly recommended to use this plugin with the template matching method in order to obtain better result. Please refer to the installation section for more detail. 

 A synthetic image from the JPIV 

 Iterative PIV using conventional cross-correlation algorithm. Note that large displacement was lost as interrogation window got smaller.

 Iterative PIV using normalized correlation coefficient algorithm (Template matching)

Parameter setting

Under the plugins>PIV menu, you can find "iterative PIV(Basic)...", and "iterative PIV(Advanced)...". A simpler parameter dialog will be shown if "iterative PIV(Basic)..." was called.

Basic Dialog

By default, you can do 3 passes of PIV, with decreasing interrogation window size. Using 1/4 the image dimension for the 1st interrogation window could be a good starting point. The search window size should always be larger or equal to the interrogation window. If you know the expected maximum displacement value, you can set the search window size as (interrogation window + 2*maximum displacement). Otherwise, search against twice as large as the interrogation window would be fine. Setting the searching window equal to the interrogation window will turn the PIV program into conventional cross-correlation mode (less recommended, but you don't need to install the OpenCV library).

In the basic dialog, the spacing between each interrogation window (the spacing of vectors in PIV result) is automatically set as half the interrogation window size.

The correlation threshold value defines to what extent we should keep the correlation result. Since in the normalized correlation coefficient algorithm the correlation value is ranged from 1 (exact match) to -1 (zero correlation), we can use this value to filter out the result obtained from images with insufficient feature for matching. Setting a high threshold value will leave only vectors resulting from highly matched images, while other vectors with correlation value lower than the threshold will be interpolated by surrounding values (replaced by the median value of the 8 neighbors). Note that this correlation value threshold doesn't work in the conventional cross-correlation mod, since the correlation value will change from image to image and is not normalized. 

Advanced Dialog

In the advanced dialog, you can load a previous PIV data before beginning the 1st pass PIV, which permit one to do more than 3 PIV iteration. The three check boxes under the correlation threshold are rather experimental options. The "advanced peak check" option permit the user to use another set of conditions to determine which might be the correct correlation peak (thus the corrector displacement vector). This set of conditions are empirically optimized for the bead tracking in traction force microscopy. The option "disable all peak checking" will force the program to use only the highest correlation peak and discard all the peaks with correlation value lower than the threshold. If the option "Don't replace invalid vector by median" was selected, all the invalid vector (judged by the correlation value or/and by the deviation from the previous PIV vectors) will be left as zero value without any interpolation.

If the "batch mode" option was selected, the post-processing dialog won't show up after the last PIV iteration and the result will be saved automatically to the specified path. 

Post-processing

A post-processing dialog will pop up after the last PIV iteration. The user can choose between two PIV post-processing method: the normalized median test and the dynamic mean test. (see Raffel et. al. Particle image velocimetry : a practical guide. 2nd ed.); restore the original PIV result if the post-processing goes wrong; or choose to accept this PIV result and save it.

PIV data format

The PIV result will be stored in plain text file. Each line in this file correspond to each PIV vector and comprised of 16 columns:

(x,y) is the position of the vector (center of the interrogation window).

ux1, uy1 are the x and y component of the vector (displacement) obtained from the 1st correlation peak.

mag1 is the magnitude (norm) of the vector.

ang1, is the angle between the current vector and the vector interpolated from previous PIV iteration.

p1 is the correlation value of the 1st peak.

ux2,uy2,mag2,ang2,p2 are the values for the vector obtained from the 2nd correlation peak.

ux0, uy0, mag0 are the vector value at (x,y) interpolated from previous PIV iteration.

flag is a column used for mark whether this vector value is interpolated (marked as 999) or switched between 1st and 2nd peak (marked as 21), or invalid (-1).

Only the first 5 columns are used for vector plot.

Batch processing

It is possible to call this plugin in ImageJ's macro language. You can use the Plugins>Macros>Record... function to record all the parameters. Or just use:

run("iterative PIV(Advanced)...", "  piv1=128 sw1=256 vs1=64 piv2=64 sw2=128 vs2=32 piv3=50 sw3=100 vs3=50 correlation=0.6 batch path=[/Users/xxx/Desktop/] " );

piv1, sw1, vs1 are the interrogation window, search window and vector spacing for the 1st pass

piv2, sw2, vs2, piv3, sw3, vs3 are the parameters for the 2nd and 3rd pass.

correlation is the threshold value of correlation peak

batch specifies the batch mode.

path is the location the result will be saved.

### If you use javascript, use "save="  instead of "path="

ex:

IJ.run(imp, "iterative PIV(Cross-correlation)...", "piv1=128 piv2=64 piv3=0 what=[Accept this PIV and output] noise=0.20 threshold=5 c1=3c2=1  save=D:\20110819b\out\segmented_89.tif.txt batch");

(Thanks to Kota Miura to point this out.)

Vector plot

There is a plotting function in this PIV plugin for visualization the PIV data afterward. It is under the Plugins>PIV>plot... 

If the "autoscale" was selected, the vector length and color coding will be automatically set according to the maximum vector value. Otherwise, the vector scale and the maximum value for the color code can be set manually so that different PIV result can be visually compared. If you know the original image size, you can give them as plot width and height. Leave both of them as zero will ask the program to guess the plot dimension from the PIV data. You can also choose to display the vector scale and color code as well as the vector magnitude plot. The LUT field is set to S_Pet by default, but you can choose any other lut from your ImageJ's lut folder.

Vector plot

Magnitude plot

Scale Graph

PIV analysis on the image from PIV challenge 2003