A new dynamic masking technique for time resolved PIV analysis

Time resolved PIV encompassing moving and/or deformable objects interfering with the light source requires the employment of dynamic masking (DM). A few DM techniques have been recently developed, mainly in microfluidics and multiphase flows fields. Most of them require ad-hoc design of the experimental setup, and may spoil the accuracy of the resulting PIV analysis. A new DM technique is here presented which envisages, along with a dedicated masking algorithm, the employment of fluorescent coating to allow for accurate tracking of the object. We show results from measurements obtained through a validated PIV setup demonstrating the need to include a DM step even for objects featuring limited displacements. We compare the proposed algorithm with both a no-masking and a static masking solution. In the framework of developing low cost, flexible and accurate PIV setups, the proposed algorithm is made available through a freeware application able to generate masks to be used by an existing, freeware PIV analysis package.


Introduction
The employment of PIV (particle image velocimetry) has played a central role in experimental fluid mechanics since its introduction back in the late 70's (Archbold and Ennos 1972) as an extension of speckle metrology (Barker and Fourney 1977). The basic idea underlying the PIV technique is to reconstruct the flow field by measuring the velocity of particles seeded into the fluid, whose size and density are chosen to ensure and they follow the flow satisfactorily. The flow is illuminated by means of a laser/led source and the light scattered by the particles allows for their tracking. The reader is referred to the review works Grant (1997), Westerweel et al. (2013) for an in-depth description of the method. The basic 2D technique has evolved into peculiar setups, the most advanced ones being the single/multiplane stereoscopic PIV (Prasad 2000) and the volumetric/tomographic PIV (Scarano 2013). It has been broadly emploied in industrial and research applications requiring non-invasive measurement of a wide range of flow fields.
When the investigated flow field is influenced by solid standing boundaries, care must be taken in order to subtract the areas occupied by both the solid objects and their shadows from the region undergoing PIV analysis, by means of a static masking (SM) approach. Indeed, no seeding particle can be identified in such areas, therefore flow velocity reconstruction cannot be accomplished. If not properly handled, this masking phase can lead to erroneous predictions which, unfortunately, are not confined to the proximity of the boundaries of the shadowed areas.
The PIV technique can be applied to either steady state or time varying flows by tuning the acquisition frame rate to the time scales of interest. When the variability in time involves the position/shape of the solid objects, extra effort is needed in order to dynamically mask the images. It should be noted that not only solid objects need to be masked, but also different fluid phases (Foeth et al. 2006). This process is relatively easy if the motion of the solid objects is known a priori, and thus minimal modifications to the SM algorithms can serve the purpose. However, when the position and/or shape of the solid objects varies in time in an unknown way, a masking technique able to dynamically track the object is needed. The dynamic masking (DM) approach for PIV analysis is currently receiving a considerable amount of attention (Sanchis and Jensen 2011;Masullo and Theunissen 2017;Anders et al. 2019), thanks to the diffusion of time resolved PIV systems which, in turn, benefit from the increased availability of high speed cameras. The major advancements in DM techniques come from the field of micro-PIV (Lindken et al. 2009) applied to microfluidics, where the investigation of both the flow fields around micro-and nanoswimmers (Ergin et al. 2015) and multiphase flows (Brücker 2000;Khalitov and Longmire 2002) requires accurate and flexible algorithms. DM techniques are included in few commercially available PIV analysis software packages (TSI Instruments 2014; DantecDynamics 2018). Recent developments (Vennemann and Rösgen 2020) envisage the application of neural-network automatic masking techniques, which however require synthetic datasets to be generated in order to train the network.
Many algorithms employ image processing techniques to track the object, most of them requiring the user to develop ad-hoc experimental setups able to highlight the object to be tracked in the acquired images. The design of the experimental setup thus affects the final accuracy of the algorithm.
Several solutions can be envisaged. In the following, we will refer to a simple 2D PIV setup, but most considerations can be extended to more complex ones. The most straightforward way to render an object easily and accurately trackable in PIV setup is to illuminate it by means of a further source of light pointing to the direction which maximizes reflection towards the camera, usually roughly perpendicular to the PIV laser sheet. The main problem associated with this naive solution is that it is virtually impossible to aim the light source to the moving object alone without illuminating the ROI (region of interest) of the PIV, thus attenuating the contrast ratio between the laser light scattered by the seeding particles and the dark background.
The situation is harshened by the fact that the higher the frame rate of the camera, the lower the amount of light hitting the sensor. Provided both the solid object movement and the flow particles are slow enough compared to the rate of acquisition of the employed setup, a possible solution would be to interpose (not necessarily a symmetric interposition) a single diffuse light shot between the couples of laser pulses, and synchronize the camera shots to both of them: the position of the object at each laser couple can then be determined by interpolating the two positions in the previous and following shots, yielded by the diffuse light. This approach would require a synchronizer able to control the laser, the camera and the light, and a camera capable of a frame rate at least twice as high as the one strictly needed to capture the time scales characterizing the investigated flow field.
A solution to this problem has been proposed and consists of exploiting the bright reflections of the fluid interfaces (Foeth et al. 2006;Dussol et al. 2016) allowing to acquire a high amount of scattered laser light in the images. Solid surfaces can be provided with a reflective coating to enhance the effect. The object can be then identified as an abnormally large particle and its boundary easily tracked. The drawback of this solution is that the light scattered by the object surface also illuminates many seeding particles that do not lie in the laser sheet, thus progressively lowering the accuracy of the PIV analysis.
A refinement of the above approach employs a second co-planar laser sheet (Driscoll et al. 2003) of different wavelength: the light scattered by the surface of the object is very poorly reflected by the seeding particles, provided the latter are chosen with a narrow reflecting band centered around the first laser wavelength. The overall setup can become extremely expensive. The difference in wavelength emission could be exploited to make the setup inexpensive: the application of two cameras equipped with different filters would allow to identify fluorescent seeding particles independently of reflections from interfaces (Pedocchi et al. 2008).
When the displacements of the objects are small, a basic solution may be to extract one single static mask which best approximates the true time-varying shaded areas. A general rule of thumb would be to draw the mask slightly larger than the expected shaded areas, seeking the best trade-off between simplicity and minimization of the amount of illuminated areas subtracted to the analysis.
In this paper, we propose a new experimental approach to the problem of DM for PIV analysis. Our method encompasses a technique to make the object easily trackable using a fluorescent painting and a specific open source algorithm able to generate the time varying masks. The approach is proven to be effective by allowing for large displacements of objects opaque to the laser light. A comparison is made between our method, the no-masking (NM) and the static masking (SM) approaches. Besides demonstrating the validity of our approach, this paper further confirms that the masking phase is of paramount importance for obtaining accurate results. Indeed, when objects' displacements are non-negligible, the resort to DM is compulsory, with the SM approach inducing inaccuracies not limited to the surroundings of the shaded areas. The structure of the paper follows: we first introduce the rationale of the proposed approach describing the fluorescent coating technique and the masking software; then, after a description of the PIV setup, we assess the reliability of the whole PIV chain analysis by means of two benchmark cases; then, we compare the results of the proposed DM method against NM and SM solutions; finally, some conclusions are drawn.

Methods
The proposed DM technique envisages a fluorescent coating of the surface of the moving object in order to allow for its easy and accurate trackability in the same images captured for the PIV analysis. Once the object is made visible, a specific algorithm performs the object tracking and, provided the laser position is known (see Fig. 1), the masking of the shaded area.

Fluorescent coating
The coating consists of a dispersion of commercially available fluorescent powder (fluorescein ) in a structural matrix. In case of rigid objects, the matrix can be a polyester/epoxy (based on the chemical compatibility with the object material) transparent resin. In case of deformable objects, the matrix can be made of transparent silicone rubber. The fluorescent-coated object needs to be illuminated for a sufficiently long time prior to the experiment in order for it to constantly emit light during the run. We found that a 20 s long exposure to a 4W LED source (visible in Fig. 2) is largely sufficient to provide consistent fluorescence emission for the short duration of our experimental run (few seconds).
Given the substantial difference between the object and the particles size in our experiment, identification of the former is straightforward. Figure 3 shows a superimposition of both the seeding particles and the object shapes at three different times (coloring refers to different instants).
Instead, when such size-based classification is not feasible, separation of wavelengths of particles and object needs to be sought: such separation can be achieved either by choosing a fluorescent coating emitting at a markedly different wavelength from the light scattered by the seeding particles, or exploiting fluorescent particles emitting in a band far from the one of the laser (Pedocchi et al. 2008). In both cases, either channel isolation of a color image acquisition or ad-hoc filtering of a multicamera setup, can greatly facilitate object identification. In our case, there is no need to achieve such wavelength separation: indeed, the peak of the emission spectrum of the fluorescent coating is at 540 nm , very close to the 532 nm one of the employed laser.

Masking software
The developed algorithm for DM is an open-source freeware GUI-based tool (Prestininzi and Lombardi 2021) conceived to work in conjunction with the free PIV analysis package PIVlab (Thielicke 2020;Thielicke and Stamhuis 2014). It consists of the sequential run of three phases (referred to as a-b-c in Fig. 1): the first one (a) is aimed at locating the laser position in the scene (i.e., calculates the coordinates of the source of light hitting the obstacles); the second one (b) tracks the objects position and calculates the shaded areas for each frame; the third one (c) merges the tracked objects areas with the shaded ones into a single mask for the PIV algorithm.
More details for each phase follow: (a) The laser position can be either visible or not within the frame (i.e., in the field of view (FOV) of the acquired frames). In the former case, the user is simply required to locate the laser source by clicking on it in our GUI; in the latter case, the user is asked to draw two segments (two couples of points) belonging to the boundary of the shaded area: the laser position, which is located out of the FOV, is then calculated as the intersection of the two lines comprising the segments. The object shadow is assumed to reach the ROI frame box. (b) Once the laser position is known, the tracking of the objects is performed as follows: one channel (in our case, the green one since a RGB color space is employed; however, the GUI allows to specify the preferred channel) of each frame is binarized using a locally adaptive threshold (Bradley and Roth 2007), the latter being computed for each pixel using the local mean intensity around its neighbors. The binary image, comprising particles and objects, is then converted into regions. The only obstacle present in our experiment is identified based on its larger size compared to all the particles. Other strategies have been previously discussed. Then, the boundary polygon of the obstacle region is determined with a user defined density of points. A ray casting (RC) approach is here adopted for the determination of the shadow. RC falls in the framework of the ''light transport modelling'', which is at the basis of computer graphics. It is chosen here because it provides numerically exact shadows. Several other methods have been developed, mainly aimed at reducing the computational loads of the RC, though at the expense of accuracy. The algorithmic structure, adapted from Case (2015), is here briefly recalled: for each frame (not indexed here for the sake of clarity), a ray r ij is cast from the laser position L towards the ith vertex P ij of the jth object's bounding polygon; the aim is to find whether P ij belongs to the subset A j of the bounding vertices directly illuminated by the laser. P ij is added to A j if r ij crosses at least one side S kj (k spanning all sides of the jth object bounding polygon) after hitting P ij (that is the intersection Q ijk does not lie between the laser position and the vertex P ij ). The only two rays, namely q 1 and q 2 , which do not cross any additional side, are stored. (c) Once the set of vertices, namely A j directly illuminated by the laser, have been identified, the shaded portion of the ROI frame box is determined by intersecting the latter with q 1 and q 2 . The two intersections are appended to A j . The region enclosed by points in A j is finally converted to a mask.
In case of multiple laser sources, the RC algorithm needs to be applied to each of them, and the union of the shaded areas is taken. A pseudocode of the raycasting procedure is reported in Alg. 1.
In this section, we present the comparison between the PIV measurements carried out with the proposed DM and two other approaches, namely the no-masking (NM) and the static masking (SM) one.

Experimental setup
We designed the PIV setup and developed the present DM technique, in order to analyze the performance of vibration inducers (VIs) (Curatolo et al. 2019(Curatolo et al. , 2020. The latter are winglets able to induce regular and wide oscillations of a cantilever placed counterflow in a non-pulsating fluid flow. Such VIs are mounted at the tip of the cantilever (see Fig. 2) and feature two concave wings able to generate lift towards the neutral configuration of the cantilever at any point of the oscillating motion. The VIs are envisaged to enhance mechanical energy extraction from stationary fluid flows by means of piezoelectric patches mounted on the surface of the cantilever. The whole lateral edge of the wing, Fig. 1 Sketch of the dynamic masking procedure. Green lines are the borders of the fan laser sheet. The object is shown in yellow. a Two segments (depicted in orange) are drawn by specifying their endpoints P 1 , P 2 , P 3 and P 4 (red crosses); then the laser source position (green cross) is calculated by intersecting the segment extensions (dashed orange traces); any instant can be used to this purpose; b tracking of the time varying position of the object and subsequent identification of the portion of its boundary directly illuminated by the laser (cyan line, referred to as A j in the text); tracing of the two rays (red lines, referred to as q 1 and q 2 in the text) passing through the endpoints of A j line; c finding the two intersections of q 1 and q 2 with the ROI frame box (cyan circles, referred to as F j in the text) and masking of the area bounded by A j [ F j . Steps b and c are both carried out for all n instants t 2 t 1 ; t n ½ highlighted in Fig. 2, is coated with fluorescent paint according to the specifications described in Sect. 2.1.
The experiments are carried out in the free surface channel of the Hydraulics Laboratory of the Engineering Department of Roma Tre University. The 10.8 cm long cantilever is placed at the centerline of the channel, oriented upstream, and oscillates in the vertical-longitudinal plane. A ceramic perovskite (PZT) piezoelectric patch (7 Â 3 cm) made by Physik Instrumente (PI) is attached to the upper surface of the cantilever. It provides an AC electrical voltage difference consequent to its deformation under flow induced oscillations. The 2D velocity field in the vertical midplane of the left wing of the VI has been obtained by means of a homemade underwater PIV equipment. 1 A continuous wave, low cost, low power (150 mW), green (532 nm) laser beam is spread into a 2 mm thick fanned sheet of 120 intersecting one wing of the VI at half span as shown in Fig. 2. The water is seeded with polyamide particles with a mean diameter of 100 lm and a density of 1016 Kg/m 3 . The laser source is placed 15 cm above (roughly 4 cm below the free surface) and 5 cm downstream of the VI, inclined 5 upstream. The above setup is conceived to investigate mainly the wake of the wing. The upstream face of the wing and part of the downstream one are not directly hit by the laser sheet. A high speed commercial camera (Sony RX100 M5) shooting perpendicularly to the laser sheet is used to acquire a movie. The latter is recorded in high frame rate mode at 500 fps with a frame size of 1920 Â 1080 px, later cropped to a smaller 655 Â 850 px ROI to be analyzed during the image analysis. A time-resolved, freeware, open source, PIV analysis tool for MatLab is used (Thielicke and Stamhuis 2014). This tool employs a multipass direct Fourier transform correlation with interrogation area (IA) deformation (in our case 64 Â 64, 32 Â 32, and 26 Â 26). At each pass, the overlapping of 50% between adjacent IA is allowed in order to obtain additional displacement information at the borders and corners of each IA. After the first pass, particles displacement information is interpolated to derive the displacement of every pixel of the IA, which is deformed accordingly. The seeding particles number density is about 5 per IA at the first pass; according to Keane and Adrian (1992), such density value ensures a 95% valid detection probability. IAs are sized in order to ensure a sufficient permanence of particle within frame couples. The analyzed flow dynamics is characterized by laser cantilever PZT VI LED camera Fig. 2 Picture of the experimental setup in the channel, with a magnified 3D view of a generic VI. The red face is the one that was coated with fluorescent paint in the experiments flow velocities ranging between 0.4 and 0.7 m/s. Therefore, the particles appear in the third pass IA for roughly 3-4 frames, which is larger than the recommended minimum value of 2 frames (Keane and Adrian 1992).

Assessment of PIV chain analysis
The accuracy of the employed PIV algorithm has been previously exstensively assessed in literature (e.g., Guérin et al. (2020), Vennemann and Rösgen (2020), Mohammadshahi et al. (2020), Narayan et al. (2020)). However, in order to ensure the physical consistency of our PIV measurements, two benchmark cases are here presented.
The first one compares the vertical profile of longitudinal flow velocity measured by means of the same PIV setup described in Sect. 3.1 in the experimental channel with an analytical reference solution. The latter has been calibrated through PTV (particle tracking velocimetry) measurements carried out by means of floating tracers. The analytical velocity profile is described by Eq. 1 (Keulegan 1938).
where u is the horizontal flow velocity component, z is the vertical coordinate, d the bed roughness and v Ã the friction velocity assumed to be given by a uniform flow formula, namely u Ã ¼ U=C; U is the depth averaged flow velocity, and C is a friction coefficient given by C ¼ 5:75 log 13:3 f R=d ð Þ , R ¼ 0:2 m being the hydraulic radius and f ¼ 0:92 the shape factor for finite width channels. Figure  The second benchmark compares the amount of reattached flow over the back surface of the VI. Indeed, given the high camber of these devices, the flow detaches from the downstream surface and eventually reattaches. The amount of surface exhibiting attached flow is found (Curatolo et al. 2020) to be correlated with the efficiency of the VI in exciting the piezoelectric patch (i.e., efficiency is higher if larger and faster oscillations are induced). Here, we compare the length of the reattached flow at top dead point of the oscillation as measured through the PIV analysis, with the one predicted by a CFD (computational fluid dynamics) commercial code FLOW-3DÒ (Flow Science 2019), solving RANS (Reynolds-averaged Navier-Stokes) equations coupled with a k-turbulence closure on a structured grid (1 mm spacing is chosen for our simulations). The flow on the downstream side detaches and reattaches at several locations for such high  camber VI. The quantity compared in this benchmark is the length of the arc between the leading edge of the VI and the closest location of flow reattachment. With reference to Fig. 5, the length of the arc predicted by the CFD model is just 10% higher than the measured one. The PIV analysis, employing the DM technique presented in this work, is then demonstrated to provide physically sound measurements. A detailed analysis of the fluid mechanics of the wake and its correlation with the overall efficiency of the VI are currently ongoing and will be the object of future works.

Results
With reference to Fig. 6, we compare the results of the three approaches in terms of instantaneous flow velocity field. The chosen instant corresponds to the top dead point of the oscillation. The proposed DM (panel a of Fig. 6) yields a smooth flow field, which reveals coherent swirling structures in the wake.
The NM approach (panel b1 of Fig. 6) also correctly predicts the vortex structures in the wake, but yields largely inaccurate values in the shaded area. It is also evident that an a posteriori filtering of the obtained flow field is not feasible since no reasonable criterion can be inferred from the comparison. Indeed, the flow velocity has a ''reasonable'' magnitude also at locations where the largest errors are produced as can be observed in panel c1 of Fig. 6, where differences between the velocity fields obtained by DM and NM approaches are shown. Moreover, no filtering criterion can be formulated even assuming a plausible flow direction, since the highly unstable swirling motions, which develop in the wake, happen to move close to such locations. Even if the modeler was aware of such inaccuracies, the NM approach would yield a ''reasonable'' but still largely inaccurate flow field at the inner chord of the wing and just below it. Such behavior could be highly misleading.
Panel b2 of Fig. 6 shows the flow velocity field obtained with the SM approach, while panel c2 shows the differences between the results obtained with SM and DM approaches. The SM approach clearly shows an overall better accuracy compared to the NM counterpart, but this is due to the fact that the location of the laser source is such that the shaded area does not move much during the oscillation (see Fig. 3 for a visual inspection of the maximum displacement experienced by the VI during one oscillation); in other words, for the analyzed case, the choice of the neutral configuration to draw the static mask is sufficient to obtain an error lower than the NM approach. We would like to highlight that the superiority of the SM over the NM cannot be generalized, since any experimental setup encompassing larger object displacements would result in the NM to be consistently more accurate.
Although Fig. 6 exhaustively demonstrates the differences yielded by the analyzed approaches, in order to provide a more quantitative assessment of the results, frequency distributions of the errors have been computed. Inspection of such distributions in Fig. 7 confirms that the SM approach yields better overall predictions than NM, the SM distributions being more peaked. Nonetheless, the SM still produces spikes of abnormal intensity. Such values, represented by the tails of the distributions, are connected to an overestimation (left tail) and an underestimation (right tail) of the extent of the static mask. The magnitudes of the frequencies, however, rule out the applicability of both SM and NM for the considered case, making the resort to DM mandatory.

Conclusions
In this work, we present a new experimental technique aimed at providing PIV analysis tools with a dynamic masking (DM) module. Dynamic masking is a required step in time resolved PIV setups encompassing opaque moving/deformable objects immersed in the fluid flow. Along with the masking algorithm, we envisage the employment of fluorescent coating to allow for accurate tracking of the object. We present the measurements carried out by means of an in-house designed, low cost, PIV setup, comparing the proposed DM and two other approaches, namely the no-masking (NM) and the static masking (SM) one. Although the analyzed flow dynamics encompass limited displacement of the solid object, the quantitative comparison demonstrates the mandatory need to adopt a DM technique. The present experimental approach, whose accuracy is here proven, is coded into a freeware and user friendly package, whose output can be directly fed into a previously available freeware PIV analysis tool, thus tangibly aiding any implementation of low cost, though still very accurate, PIV setup.
Funding Open access funding provided by Università degli Studi Roma Tre within the CRUI-CARE Agreement.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.