1 Introduction

Global velocity diagnostics is of fundamental importance in the study of fluid mechanics in order to understand the physics of complex flows. Particle image velocimetry (PIV) is a widely used global velocity measurement technique. The working principles and applications of PIV have been comprehensively described in the books by Raffel et al. (2007) and Adrian and Westerweed (2011). Since the early development of PIV (Adrian 1991), significant technical improvements have been made in both hardware and software, which have enabled PIV application to various scientific disciplines. Nowadays, PIV has become a standard technique for global velocity measurements in fluid mechanics and aerodynamics laboratories. In spite of rapid technical advances in PIV hardware such as cameras, lasers, optics, and particle-seeding devices, the central problem in image processing remains the same, that is, how to extract high-resolution displacement (velocity) vectors from a pair of particle images taken at two different moments. Tracking individual particles can be performed in low-density particle images (Dracos and Gruen 1998; Maas et al. 1993). For high-density particle images, a physically intuitive approach is to determine a displacement vector by maximizing the correlation peak in the spatial cross-correlation map obtained from two corresponding interrogation windows in successive particle images. The cross-correlation between particle images can be directly evaluated via the fast Fourier transform (FFT) algorithm according to the convolution theorem of the Fourier transform. Therefore, the correlation method is a key element in PIV processing. The displacement determined by using such approach could be physically interpreted as a spatially averaged displacement of a particle group within the interrogation window. The methods and algorithms for PIV interrogation have been intensively studied, and the performance of various research and commercial algorithms has been critically evaluated, for example, in the workshops of International PIV Challenge (Stanislas et al. 2003, 2005, 2008).

In contrast to the mature and straightforward cross-correlation method (correlation method in short) adopted in PIV, the optical flow method is not widely known and used in the experimental fluid mechanics community. The global variational optical flow method was originally developed by computer vision scientists to track the motion of objects (e.g., people and cars) in video images (Horn and Schunck 1981). The optical flow is loosely defined as an apparent velocity field in the image plane that is generated by projection of the moving objects in the three-dimensional (3D) object space. The true physical meaning of the optical flow depends on the imaging process of the radiation associated with a specific physical phenomenon investigated. Without dealing with any specific physical process, Horn and Schunck (1981) first gave a model equation called the brightness constraint equation for the optical flow, which has been followed by researchers who have since proposed various revised models (Barron et al. 1994; Haussecker and Fleet 2001). To determine the optical flow, the brightness constraint equation is solved as an inverse problem via the variational method to minimize the L 2-norm with the first-order Tikhonov regularization functional. This leads to the Euler–Lagrange equations to be solved numerically with suitable boundary conditions in the image domain. A high-resolution velocity field could be extracted from images at one vector per pixel. In computer vision, local optimization methods based on subdomains like the Lucas–Kanade method similar to correlation method are also classified into optical flow methods (Baker and Mathews 2004). In this paper, the global variational method is specifically referred to as the optical method.

To fluid mechanics experimentalists, the optical flow method is less intuitive, particularly in terms of the direct connection between the optical flow and the fluid velocity. However, this approach could be adapted for the determination of high-resolution velocity fields from various images of continuous patterns (like cloud and ocean images in satellite imagery) particularly in geophysical fluid mechanics. Quenot et al. (1998) proposed an optical flow method with dynamical programming for PIV images. Ruhnau et al. (2005) and Yuan et al. (2007) used the brightness constraint equation for PIV images. Corpetti et al. (2002, 2006) proposed the integrated continuity equation in the image plane under the assumption that the radiance is proportional to an integral of the fluid density across a measurement domain. This assumption is valid for light transmittance through a fluid with a variable density (Wildes et al. 2000; Héas et al. 2007). The optical flow method based on the integrated continuity equation was applied to PIV images in a mixing layer and a wake behind a circular cylinder (Corpetti et al. 2006), and results were in good agreement with hot-wire probe measurements of mean velocity profiles and turbulence quantities. The review article by Heitz et al. (2010) provides a comprehensive introduction to the optical flow method applied to fluid flow measurements, including the discussions on the first-, higher-order and physics-based regularization terms for optimization.

To lay a rational foundation for application of the optical flow method to fluid flow measurements, the key problem is to build the quantitative connection between the optical flow and the fluid flow velocity for various flow visualizations. Based on the projection of the transport equations in the 3D object space onto the image plane, Liu and Shen (2008) have derived the projected motion equations for various flow visualizations including laser-sheet-induced fluorescence images, transmittance images of passive scalar transport, schlieren, shadowgraph and transmittance images of density-varying flows, transmittance and scattering images of particulate flows, and laser-sheet-illuminated particle images. Further, these equations are recast into the physics-based optical flow equation in the image plane, where the optical flow is proportional to the light-ray-path-averaged velocity of fluid (or particles) weighted in a relevant field quantity like dye concentration, fluid density or particle concentration. Using the optical flow method, Liu et al. (2012) have studied the unique intrinsic flow structures of Jupiter’s Great Red Spot (GRS) based on high-resolution velocity fields extracted from the NASA Galileo 1996 cloud images of the GRS.

The extraction of velocity fields from images by using the optical flow method is mathematically treated as an inverse problem. This approach is popular in computer sciences and applied mathematics, which is not familiar to most fluid mechanics experimentalists. It is tempting to apply optical flow algorithms directly to images optimized for correlation PIV (in terms of particle-seeding density, pixel shift, etc.) since PIV has been so widely used in major fluid mechanics laboratories in the world. Although some encouraging results were obtained by Corpetti et al. (2006) in application of the optical flow method to PIV measurements in a mixing layer and a wake, it seems puzzling that the optical flow algorithms tested in the workshops of International PIV Challenge failed to exhibit superior spatial resolution and accuracy (Stanislas et al. 2008). Therefore, at this stage, the applicability of the optical flow method to PIV images has not been fully established. There are several possible reasons for this difficulty. First, in contrast to the correlation method that is essentially an integral approach, the optical flow method as a differential approach is, in principle, better suited to images of continuous patterns. This is because accurate computations of the time derivative and the spatial gradient of the image intensity field are required. From this perspective, images of discrete particles are probably the worst case for the optical flow method, since they are basically non-smooth spatial random noise distributions. The optical flow method works well on PIV images only when certain constraints are satisfied. In addition, there is lack of sufficient understanding of the relevance of the optical flow to the fluid velocity or the physical meaning of the optical flow. These problems should be addressed through simulations based on the physics-based optical flow equation derived from the relevant governing equation for a specific flow visualization technique (PIV in this case).

This work is a quantitative comparative study between the optical flow and cross-correlation methods applied to PIV images through simulations and physical measurements. The working principles of the physics-based optical flow method are recapitulated first, including the optical flow equation, mathematical definition and physical meaning of the optical flow, variational formulation, error analysis, and selection of the relevant parameters in optical flow computation. Then, an expression for error estimation is given, which depends on the four parameters: particle displacement, particle velocity gradient, particle image density, and particle image diameter. The mathematical connection between the optical flow and the particle velocity in PIV is discussed. Quantitative evaluations of the optical flow method and the well-established correlation method (LaVision DaVis 7.2) are made in the parametric space through simulations of measurements of an Oseen vortex pair in uniform flow. Further comparisons are made in physical PIV measurements in a normal impinging air jet.

2 Basic equations for optical flow method

2.1 Physics-based optical flow equation

Flow visualization techniques rely on tracers (such as particles and dyes) or on the change of certain physical properties of fluid (such as the density) to capture flow structures. Digital images of flow visualization are obtained by using sensors that detect radiation with a certain wavelength bandwidth from a fluid medium in a flow. The perspective projection from a fluid medium onto an image is illustrated in Fig. 1. The orthogonal row vectors (m 1 , m 2 , m 3 ) in the rotational matrix in the collinearity conditions constitute a special object space coordinate frame located at the perspective center associated with a camera/lens system. The vectors m 1 and m 2 are the directional cosine vectors parallel to the x 1- and x 2-axis in the image coordinate system, respectively, while m 3 is normal to the image plane. The object coordinates \(\varvec{X} = (X_{1} ,X_{2} ,X_{3} )\) are denoted as the projections of the object space position vector from the perspective center in this frame. As shown in Fig. 1, the visualized flow domain is confined by two control surfaces \(X_{3} = \varGamma_{1} (X_{1} ,X_{2} )\) and \(X_{3} = \varGamma_{2} (X_{1} ,X_{2} )\) that could be virtual or solid. In many cases, the planar control surfaces \(X_{3} = \varGamma_{1} = {\text{const}}.\) and \(X_{3} = \varGamma_{2} = {\text{const}}.\) are used.

Fig. 1
figure 1

Projection from fluid flow onto the image plane

Liu and Shen (2008) have derived the projected motion equations for typical flow visualizations including laser sheet visualization of particles in flows (PIV). The projected motion equations for these different flow visualizations have a generic form of the transport equation, which can be expressed in the image coordinates by using the perspective projection transformation between the object space coordinates \(\varvec{X} = (X_{1} ,X_{2} ,X_{3} )\) and the image coordinates \(\varvec{x} = (x_{1} ,x_{2} )\). Therefore, the physics-based optical flow equation in the image plane is given by

$$\frac{\partial g}{{\partial {\kern 1pt} t}} + \nabla \cdot (g\varvec{u}) = f(x_{1} ,x_{2} ,g),$$
(1)

where \(\varvec{u} = (u_{1} ,u_{2} )\) is the velocity in the image plane referred to as the optical flow, g is the normalized image intensity that is proportional to the radiance received by a camera, \(\nabla = \partial /\partial {\kern 1pt} x_{\beta }\) is the spatial gradient, and \(\nabla^{2} = \partial^{2} /\partial {\kern 1pt} x_{\beta } \partial {\kern 1pt} x_{\beta }\) is the Laplace operator. The right-hand-side term in Eq. (1) is defined as

$$f(x_{1} ,x_{2} ,g) = \lambda^{2} D\nabla^{2} g + DcB + \left. {c\varvec{n} \cdot (\psi \varvec{U})} \right|_{{\varGamma_{1} }}^{{\varGamma_{2} }} ,$$
(2)

where D is the diffusion coefficient, c is a coefficient for fluorescence, scalar absorption, or particle scattering/absorption, and \(B = - \varvec{n} \cdot \nabla \psi |_{{\varGamma_{1} }}^{{\varGamma_{2} }} - \nabla_{12} \cdot (\psi |_{{\varGamma_{2} }} \nabla_{12} \varGamma_{2} + \psi |_{{\varGamma_{1} }} \nabla_{12} \varGamma_{1} )\) is a boundary term that is related to a field quantity ψ and its derivatives coupled with the derivatives of the control surfaces confining the illumination domain. Depending on the flow visualization techniques, the field quantity ψ could be the scalar (e.g., dye) concentration in flows, fluid density in density-varying flows, or particle number per unit total volume for particulate flows. For PIV images, ψ represents the particle density in the fluid under investigation. The third term in the right-hand side of Eq. (2) represents the accumulation effect of the quantity ψ in the volume across the control surfaces.

The optical flow is mathematically given by

$$\varvec{u} = (u_{1} ,u_{2} ) = \lambda \left\langle {\varvec{U}_{12} } \right\rangle_{\psi } ,$$
(3)

where λ is a scaling factor in the projection transformation. The optical flow is proportional to the path-averaged velocity weighted with the field quantity ψ related to a visualizing medium, which is defined as

$$\left\langle {\varvec{U}_{12} } \right\rangle_{\psi } = \frac{{\int_{{\varGamma_{1} }}^{{\varGamma_{2} }} {\psi \varvec{U}_{12} \,{\text{d}}X_{3} } }}{{\int_{{\varGamma_{1} }}^{{\varGamma_{2} }} {\psi \,{\text{d}}X_{3} } }} ,$$
(4)

where \(\varvec{U}_{12} = (U_{1} ,U_{2} )\) are the projected components onto the coordinate plane \((X_{1} ,X_{2} )\) of the fluid or particle velocity \({\varvec{U}} = (U_{1} ,U_{2} ,U_{3} )\) in the object space frame (m 1 , m 2 , m 3 ) (see Fig. 1). The physical meaning of the optical flow is clearly given in Eq. (3). In the special case where \(g{\kern 1pt} {\nabla } \cdot \varvec{u} = 0\) and f = 0, Eq. (1) is reduced to the Horn–Schunck brightness constraint equation \(\partial \,g/\partial {\kern 1pt} t + \varvec{u} \cdot \nabla g = 0\) (Horn and Schunck 1981). In general, the optical flow is not divergence-free, i.e., \(\nabla \cdot \varvec{u} \ne 0\).

2.2 Variational solution

To determine the optical flow, a variational formulation with a smoothness constraint is typically used (Horn and Schunck 1981), which in fact is the first-order form of the Tikhonov’s formulation for ill-posed problems (Tikhonov and Arsenin 1977). Given g and f, we define a functional

$$J(\varvec{u}) = \int_{\varOmega } {\left[ {\partial g/\partial {\kern 1pt} t + \nabla \cdot (g\varvec{u}) - f} \right]^{2} {\text{d}}x_{1} {\text{d}}x_{2} } + \alpha \int_{\varOmega } {\left( {\left| {\nabla u_{1} } \right|^{2} + \left| {\nabla u_{2} } \right|^{2} } \right){\text{d}}x_{1} {\text{d}}x_{2} } ,$$
(5)

where α is the Lagrange multiplier and Ω is an image domain. By minimizing the functional, i.e., \(J(\varvec{u}) \to \text{min}\), we obtain the Euler–Lagrange equation

$$g\nabla [\partial g/\partial t + {\nabla } \cdot (g\varvec{u}) - f] + \alpha {\nabla }^{2} \varvec{u} = 0.$$
(6)

The standard finite difference method is used to solve Eq. (6) with the Neumann condition \(\partial \varvec{u}/\partial n = 0\) on the image domain boundary \(\partial \varOmega\) for the optical flow (Liu and Shen 2008). The solution of the Horn and Schunck’s equation can be used as an initial approximation for Eq. (6) for faster convergence. The above-variational formulation is based on the L 2-norm of Eq. (1) with the first-order Tikhonov constraint functional. To preserve the discontinuity in velocity fields, the variational formulation with the L 1-norm has been proposed by Aubert and Kornprobst (1999) and Aubert et al. (1999). A mathematical analysis of the variational solution of Eq. (1) in the weaker conditions based on the L 1-norm and an iterative numerical algorithm are given by Wang et al. (2015). Although the first-order Tikhonov constraint functional is physically plausible, it is not derived from the first principles. A recent effort has been made by incorporating certain physical mechanisms in turbulent flows into the constraints in optical flow computations (Cassisa et al. 2011; Zille et al. 2014; Chen et al. 2015).

2.3 Selection of parameters in optical flow computation

The optical flow algorithm used in this work has the Horn–Schunck estimator for an initial solution (Horn and Schunck 1981) and Liu–Shen estimator for a refined solution of Eq. (1) (Liu and Shen 2008; Wang et al. 2015). The main parameters are the Lagrange multipliers selected in the Horn–Schunck and Liu–Shen estimators. Before optical flow computation, pre-processing of images is sometimes required to remove the random noise and reduce the possible systematic error associated with the illumination intensity change. The relevant parameters in pre-processing and optical flow computation should be suitably selected. A Gaussian filter is usually applied to images to remove the random noise and make the particle images more continuous for suitable optical flow computation. The standard deviation (std) of a Gaussian filter is selected depending on the specific application (for example, the std of a Gaussian filter is 4–6 pixels for images of 480 × 520 pixels).

In optical flow computation, it is assumed that the illumination light intensity for flow visualization remains constant. This assumption is valid in the well-controlled laboratory conditions, and for example, the laser sheet intensity in PIV is usually repeatable in normal testing conditions. However, when an illumination intensity field changes in a time interval between two successively acquired images, it is necessary to equalize (or normalize) the overall intensity of the images and correct the local illumination intensity change. For example, in multiple-spectral imaging of Jupiter’s atmosphere structures by spacecraft, the illumination intensity field provided by the Sun could be locally and non-uniformly changed during image acquisition between a relatively long period (in hours) due to the relative motion between the Sun, Jupiter, and spacecraft. In this case, correction for this illumination intensity change is required before applying the optical flow method to the images. A simple illumination intensity correction scheme is described in Sect. 4.3, which is also based on application of a Gaussian filter. The selection of the std (or size) of a Gaussian filter is important. When the size of a filter is too large, the local variation associated with the illumination intensity change in images cannot be corrected. On the other hand, when the filter size is too small, the apparent motion of features in the two images would be artificially reduced after the procedure is applied. The selection of the filter size is a trial-and-error process in a specific measurement, and simulations on a synthetic velocity field are used to determine the suitable size. In an example given in Sect. 4.3, the 30-pixel std of a Gaussian filter is used for correction of a non-uniform illumination intensity change.

When the particle displacements are large (for example more than 10 pixels), the error would be large as indicated by the error analysis in Sect. 3.1. In this case, a coarse-to-fine iterative scheme can be used (Heitz et al. 2008). First, the original images are suitably downsampled by using the wavelet transform so that the displacements in pixels are small enough (1–5 pixels). A coarse-grained velocity field is obtained by applying the optical flow algorithm to the downsampled images. The resulting coarse-grained velocity field is then used to generate a synthetic shifted image with the same spatial resolution as the original image #1 (i.e., the first one in the two successive images) by using an image-shifting (image-warping) algorithm with an embedded spatial interpolation scheme. This algorithm uses a translation transformation for large displacements and the discretized optical flow equation for sub-pixel correction. Next, the velocity difference field between the synthetically shifted image and the original image #2 is determined by using the optical flow algorithm, and it is added on the initial velocity field for correction or improvement. Thus, a refined velocity field is successively recovered by iterations to achieve a better accuracy.

There is no rigorous theory for determining the Lagrange multiplier in the variational formulation of the optical flow equation. The Lagrange multiplier acts like a diffusion coefficient in the corresponding Euler–Lagrange equations. Therefore, a larger Lagrange multiplier tends to smooth out finer flow structures. In general, the smallest Lagrange multiplier that still leads to a well-posed solution is selected. However, within a considerable range of the Lagrange multipliers, the solution is not significantly sensitive to its selection. Simulations based on a synthetic velocity field for a specific measurement are usually carried out to determine the Lagrange multiplier by using an optimization scheme.

3 Error analysis

3.1 Error propagation

The variational formulation and the corresponding Euler–Lagrange equations allow a systematic error analysis of optical flow computation (Liu and Shen 2008). In a sensitivity analysis, the image intensity and optical flow are decomposed into a basic solution and an error, i.e., \(g = g_{o} +\Delta g\) and \(\varvec{u} = \varvec{u}_{\text{o}} +\Delta \varvec{u}\), where \(g_{\text{o}}\) and \(\varvec{u}_{\text{o}}\) satisfy exactly Eq. (6), \(\Delta \varvec{u}\) is the resulting error in optical flow computation and \(\Delta g\) is a variation or difference in the image intensity measurement. By substituting \(g = g_{\text{o}} +\Delta g\) and \(\varvec{u} = \varvec{u}_{\text{o}} +\Delta \varvec{u}\) into Eq. (6) and neglecting higher-order terms, an error propagation equation can be obtained, where the elemental error sources are \(\Delta (\partial g/\partial t)\), \(\Delta ({\nabla }g)\), \(\Delta ({\nabla } \cdot \varvec{u})\) and \(\Delta g\).

To understand the error limitation of the optical flow method, an ideal case is considered where the elemental errors \(\Delta ({\nabla }g)\), \(\Delta (\nabla \cdot \varvec{u})\) and \(\Delta g\) vanish, and the optical flow error \(\Delta \varvec{u}\) is mainly produced by \(\Delta (\partial g/\partial t)\). For the first-order time difference, an estimate is given by \(\Delta (\partial g/\partial t) \cong - g_{tt}\Delta {\kern 1pt} t /2\), where \(g_{tt} = \partial^{2} g /\partial t^{2}\) and \(\Delta {\kern 1pt} t\) is a time interval between two consecutive images. In this case, an estimate for the error of the optical flow is given by

$$g\nabla \left[ { - \left\| {\nabla g} \right\|_{\text{char}}^{ - 1}\Delta tg_{tt} /2 + \left\| {\nabla g} \right\|_{\text{char}}^{ - 1} \nabla g \cdot (|\varDelta \varvec{x}||\varvec{u})} \right] + \alpha \left\| {\nabla g} \right\|_{\text{char}}^{ - 1} \nabla^{2} (\Delta \varvec{u}) = 0,$$
(7)

where a characteristic intensity gradient magnitude \(||\nabla g||_{\text{char}}\) is used for normalization, which can be suitably defined depending on the application. Specifically, the characteristic norm \(|| \cdot ||_{\text{char}}\) is defined as a L 2-norm in a given domain. The term \(\left\| {\nabla g} \right\|_{\text{char}}^{ - 1}\Delta tg_{tt}\) that represents an elemental error in the time differentiation is particularly interesting. Since \(\Delta {\kern 1pt} t\) cannot be zero and \(||\nabla g||_{\text{char}}\) cannot be infinitely large, the product \(\left\| {\nabla g} \right\|_{\text{char}}^{ - 1}\Delta t\) must be finite, i.e.,

$$\Delta t\left\| {\nabla g} \right\|_{\text{char}}^{ - 1} = \delta ,$$
(8)

where δ is a small positive constant. Hence, according to Eq. (8), a finite optical flow error \(\Delta \varvec{u}\) always exists, which imposes an ultimate limit in optical flow computation. In general, a smaller time interval and a larger intensity gradient would lead to a smaller error in optical flow computation.

In addition to the above consideration of the error propagation, a general constraint is related to the intrinsic error of the finite difference approximation \(\varvec{u}(t,x) =\Delta \varvec{x}/\Delta t + \varvec{R}{(\varDelta }t,\varvec{x}\text{)}\) in numerical computations, where \(\varvec{R}(\Delta t,\varvec{x} \approx 0.5({\text{d}}\varvec{u}/{\text{d}}t)\Delta t\) is the remainder or error in velocity. Using an approximation \(||d\varvec{u}/dt||{}_{\text{char}} \approx ||\nabla \varvec{u}||_{\text{char}} ||\varvec{u}||_{\text{char}}\), we have an estimate

$$||\varvec{R}||{}_{\text{char}} \approx 0.5\,\Delta t{\kern 1pt} ||\varvec{u}||_{\text{char}} ||\nabla \varvec{u}||_{\text{char}} \approx 0.5||\Delta \varvec{x}||_{\text{char}} ||\nabla \varvec{u}||_{\text{char}} ,$$
(9)

where \(||\Delta \varvec{x}||_{\text{char}}\) is the characteristic displacement of flow structures in the image plane. The time interval is proportional to the displacement by \({\kern 1pt}\Delta t\sim||\Delta \varvec{x}||_{\text{char}} /||\varvec{u}||_{\text{char}}\).

Combining the errors given by Eqs. (8) and (9) and dropping the subscript “char” for simplicity of expression, we have an estimate for the total error of optical flow computation

$$\varepsilon = ||\Delta \varvec{x}||\sqrt {\frac{{c_{1} }}{{||\nabla g||^{2} ||\varvec{u}||^{2} }} + c_{2} ||\nabla \varvec{u}||^{2} } ,$$
(10)

where c 1 and c 2 are coefficients to be determined. According to Eq. (10), the main parameters related to the error of the optical flow method are the displacement \(||\Delta \varvec{x}|| ,\) the image intensity gradient \(||\nabla g||\), the velocity gradient \(||\nabla \varvec{u}||\), and the velocity magnitude \(||\varvec{u}||\). Equation (10) indicates that the error is proportional to \(||\Delta \varvec{x}||\), and small displacements are generally required for a good accuracy in optical flow computation. The error in optical flow computation is a function of location depending on \(||\nabla g||\) and \(||\nabla \varvec{u}||\). The error would be larger in the regions where \(||\nabla \varvec{u}||\) is larger and/or \(||\nabla g||\) is smaller.

3.2 Relevant parameters for particle images

In typical planar PIV measurements, a thin laser sheet is used to illuminate particles seeded into the flow, and the light scattered by these particles is perpendicularly recorded by a camera. Particles illuminated by a laser sheet are confined between the virtual control surfaces Γ 1 and Γ 2 as illustrated in Fig. 1. In this case, the optical flow obtained from particle images is \(\varvec{u} = \lambda \left\langle {\varvec{U}_{12} } \right\rangle_{\psi }\), where the light-ray-path-averaged velocity is defined in Eq. (4) based on the density (ψ) of particles in the fluid. Thus, the mathematical definition and physical meaning of the optical flow in PIV are clearly given. Further, elucidated in Sect. 3.2, the particle velocity extracted by the interrogation-window-based correlation method in PIV is equivalent to the light-ray-path-averaged velocity weighted by the density of particles. In this case, the right-hand-side term in Eq. (1) is given by \(f = C\varvec{n} \cdot (\psi \varvec{U})|_{{\varGamma_{1} }}^{{\varGamma_{2} }}\) where C is the scattering cross section, which represents the contribution from particles that move across the laser sheet boundary surfaces and accumulate within the laser sheet. The particle accumulation (the out-plane loss/gain of particles) in a laser sheet has been long recognized as an error source in planar PIV, and its effect on the determination of the velocity is explicitly shown as a source term in Eq. (1).

The optical flow method requires that the time derivative \(\partial g/\partial t\) and the spatial gradient \(\nabla g\) be calculated, which is more accurately accomplished for images of continuous patterns. An image of uniformly distributed discrete particles has a non-smooth intensity distribution, which poses a challenge to application of the optical flow method, particularly when the displacements are so large that particles in image #1 are not connected to those in image #2. It is highly desirable to discuss the constraints on the optical flow method applied to PIV images. From a theoretical viewpoint, a PIV image can be reconstructed by the perspective projection of the scattering radiations from laser-illuminated particles in the 3D object space onto the image plane. The mathematical description of this process is a convolution integral of the scattering emission through the Green’s function of an optical system (Raffel et al. 2007; Adrian and Westerweed 2011). The intensity distribution of an image of M discrete particles can be ideally described by the linear superposition of many particles, i.e.,

$$g = \sum\limits_{i = 1}^{M} {g_{i} } ,$$
(11)

where the intensity of the ith particle is modeled by a Gaussian distribution

$$g_{i} = \frac{{I_{i} }}{{2\pi \sigma_{i}^{2} }}\text{exp}\left[ { - \frac{{(x_{1} - x_{1,p(i)} )^{2} + (x_{2} - x_{2,p(i)} )^{2} }}{{2\sigma_{i}^{2} }}} \right].$$
(12)

In Eq. (12), the coordinates \(\varvec{x}_{p(i)} = (x_{1,p(\,i)} ,x_{2,p(\,i)} )\) give the centroid location of the ith particle (which is a function of time), the standard deviation \(\sigma_{i}\) defines its size in the image, and I i is its intensity coefficient. The time derivative \(\partial g/\partial t\) is given by

$$\frac{\partial g}{\partial t} = \sum\limits_{i = 1}^{M} {\frac{{\partial g_{i} }}{\partial t}} = \sum\limits_{i = 1}^{M} {\frac{{g_{i} }}{{\sigma_{i}^{2} }}(\varvec{x} - \varvec{x}_{p(i)} ) \cdot \varvec{u}_{p(i)} } ,$$
(13)

where \(\varvec{u}_{p(i)} = d\varvec{x}_{p(i)} /dt\) is the particle velocity in the image plane. When \(\sigma_{i} \to 0\), g i approaches to the Dirac-delta function, i.e., \(g_{i} \to I_{i} {\kern 1pt} \delta (\varvec{x} - \varvec{x}_{p(i)} )\), and thus the intensity distribution of a particle image becomes very spiky and non-smooth.

For application of the optical flow method to PIV images, the main difficulty is associated with the non-smooth nature of the intensity distribution g of particle images such that optical flow computation is sensitive to the uncertainty in calculating the time derivative \(\partial g/\partial t\). As a constraint, a plausible assumption is that the non-smoothness of the \(\partial g/\partial t\) field is not worse than that of g. Mathematically speaking, the norm of \(\partial g/\partial t\) that represents its bound is on the same order as that of g. Based on this argument, when the image domain Ω is decomposed into the subdomains \(\varOmega_{i} (i = 1,2,3, \ldots ,N)\) where the ith particle is contained, a heuristic constraint is proposed, i.e.,

$${{||\partial g_{i} /\partial t||_{{\varOmega_{i} }}\Delta {\kern 1pt} t} \mathord{\left/ {\vphantom {{||\partial g_{i} /\partial t||_{{\varOmega_{i} }}\Delta {\kern 1pt} t} {||g_{i} ||_{{\varOmega_{i} }} }}} \right. \kern-0pt} {||g_{i} ||_{{\varOmega_{i} }} }} \le b,$$
(14)

where b is a positive number, \(\Delta {\kern 1pt} t\) is a time interval between two successive images. In Eq. (14), the L 2-norm on the subdomain Ω i around the ith particle is defined as

$$||g_{i} ||_{{\varOmega_{i} }} = \left( {\int_{{\varOmega_{i} }} {g_{i}^{2} H(\varOmega_{i} )} {\text{d}}x_{1} {\text{d}}x_{2} } \right)^{1/2} ,$$
(15)

where \(H(\varOmega_{i} )\) is a window function given by the Heaviside function [\(H(\varOmega_{i} ) = 1\) for \((x_{1} ,x_{2} ) \in \varOmega_{i}\) and \(H(\varOmega_{i} ) = 0\) for \((x_{1} ,x_{2} ) \notin \varOmega_{i}\)]. Substituting the finite difference form of Eq. (13) into Eq. (14) and using the Cauchy–Schwarz inequality, we have an equivalent condition

$${{||\Delta x_{p(i)} ||_{{\varOmega_{i} }} } \mathord{\left/ {\vphantom {{||\Delta x_{p(i)} ||_{{\varOmega_{i} }} } {d_{p(i)} \le b}}} \right. \kern-0pt} {d_{p(i)} \le b}},$$
(16)

where \(||\Delta \varvec{x}_{p(i)} ||_{{\varOmega_{i} }}\) is the characteristic displacement of the particle in Ω i , \(d_{p(i)} = 2\sigma_{i}\) is the mean image diameter of the particles in Ω i , and b is the upper bound. The value of b is not fixed, but rather depends on the specific flow studied and the accuracy required. As a rule of thumb, the upper bound b is \({\text{O}}(1)\), which will be estimated through simulations. In general, Eq. (16) is also valid for images of continuous patterns, where \(d_{p(i)}\) should be interpreted as the characteristic length of distinct structures in the image plane.

The finite difference approximation of the particle velocity is an essential part in PIV. Therefore, similar to Eq. (9) for the optical flow, an estimate of the error in the finite difference approximation of the particle velocity is

$$\begin{aligned}||\varvec{R}||{}_{{\varOmega_{i} }} &\approx &0.5\Delta t||\varvec{u}_{{p(\varvec{i})}} ||_{{\varOmega_{i} }} ||\nabla \varvec{u}_{{p(\varvec{i})}} ||_{{\varOmega_{i} }}\\ &\approx& 0.5||\Delta \varvec{x}_{{p(\varvec{i})}} ||_{{\varOmega_{i} }} ||\nabla \varvec{u}_{{p(\varvec{i})}} ||_{{\varOmega_{i} }} .\end{aligned}$$
(17)

Thus, another constrain for the displacement is

$$||\Delta \varvec{x}_{{p(\varvec{i})}} ||_{{\varOmega_{i} }} ||\nabla \varvec{u}_{{p(\varvec{i})}} ||_{{\varOmega_{i} }} \le h,$$
(18)

where h is a positive constant. Equations (16) and (18) are two constraints on the displacement of particles, which are derived from the different requirements. Equation (16) is related to the time derivative \(\partial g/\partial t\) in optical flow computation for images of discrete particles, while Eq. (18) is associated with the finite difference approximation of the particle velocity.

For low-density particle images, the velocity vectors in the void regions could be formally extracted at one vector per pixel in optical flow computation. This pseudo-high-resolution is a result of an embedded interpolation process in solving the global optimization problem in the whole image domain for the optical flow. Although the analytical details of this implicit interpolation are unknown, when it is assumed to be equivalent to a general mth-order interpolation (Hildebrand 1974), its error could be estimated by

$$E_{m} \sim\left\langle {r_{p} } \right\rangle^{m} \left\| {\Delta {\kern 1pt}^{m} \varvec{x}_{p(i)} } \right\|_{{\varOmega_{i} }} \sim{{\left\| {\Delta {\kern 1pt}^{m} \varvec{x}_{p(i)} } \right\|_{{\varOmega_{i} }} } \mathord{\left/ {\vphantom {{\left\| {\Delta {\kern 1pt}^{m} \varvec{x}_{p(i)} } \right\|_{{\varOmega_{i} }} } {N_{p}^{m/2} }}} \right. \kern-0pt} {N_{p}^{m/2} }},$$
(19)

where \(\left\langle {r_{p} } \right\rangle\) is the mean inter-particle distance, \(\Delta {\kern 1pt}^{m}\) is the mth-order difference operator, and \(N_{p}\) is the particle image density. In Eq. (19), an estimate \(\left\langle {r_{p} } \right\rangle \sim N_{p}^{1/2}\) in the image plane is used according to 2D particle statistics.

The generic error estimate Eq. (10) for the optical flow method can be extended by including the effects of the particle image diameter and the particle image density. To simplify the notations, we drop the subscripts “Ω (i)” and “(i)” in Eqs. (14)–(19). It is noted that the effect of the particle image diameter is related to the effect of the image intensity gradient, i.e., \(||\nabla g|| \sim d_{p}^{ - 1} ,\) where \(d_{p}\) is the mean particle image diameter. Therefore, by combining Eqs. (8), (16), (18), and (19), an estimate for the total error of the optical flow method applied to PIV images is given by

$$\varepsilon = ||\Delta \varvec{x}_{p} ||\sqrt {\frac{{c_{1} d_{p}^{2} }}{{\left\| {\varvec{u}_{p} } \right\|^{2} }} + c_{2} \left\| {\nabla \varvec{u}_{p} } \right\|^{2} + \frac{{c_{3} }}{{d_{p}^{2} }} + \frac{{c_{4} }}{{N_{p}^{m} }}\frac{{\left\| {\Delta ^{{{\kern 1pt} m}} {\kern 1pt} \varvec{x}_{p} } \right\|^{2} }}{{\left\| {\Delta \varvec{x}_{p} } \right\|^{2} }}} ,$$
(20)

where c 1, c 2, c 3, and c 5 are coefficients to be determined. According to Eq. (20), the main parameters are the particle displacement \(||\Delta \varvec{x}_{p} ||\), the particle image diameter \(d_{p}\), the particle velocity gradient \(||\nabla \varvec{u}_{p} ||\), and the particle image density \(N_{p}\). In general, the particle displacement \(||\Delta \varvec{x}_{p} ||\) should be small in optical flow computation using particle images, particularly in regions of large velocity gradients. The particle image diameter \(d_{p}\) could have the optimal value for optical flow computation since the terms of \(\sim d_{p}^{2}\) and \(\sim d_{p}^{ - 2}\) in Eq. (20) have the opposite trends as \(d_{p}\) increases. The particle image density \(N_{p}\) should be suitably large. However, in the limiting case where \(N_{p} \to \infty ,\) particle images would become uniform and the image intensity gradient becomes very small. In this case, accurate extraction of the optical flow is not possible. Therefore, there would be the optimal value of \(N_{p}\), and this mechanism could be incorporated into Eq. (20). Although the above error estimate is given from the perspective of the optical flow, these parameters are also important for the correlation method in PIV (Timmins et al. 2012).

Without loss of generality, for the convenience of application, the particle displacement \(||\Delta \varvec{x}_{p} ||\) is replaced by the maximum particle displacement \(\text{max}{\kern 1pt} (||\varvec{x}_{p} |)\), and the particle velocity gradient \(||\nabla \varvec{u}_{p} ||\) is replaced by the averaged magnitude of the particle velocity gradient \(|\nabla \varvec{u}_{p} |\). To decrease the maximum displacement \(\text{max}{\kern 1pt} (|\Delta \varvec{u}_{p} |)\) and increase the mean particle image diameter \(d_{p}\) in pixels, suitable downsampling and filtering of images could be used as pre-processing under an assumption that the pre-processing does not alter the motion information contained in images. For moderately large displacements (for example more than 10 pixels for images of 480 × 520 pixels), the coarse-to-fine iterative scheme described in Sect. 2.3 could be used to recover a high-resolution field and improve the accuracy. However, when the displacements in images are too large (for example more than 20 pixels), the optical flow method may fail to extract a velocity field at the beginning. In fact, most test images used in the workshops of the International PIV Challenge has such large displacements that the above constraints could not be satisfied, and so it is not surprising that the optical flow algorithms did not provide superior results over established correlation methods. The constraint given by Eq. (20) should be considered when applying the optical flow method to PIV images optimized for the correlation algorithms. Generally, suitably small displacements between two successive images are more favorable to optical flow computation. When the particle density is low, particles are small, and/or displacements are relatively large in images, a correlation method could be incorporated into the coarse-to-fine scheme to overcome the multi-resolution limitations (Heitz et al. 2008).

3.3 Relationship between optical flow and particle velocity

For application of the optical flow method to PIV images, it is necessary to explore the mathematical connection between the optical flow and the particle velocity in the image plane. Substitution of Eq. (11) into Eq. (1) yields

$$\sum\limits_{i = 1}^{M} {G_{i} } - F = 0,$$
(21)

where

$$G_{i} = \frac{{g_{i} }}{{\eta_{i} }}(\varvec{x} - \varvec{x}_{p(i)} ) \cdot (\varvec{u}_{p(i)} - \varvec{u}),$$
(22)
$$F = \text{max}\left( {\sigma_{i}^{2} } \right)\left( {\sum\limits_{i = 1}^{M} {g_{i} \nabla \cdot \varvec{u}} - f} \right),$$
(23)

where \(\eta_{i} = \sigma_{i}^{2} /\text{max}\left( {\sigma_{i}^{2} } \right)\) represents the relative or normalized cross-sectional area of the ith particle.

For simplicity, the following unconstrained variational problem is considered, i.e.,

$$J(\varvec{u}) = \int_{\varOmega } {\left( {\sum\limits_{i = 1}^{M} {G_{i} } - F} \right)}^{2} {\text{d}}x_{1} {\text{d}}x_{2} \to \text{min}\text{.}$$
(24)

Furthermore, we consider a limiting case where \(\text{max}\left( {\sigma_{i}^{2} } \right) \to 0\) while \(\eta_{i}\) remains constant. In this case, when the image domain Ω is decomposed into N subdomains (or PIV interrogation windows) \(\left( {\varOmega = \bigcup\nolimits_{k}^{N} {\varOmega_{k} } } \right)\), by using the Cauchy–Schwarz inequality, the variational problem can be equivalently expressed as

$$J(\varvec{u}) = \sum\limits_{k = 1}^{N} {\left\| {\varvec{u}_{p(i)} - \varvec{u}} \right\|_{{_{{\varOmega_{k} }} }}^{2} } \to \text{min,}$$
(25)

where the special L 2-norm is defined as

$$||\varvec{u}_{p(i)} - \varvec{u}||_{{\varOmega_{k} }} = \left( {\int_{{\varOmega_{k} }} {H(\varOmega_{k} )\sum\limits_{i = 1}^{M} {G_{i}^{2} } } {\text{d}}x_{1} {\text{d}}x_{2} } \right)^{1/2} ,$$
(26)

and \(H(\varOmega_{k} )\) is the Heaviside function. A mathematically trivial but physically meaningful solution for Eq. (25) is

$$\left\| {\varvec{u}_{p(i)} - \varvec{u}} \right\|_{{_{{\varOmega_{k} }} }}^{2} = 0\quad (k = 1,2,3, \ldots ,N)$$
(27)

Equation (27) indicates that the particle velocity equals the optical flow in terms of the L 2-norm defined by Eq. (26) in the subdomains (i.e., interrogation windows). Although the theoretical connection between the particle velocity and the optical flow in PIV has been elucidated, quantitative comparisons between the optical flow and correlation methods have to be done based on simulations and physical flow measurements.

4 Simulations

4.1 Typical case

In order to evaluate the performance of the optical flow and correlation methods, simulations are conducted on particle images in a synthetic flow—an Oseen vortex pair in uniform flow. A sample particle image with the size of 500 × 500 pixels and the 8-bit dynamic range is generated, where 10,000 particles with a Gaussian intensity distribution with the standard deviation of σ = 2 pixels are uniformly distributed. This image is further smoothed out by using a Gaussian filter with the 2-pixel standard deviation to provide a quasi-continuous intensity field. Figure 2 shows the generated particle image that is used for simulations, where the mean characteristic image diameter of particles is \(d_{p} = 4\) pixels and the particle image density is 0.04 1/pixel2. This particle image density corresponds to about 40 particles in a 32 × 32 pixel2 interrogation window. Particle images with different densities are also generated to investigate the effect of the particle image density. It is found that the error of the correlation method basically remains unchanged in a range of 0.015–0.08 1/pixel2 for this flow (see Fig. 9). Thus, it is reasonable to use the particle image with 10,000 particles as a typical case for comparing the optical flow and correlation methods. Careful inspection of the zoomed-in view indicates that this particle image is sufficiently smooth for optical flow computation.

Fig. 2
figure 2

Sample particle image (500 pixels by 500 pixels) for simulations, where 10,000 particles are randomly distributed

A synthetic velocity field, generated by superposing an Oseen vortex pair on a uniform flow, is used as a canonical flow. Two Oseen vortices are placed at \((m/3,\,n/2)\) and \((2m/3,\;n/2)\) in an image, respectively, where m (500) and n (500) are the numbers of rows and columns of the image. The circumferential velocity of an Oseen vortex is given by \(u_{\theta } = (\varGamma /2\pi r)[1 - \text{exp}( - r^{2} /r_{0}^{2} )]\), where the vortex strengths are \(\varGamma = \pm 7000\) (pixel)2/s and the vortex core radius is \(r_{0} = 15\) pixels. The uniform flow velocity is 10 pixels/s. The second image is generated by deforming the original synthetic particle image based on the given velocity field after a time step \(\Delta t\). This processing is made by applying an image-shifting (image-warping) algorithm that uses a translation transformation for large displacements and the discretized optical flow equation for sub-pixel correction. This image-shifting (image-warping) algorithm faithfully describes the motion of image patterns (e.g., particle images) for a given velocity field since the physics-based optical flow equation is derived from the governing transport equations for flow visualizations. It is emphasized that optical flow computation to extract a velocity field from the synthetic images is independent of the image-shifting (image-warping) generating process. In other words, optical flow computation and generation of synthetic images by using this algorithm is not a circular process. The time step \(\Delta t\) is used to control the maximum displacement in synthetic particle images.

In optical flow computation, the Lagrange multiplier in the Horn–Schunck estimator is set at 50 for an initial velocity field. As pointed out in Sect. 2.1, the classical Horn–Schunck estimator assumes that the optical flow is divergence-free, which is not physically true since the optical flow as the light-path-averaged velocity generally does not satisfy \(\nabla \cdot \varvec{u} = 0\) even for 2D laser visualization in PIV. Nevertheless, the Horn–Schunck estimator provides a good initial solution for refinement by the Liu–Shen estimator based on Eq. (1) derived from the relevant governing equations for various flow visualizations. The Lagrange multiplier in the Liu–Shen estimator is fixed at 5000 for a refined velocity field, and it does not significantly affect the velocity profile in a range of 1000–20,000 except the peak velocity near the vortex cores in this flow. Therefore, in simulations and measurements, the Lagrange multipliers are fixed at (50, 5000) in the Horn–Schunck estimator and the Liu–Shen estimator, respectively, unless stated otherwise. In the coarse-to-fine iterative scheme, images are initially downsampled by a factor of 2 to obtain a coarse-grained velocity field. Then, a refined velocity field with full image resolution is obtained in iterations. The correlation method used for comparison is embedded in LaVision’s DaVis (7.2) software package. This FFT-based correlation algorithm is chosen because it is the most widely used commercial PIV software and its capability has been examined in various applications (Stanislas et al. 2003, 2005, 2008). It is noted that the parameters in the correlation software are not fully optimized such that the following comparisons provide a useful reference rather than a general and complete conclusion.

As previously justified, a pair of images with 10,000 particles is processed as a typical case, where the maximum displacement \(\text{max}{\kern 1pt} {\kern 1pt} (|\Delta \varvec{x}_{p} |)\) is 2.6 pixels, and \({{\text{max}{\kern 1pt} (|\Delta \varvec{x}_{p} |)} \mathord{\left/ {\vphantom {{\text{max}{\kern 1pt} (|\Delta \varvec{x}_{p} |)} {d_{p} }}} \right. \kern-0pt} {d_{p} }}\) is 0.65. Figure 3 shows a pair of particle images downsampled by 2 and filtered with a Gaussian filter with the 2-pixel standard deviation for a coarse-grained velocity field. The displacements in these images are reduced by 2. It is observed that not only the size of individual particles is increased by filtering, but also some clusters of particles are diffused into larger blobs in high-density particle images. As a result, the size of distinct structures in the images is increased. Next, a refined velocity field is recovered by the first iteration in the coarse-to-fine scheme.

Fig. 3
figure 3

Particle images downsampled by a factor of 2 and Gaussian-filtered (the 2-pixel standard deviation) for the initial optical flow computation in the coarse-to-fine scheme, a Image #1, and b Image #2

Figure 4 shows the velocity vectors extracted from the particle images. The optical flow method gives 500 × 500 vectors, and the correlation method with the two passes (64 × 64–16 × 16 and 50 % window overlap) gives 62 × 62 vectors. Figure 5 shows the corresponding streamlines and vorticity fields. The overall flow fields extracted by both methods are consistent except that the optical flow method yields the results with much higher spatial resolution. Figure 6 shows direct comparisons between the x-velocity and y-velocity profiles obtained by both methods and the true profiles (the truth) at five x-locations in an Oseen vortex pair in uniform flow. The results from both methods compared well with the true distribution except near the vortex cores where the velocity reaches the maximum and its gradient is very large. According to the error estimates given by Eqs. (9) and (17), the intrinsic error associated with the finite difference approximation in both methods is large there. The error from the correlation method in those regions is larger than that from the optical flow method, which is evidenced by the distributions of the local root-mean-square (RMS) error in Fig. 7. This is not surprising since the cross-correlation computation in interrogation windows tends to smooth out the velocity in regions where the velocity changes drastically in its magnitude and direction.

Fig. 4
figure 4

Velocity vectors of an Oseen vortex pair in uniform flow extracted from the particle images by using a the optical flow method, and b the correlation method (0.04 1/pixel2 seeding particle image density)

Fig. 5
figure 5

Streamlines and vorticity fields of an Oseen vortex pair in uniform flow extracted from the particle images by using a the optical flow method, and b the correlation method

Fig. 6
figure 6

Comparisons of a the x-velocity and b y-velocity profiles at five x-locations in an Oseen vortex pair in uniform flow

Fig. 7
figure 7

RMS error distributions for a the optical flow method, and b the correlation method

4.2 Effects of relevant parameters on accuracy

As our previous analysis indicates, particle displacement, particle velocity gradient, particle image density, and particle image diameter are the significant error parameters in the optical flow and the correlation methods. The synthetic particle images with different displacements and velocity gradients are generated by changing the time step in the flow of an Oseen vortex pair in uniform flow. The total RMS error in the whole image (\(m \times n\) pixels) is evaluated by integrating the error distributions, i.e.,

$$\begin{aligned} {\text{RMS}}\,{\text{Error}} & = m^{ - 1} n^{ - 1} \sum\limits_{i = 1}^{m} {\sum\limits_{j = 1}^{n} {\left[ {\left( {u_{x} (i,j) - u_{{x,{\text{exa}}}} (i,j)} \right)^{2} } \right.} } \\ & \quad \left. { + \left( {u_{y} (i,j) - u_{{y,{\text{exa}}}} (i,j)} \right)^{2} } \right]^{1/2} . \\ \end{aligned}$$
(28)

The RMS error is first calculated as a function of the maximum displacement in images. As shown in Fig. 8a, for the images with 10,000 particles, the total RMS error in both the optical flow and correlation methods increases approximately proportionally with the maximum displacement \(\text{max}{\kern 1pt} (|\Delta \varvec{x}_{p} |)\). When \({{{\text{max(|}}\Delta \varvec{x}_{p} | )} \mathord{\left/ {\vphantom {{{\text{max(|}}\Delta \varvec{x}_{p} | )} {d_{p} }}} \right. \kern-0pt} {d_{p} }} < 1.5\), the optical flow method gives more accurate results than the correlation method, and the relative error is less than 2 %. The total RMS error of the optical flow method with the Lagrange multipliers (50, 5000) exceeds that of the correlation method when \(\text{max}{\kern 1pt} (|\Delta \varvec{x}_{p} |)\) is larger than about 4–5 pixels. It is observed that for large \({{{ \hbox{max} }{\kern 1pt} (|\Delta \varvec{x}_{p} |)} \mathord{\left/ {\vphantom {{{ \hbox{max} }{\kern 1pt} (|\Delta \varvec{x}_{p} |)} {d_{p} }}} \right. \kern-0pt} {d_{p} }}\) the optical flow method yields the results with the significant random fluctuation. This behavior is intrinsically associated with the non-smooth nature of particle images according to the previous analysis. This random fluctuation could be reduced by adjusting the Lagrange multipliers. As indicated in Fig. 8a, when larger Lagrange multipliers (200, 20,000) are used, the optical flow method yields smaller random fluctuations. Figure 8b shows the RMS error as a function of the velocity gradient, which is essentially the same as that in Fig. 8a since the velocity gradient is directly proportional to the displacement in this case. In optical flow computations in Figs. 8, 9, 10 and 11 except in one case, the Lagrange multipliers (50, 5000) are used for the Horn–Schunck estimator and the Liu–Shen estimator, respectively. In the coarse-to-fine scheme, the images are initially downsampled by 2 and then the original resolution is recovered by the spatial interpolation in the image-shifting (image-warping) scheme in the second iteration.

Fig. 8
figure 8

Total RMS error as a function of a the maximum displacement and b the velocity gradient for an Oseen vortex pair in uniform flow. In optical flow computations in Figs. 8, 9, 10 and 11 except in one case, the Lagrange multipliers (50, 5000) are used for the Horn–Schunck estimator and the Liu–Shen estimator, respectively. In the coarse-to-fine scheme, the images are initially downsampled by 2 and then the original resolution is recovered in the second iteration

Fig. 9
figure 9

Total RMS error as a function of the particle image density for an Oseen vortex pair in uniform flow

Fig. 10
figure 10

Total RMS error as a function of the particle image diameter for an Oseen vortex pair in uniform flow

Fig. 11
figure 11

Total RMS angular error as a function of the four parameters: a particle displacement, b particle velocity gradient, c particle image density, and d particle image diameter for an Oseen vortex pair in uniform flow

Particle image density is another relevant parameter that affects the accuracy of extracted velocity fields. To investigate the effect of particle image density, images (500 pixels by 500 pixels) with 500, 2000, 4000, 7000, 10,000, 12,000, 16,000, and 20,000 particles are generated, which correspond to particle densities of 0.002, 0.008, 0.016, 0.028, 0.04, 0.048, 0.064, and 0.08 1/pixel2. The velocity fields are extracted by using the optical flow and correlation methods from synthetic images of an Oseen vortex pair in uniform flow with the maximum displacement of 2.6 pixels. The total RMS error is shown in Fig. 9 as a function of the particle image density. For the optical flow method, there is a shallow valley in the particle image density of 0.015–0.04 1/pixel2, where the total RMS error reaches the minimum. This range approximately corresponds to 15–40 particles in a 32 × 32 pixel2 window which is also more suitable for the correlation method. As the particle image density increases, the total RMS error of the correlation method decreases when the particle image density is less than 0.015 1/pixel2 and then remains largely unchanged in a range of 0.015–0.08 1/pixel2. Generally, the statistical robustness of calculating the cross-correlation between particle pairs is enhanced when the particle image density is high while individual particles remain distinct. However, when particle image density is very high, the accuracy of cross-correlation computation decreases. The vectors in the void regions in particle images are formally obtained as a result of the spatial interpolation embedded in optical flow computation. In this case, a conservative estimate of the spatial resolution is that the number of reliable velocity vectors extracted by using the optical flow method equals the number of pixels contained in all the particles.

Figure 10 shows the RMS error as a function of the particle image diameter. As indicated in Eq. (20), the error in optical flow computation deceases as the particle image diameter increases for \(d_{p} \le 4\) pixels, increasing thereafter due to the elevated error associated with the decay of the image intensity gradient. Thus, there is a shallow valley near the particle image diameter of 4 pixel \(({{{ \hbox{max} }{\kern 1pt} (|\Delta \varvec{x}_{p} |)} \mathord{\left/ {\vphantom {{{ \hbox{max} }{\kern 1pt} (|\Delta \varvec{x}_{p} |)} {d_{p} }}} \right. \kern-0pt} {d_{p} }} = 0.62)\), where the RMS error of the optical flow method reaches the minimum. Interestingly, the error in the correlation method has the similar dependency on the particle image diameter (Raffel et al. 2007). Figure 11 shows the total RMS angular error as a function of the four parameters: particle displacement, particle velocity gradient, particle image density, and particle image diameter for an Oseen vortex pair in uniform flow. The total RMS angular error in both optical flow and correlation methods is around 3° in wide ranges of the parameters. The largest angular error (about 6°) appears near the vortex cores where the velocity direction is changed drastically.

4.3 Effect of illumination intensity change

The basic assumption in optical flow computation is that the illumination intensity field is time-independent. When a laser illumination field in PIV measurements is changed between two consecutive shots, the error in optical flow computation could be significant, which is mainly contributed by the elemental error \(\Delta (\partial g/\partial t)\) in the error propagation equation. A simple illumination intensity correction scheme is used to reduce the effect of the changing illumination even if it cannot be totally eliminated. The illumination intensity change is decomposed into the overall intensity shift and local illumination intensity change. First, the overall illumination intensity change in the whole images is corrected simply by shifting the averaged intensity change. Next, to correct the local illumination intensity change, a Gaussian filter with a suitable standard deviation is applied to two images to obtain two sufficiently filtered (smoothed) images. A difference field between the two filtered images, which is proportional to a change in the illumination intensity, is then used to compensate the image intensity variation caused by the local illumination intensity change. This is accomplished by adding the difference field to the original image to be corrected. A pair of images (g 1 and g 2) is considered, where g 2 is affected by the local illumination intensity change. Mathematically, the local illumination intensity change is estimated by \(\delta g = g_{1} * G_{\sigma } - g_{2} * G_{\sigma } ,\) where * denotes the convolution operator and \(G_{\sigma }\) is the Gaussian kernel with the standard deviation σ. Then, the illumination-corrected second image is \(\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{g}_{2} = g_{2} + \delta g\). Clearly, the standard deviation σ should be suitably selected by a trial-and-error approach depending on the characteristic length scale of the local illumination intensity change. When σ is too small, \(\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{g}_{2} \approx g_{1}\) so that the optical flow could not be extracted correctly. On the other hand, when σ is too large, \(\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{g}_{2} \approx g_{2}\) so that the local illumination change could not be corrected sufficiently.

To simulate the effect of the local illumination intensity change and demonstrate the correction procedure, a 2D sinusoidal distribution \(\Delta {\kern 1pt} I(x,y) = 1 + A{\text{sin(}}2\pi x/\lambda_{x} ) {\text{sin}}{\kern 1pt} (2\pi y/\lambda_{y} )\) is used to simulate a complex local illumination intensity change, where A is the amplitude, and \(\lambda_{x}\) and \(\lambda_{y}\) are the wavelengths. Figure 12 shows the local illumination intensity change field. The second image affected by the local illumination intensity change is generated by multiplying \(\Delta {\kern 1pt} I(x,y)\) to the original second image. Figure 13a shows the second particle image that has the visible sinusoidal patterns of the local illumination intensity change with \(A = 0.5\). The illumination intensity correction scheme with \(\sigma = 30\) pixels is applied to this image to obtain the illumination-corrected image shown in Fig. 13b. Although the illumination intensity patterns are largely eliminated, the weak remainder of the patterns is still visible. To further refine the illumination intensity correction procedure, a more sophisticated scheme based on a certain optimization principle could be developed. This simulated case represents an extreme situation, and in practice the local illumination intensity change is not such large and complex.

Fig. 12
figure 12

Illumination intensity change field in simulation

Fig. 13
figure 13

a Particle image affected by the illumination intensity change for A = 0.5, and b particle image after correcting the illumination intensity change

To show the effect of the local illumination intensity change on extraction of a velocity field, the optical flow and correlation methods are applied to a pair of the images without correcting the illumination intensity change. Figure 14 shows the x-velocity and y-velocity profiles at five x-locations in an Oseen vortex pair in uniform flow. As expected, the optical flow method as a differential approach is more sensitive to the local illumination intensity change than the correlation method that is an integral approach. Therefore, the illumination intensity correction is necessary for optical flow computation. Figure 15 shows the improved results after the second image is processed by using the simple illumination intensity correction scheme. Figure 16 shows the total RMS error as a function of the illumination intensity change amplitude A for an Oseen vortex pair in uniform flow. The accuracy of optical flow computation is significantly improved after the effect of the local illumination intensity change is corrected. In contrast, the improvement is relatively small for the correlation method.

Fig. 14
figure 14

Effects of the illumination intensity change on a the x-velocity and b y-velocity profiles at five x-locations in an Oseen vortex pair in uniform flow

Fig. 15
figure 15

Results after correction for the illumination intensity change: a the x-velocity and b y-velocity profiles at five x-locations in an Oseen vortex pair in uniform flow

Fig. 16
figure 16

Total RMS error as a function of the illumination intensity change amplitude for an Oseen vortex pair in uniform flow

5 Experiments and discussions

5.1 Setup

To compare the optical flow and correlation methods based on experimental particle images, PIV measurements were conducted in an air jet normally impinging on a black-coated wall from a contoured circular nozzle with a diameter of D = 9 mm [a DISA nozzle (type 55d45)]. Figure 17 shows the experimental setup. The flow was seeded by water droplets generated from the TSI atomizer (the mean diameter of the particles in the flow is about 68 μm). The jet velocity at the exit was 4.5 m/s. The nozzle-to-surface distance is h = 38 mm, and the distance-to-diameter ratio is h/D = 4.2. The Reynolds number based on the diameter is Re = 2600. A Nd:YAG Big Sky Laser system with 50 mJ pulses was used for particle illumination. The time interval between two pulses was 20 µs. A Phantom v9.1 camera with a zoom lens was used to capture particle images with a field of view of 37 × 27 mm2. The impingement region and wall-jet region were measured separately. The sample particle images are shown in Fig. 18. The mean diameter of particles in the images is 3 pixels and the maximum displacement is \({ \hbox{max} }{\kern 1pt} (|\Delta \varvec{x}_{p} |) = 5.2\) pixels.

Fig. 17
figure 17

Impinging jet setup

Fig. 18
figure 18

Typical particle images: a impingement region, and b wall-jet region

5.2 Accuracy evaluation of snapshot field

Before processing PIV images acquired in the experiments, the accuracy of both the methods is evaluated in a typical simulated case. First, a velocity field is extracted from a pair of experimental particle images with a time interval of 20 μs by using the optical flow method. Then, this velocity field is smoothed out by using a Gaussian filter with the 2-pixel standard deviation, and it is used as the baseline velocity field (the truth) for comparison to generate the synthetic particle image pair. The first original experimental PIV image (see Fig. 18a for the impingement region or Fig. 18b for the wall-jet region) is used as the first synthetic particle image, and the second synthetic particle image is generated by using the image-shifting (image-warping) algorithm based on the baseline velocity field. This pair of the synthetic particle images serves as a test case for direct comparisons between the optical flow and correlation methods. It is noted again that although the baseline velocity is obtained by using the optical flow method from a pair of experimental images, the generation of the second synthetic image using the image-shifting (image-warping) scheme is an independent process that is not in favor of either the optical flow method or correlation method. In fact, the baseline velocity field could be generated using any feasible method such as a theoretical solution and a CFD code. Here, the optical flow method is used for generating the baseline velocity field from experimental images purely because it can provide a high-resolution field.

Figure 19 shows the snapshot velocity vector and vorticity fields in the impingement region of the impinging jet extracted from the synthetic particle image pair. Both the optical flow and correlation methods reveal large vortices generated in the shear layer of the free jet and wall jet due to the Kelvin–Helmholtz instability, and induced secondary vortices (secondary separations) in boundary layer near the wall. However, the optical flow method yields the velocity field with much higher spatial resolution, revealing more details of the flow structures. Quantitative comparisons with the true distributions are given in Fig. 20 in the x-velocity and y-velocity profiles at five y-locations in the impingement region of the impinging jet. Both methods compare well with the true profiles in this region. Figure 21 shows the snapshot velocity vectors and vorticity fields in the wall-jet region, which visualize large vortices and induced secondary vortices extracted by both methods. Figure 22 shows quantitative comparisons in the x-velocity and y-velocity profiles at five x-locations in the wall-jet region. The error of the correlation method is noticeable particularly near the wall in some regions (x = 900–1200 pixels) where complex interactions between vortices and boundary layer take place. This error could be due to interrogation windows cutting through the wall boundary (no special treatment is applied to deal with this problem). The total RMS errors in the whole domain for the optical flow and correlation methods are 0.11 and 0.15 pixels/unit time, respectively.

Fig. 19
figure 19

Snapshot velocity vector and vorticity fields in the impingement region of the impinging jet by applying a the optical flow method and b the correlation method to the synthetic particle images

Fig. 20
figure 20

Comparisons of a the x-velocity and b y-velocity profiles at five y-locations in Fig. 19

Fig. 21
figure 21

Snapshot velocity vector and vorticity fields in the wall-jet region of the impinging jet by applying a the optical flow method and b the correlation method to the synthetic particle images

Fig. 22
figure 22

Comparisons of a the x-velocity and b y-velocity profiles at five x-locations in Fig. 21

5.3 Ensemble-averaged fields

A sequence of 400 particle image pairs acquired in the impingement region is processed by using the optical flow and correlation methods. Figure 23 shows the ensemble-averaged velocity vector and vorticity fields. The overall flow structures including free shear layers and boundary layers can be extracted by using both methods. Figure 24 shows the ensemble-averaged profiles of the x-velocity and y-velocity components at five y-locations in the impingement region of the impinging jet. The results extracted by using both methods are in good agreement at these locations. Since the truth is not known, the RMS difference in the whole field between the two methods is used as an alternative measure. The RMS difference of velocity in the whole field is 0.053 pixels/unit time. Then, the velocity fluctuations \(u_{x}^{{\prime }} = u_{x} - \left\langle {u_{x} } \right\rangle\) and \(u_{y}^{{\prime }} = u_{y} - \left\langle {u_{y} } \right\rangle\) are calculated, where 〈〉 is the ensemble averaging operator. Further, the turbulent kinetic energy \(k_{T} = \left\langle {u_{x}^{{{\prime }2}} } \right\rangle + \left\langle {u_{y}^{{{\prime }2}} } \right\rangle\) and Reynolds stress \(\tau_{T} = - \left\langle {u_{x}^{{\prime }} u_{y}^{{\prime }} } \right\rangle\) are calculated. These quantities are not converted to the physical units since comparisons are more direct in the image plane. Figure 25 shows the fields of the turbulent kinetic energy in the impingement region of the impinging jet. The overall distributions obtained by both methods are similar, indicating the high turbulent energy in the wall jet. The RMS difference of k T is 0.1 (pixels/unit time)2 in the whole field and 0.03 (pixels/unit time)2 in the quiescent region outside of the jet. In Figs. 23 and 25, the free shear layers of the jet estimated by the correlation method seem visually thinner than those given by the optical flow method. For the sharp edges in flow visualizations shown in Fig. 18a, the correlation method tends to underestimate the velocity there since there are fewer particles in interrogation windows across the edges. This subtle effect can be carefully observed in the velocity profiles near the jet exit in Fig. 24b.

Fig. 23
figure 23

Ensemble-averaged velocity vector and vorticity fields in the impingement region of the impinging jet by applying a the optical flow method and b the correlation method to the experimental particle images

Fig. 24
figure 24

Ensemble-averaged profiles of a the x-velocity and b y-velocity components at five y-locations in Fig. 23

Fig. 25
figure 25

Fields of the turbulent kinetic energy in the impingement region of the impinging jet by applying a the optical flow method and b the correlation method to the experimental particle images

As shown in Fig. 26, the profiles of k T at several locations in the free jet indicate some differences particularly in the potential core and the region near the free jet shear layer. Figure 27 shows the fields of the Reynolds stress in the impingement region of the impinging jet. The profiles of the Reynolds stress at five y-locations are shown in Fig. 28. The results given by both methods are in good agreement, and the RMS difference of τ T is 0.0043 (pixels/unit time)2. The Reynolds stress obtained by using both methods is very small in the potential core and the region outside of the jet. This is physically reasonable. Figure 29 shows the distributions of the ensemble-averaged velocity, turbulent kinetic energy, and Reynolds stress along the centerline of the impinging jet. The turbulent kinetic energy yielded by using the correlation method in the potential core is lower. The Reynolds stress given by both methods in the potential core is around zero, which is reasonable from a physical viewpoint.

Fig. 26
figure 26

Profiles of the turbulent kinetic energy at five y-locations in Fig. 25

Fig. 27
figure 27

Fields of the Reynolds stress in the impingement region of the impinging jet by applying a the optical flow method and b the correlation method to the experimental particle images

Fig. 28
figure 28

Profiles of the Reynolds stress at five y-locations in Fig. 27

Fig. 29
figure 29

Distributions of the flow quantities along the centerline of the impinging jet

Similarly, a sequence of 284 particle image pairs acquired in the wall-jet region is processed. Figure 30 shows the ensemble-averaged velocity vector and vorticity fields in the wall-jet region. Figure 31 shows the ensemble-averaged profiles of the x-velocity and y-velocity components at five x-locations in the wall-jet region. The RMS difference of velocity in the whole field is 0.044 pixels/unit time. Figures 32 and 33 show the fields of the turbulent kinetic energy and its profiles at several x-locations in the wall-jet region, respectively. The total RMS error of k T in the whole field is 0.1 (pixels/unit time)2. It is found in Fig. 33 that a large difference in k T given by the optical flow and correlation methods is found near the free jet shear layer, but it decreases as the x-location moves away from the free jet. The cause of this phenomenon is unknown. There is the peak value of the turbulent kinetic energy in the wall jet at the location of \(r/D = 2\), where r is the radial distance from the impingement point and D is the nozzle diameter. The peak value of k T has been observed previously, which corresponds to the local maximum in the heat transfer and droplet deposition distributions (Liu and Sullivan 1996; Liu et al. 2010). The fields of the Reynolds stress in the wall-jet region are shown in Fig. 34, and the profiles of τ T at five x-locations are shown in Fig. 35. The results given by both methods are in good agreement, and the RMS difference of τ T is 0.034 (pixels/unit time)2. The peak of τ T is located at about \(r/D = 1.8\).

Fig. 30
figure 30

Ensemble-averaged velocity vector and vorticity fields in the wall-jet region of the impinging jet by applying a the optical flow method and b the correlation method to the experimental particle images

Fig. 31
figure 31

Ensemble-averaged profiles of a the x-velocity and b y-velocity components at five x-locations in Fig. 30

Fig. 32
figure 32

Fields of the turbulent kinetic energy in the wall-jet region of the impinging jet by applying a the optical flow method and b the correlation method to the experimental particle images

Fig. 33
figure 33

Profiles of the turbulent kinetic energy at five x-locations in Fig. 32

Fig. 34
figure 34

Fields of the Reynolds stress in the wall-jet region of the impinging jet by applying a the optical flow method and b the correlation method to the experimental particle images

Fig. 35
figure 35

Profiles of the Reynolds stress at five x-locations in Fig. 34

6 Conclusions

The accuracy of the optical flow method applied to PIV images depends on the four parameters: particle displacement, particle velocity gradient, particle image density, and particle image diameter. The expression of error estimation is given, which is applicable to not only the optical flow method but also the correlation method. The root-mean-square (RMS) errors are evaluated in the parametric space through simulations based on a synthetic flow—an Oseen vortex pair in uniform flow. The errors in both methods are approximately proportional to the particle displacement and particle velocity gradient. When the particle image density is low and the particle image diameter is small, the errors in both methods are relatively large. As the particle image density and particle image diameter increase, the errors are generally decreased first and then slightly increased, and the optimal values for these parameters can be found. Simulations indicate that the optical flow method is able to extract velocity fields with much higher spatial resolution and improved accuracy from PIV images when the relevant parameters are suitably selected. Furthermore, the illumination intensity change between sequential images would significantly affect the accuracy of optical flow computation if this effect is not corrected. A simple scheme for correcting the local illumination intensity change is proposed and tested. The optical flow and correlation methods are further evaluated in PIV measurements in a normal impinging air jet. The snapshot and ensemble-averaged velocity fields in the impingement and wall-jet regions are obtained, and the statistical quantities, such as the turbulent kinetic energy, Reynolds stress, and kinetic energy spectrum, are calculated. It is found that the results given by both methods are generally in good agreement. However, there are some noticeable differences in the turbulent kinetic energy near the free jet shear layer.