mpiv_filter.m is to post-process the output from mpiv. It includes two parts: spurious vectors elimination and missing vectors interpolation. mpiv_filter.m is an external function (.m file) in MATLAB with a format as following:
function [iu_f, iv_f, iu_i, iv_i] = mpiv_filter( iu, iv, ...
i_filter, vec_std,...
i_interp, i_plot )
The input parameters to mpiv_filter.m are:
iu, iv : input vectors from the output of mpiv.m
i_filter : = 1, standard filter
= 2, median filter
= 3, global filter
i_filter = 2 (or 1) is recommended
vec_std : threshold value to eliminate error vectors.
typical value of vec_std is between 1.5 and 2.0
i_interp : = 1, linear interpolation
= 2, cubic-spline interpolation
= 3, Kriging interpolation
= 0, no interpolation
i_interp = 3 is recommended
i_plot : = 1; plot result during piv process with pause for check
otherwise, no plot
The filter uses a small area (typically 3
3 to 9
9
vectors) to calculate the mean, median, and standard deviation,
and the number of valid vectors (with values other than NaN) in
the area. The size of the area is determined by a preset threshold
value for the number of valid vectors. The size of the area increases when the number of valid vectors is below this value. It
outputs NaN when reaching the preset maximum size while containing less than the
threshold vector number. In calculating the statistical values (e.g., mean, median, and standard deviation), the vectors
with a value outside the range of twice the r.m.s. value are not included in the
calculation to avoid the influence of these potential bad vectors with large deviations.
The standard and median filters use the calculated mean, median, and standard
deviation to determine whether the vector of interest (called target
vector hereafter) is spurious or not. If the target vector is within
the range of vec_std
standard deviation from the mean or median value (for standard and median filter, respectively), it is then considered as a good vector.
It is otherwise removed from the `valid vectors' and replaced with NaN.
The interpolation is to assign a value for each NaN vectors. Similar to the filter, an expandable small area is used to interpolate each vector if Kriging method is chosen. Note that with more than one continuous NaN vectors neighboring to each other, only Kriging method gives interpolated results (the other two interpolation methods keep NaN in the output). Therefore the Kriging method is recommended in the filtering process for most cases. However, Kriging is computational intensive. It may take a significant portion of time in the PIV processing (if the recursive process is chosen) and post-processing.
The output of mpiv_filter.m contains two sets of velocity vectors:
iu_f, iv_f : filtered velocity matrices in x and y without interpolation iu_i, iv_i : filtered velocity matrices in x and y with interpolationNote that all the error vectors in iu_f and iv_f as well as in other inputs and outputs throughout mpiv are denoted as NaN.