1 Introduction

Throughout the years, digital particle imaging velocimetry (PIV) has developed into a technique that can be used in more and more complicated systems (Adrian 2005). It has been successfully applied in turbulent flows, two-phase flows, and flows around objects. The performance of the technique is determined by the quality of the images and by the signal treatment after acquisition (Raffel et al. 2007). If the quality of the original images is good, i.e., even illumination, good contrast, low background noise, few stationary objects, suitable tracer particle displacement etc., image processing will be relatively straightforward. In practice, however, these conditions cannot always be accomplished. Laser intensity can vary between images or image pairs due to differences in the two lasers (in case of a double-pulsed YAG laser), objects or bubbles can introduce strong reflections of light, and/or reflection from channel walls in confined flows introduce glow. Several approaches are available in literature to tackle these problems (Seol and Socolofsky 2008; Lindken and Merzkirch 2002; Honkanen and Nobach 2005; Westerweel 1993; Shavit et al. 2007; Theunissen et al. 2008). In the presence of static objects or in two-phase flow, fluorescent particles and a color filter are often used to avoid interference of the object edges in the correlation map. In the case of two-phase flow, two cameras (of which one has a color filter) may be used to optically separate the two phases before correlation. Although this enables PIV of two-phase flow and edge flow, the average intensity of the tracer particles is lower (Raffel et al. 2007). In some cases, this will render the correlation rather difficult. Furthermore, fluorescent particles are about a factor ten more expensive than non-fluorescent particles, and calibration of the two cameras is more complicated (Seol and Socolofsky 2008).

Applying a static mask to block stationary objects from an image is a well-known technique to prevent these objects from interfering with the correlation map. However, if an object is semi-transparent, information on flow behind the object will be lost. To cope with moving bubbles shadowgraphy is often used (Lindken and Merzkirch 2002). This approach uses a second camera and background lighting to capture the shadows of moving objects, which can then be used to mask these areas from the images from the first camera. However, this approach requires an additional camera and careful alignment of the images from the two cameras. Since a large difference in size and intensity between the object and tracer particles is often present, these objects can also be identified and masked using only the original images from a single camera.

The use of an additional camera can be circumvented by removing the stationary objects through a background subtraction, which will leave moving tracer particles in the image as suggested by Honkanen and Nobach (2005). Image normalization to cope with uneven illumination was already suggested by Westerweel (1993). This methodology scales the intensity in the original image to a suitable minimum and/or maximum value. Common examples are subtracting a sliding minimum, sliding average, or scaling to the sliding minimum and -maximum. The last option is very attractive in applications with low light intensity, since the technique enhances tracer particle visibility. Since this approach also reduces the relative intensity of bright objects (bubble or object reflections) compared to the particle intensities, the relative contribution of these objects in the correlation function is also reduced (Shavit et al. 2007). Combining image normalization with background subtraction solves the problems of temporal and spatial variation in the intensity distribution, as discussed by Theunissen et al. (2008) recently.

In this work, we introduce a combined approach that can be implemented at relative ease, which tackles uneven illumination, the presence of stationary objects and moving objects (i.e. bubbles) without the use of additional hardware. This approach consists of intensity normalization (to cope with uneven illumination), followed by background subtraction (to remove stationary objects) and image masking (to remove the bubbles in two-phase flow). We demonstrate the capabilities of this approach with two examples: single-phase flow in spacer-filled channels and an extension to two-phase flow in these channels.

2 Theory

First the contrast of each frame is normalized with the aid of a local min/max filter:

$$ N({\mathbf{x}}) = {\frac{{I({\mathbf{x}}) - I_{\min } ({\mathbf{x}})}}{{I_{\max } ({\mathbf{x}}) - I_{\min } ({\mathbf{x}})}}} $$
(1)

where I min(x) and I max(x) are, respectively, the local sliding minimum and maximum using a filter length that is generally larger than the particle image diameter (~3 px) and smaller than the interrogation window width (~32 px):

$${I_{\min } }({\mathbf{x}}) = \mathop {\min }\limits_{{{\mathbf{x}} \in \Upomega }} (I({\mathbf{x}}));\quad I_{\max } ({\mathbf{x}}) = \mathop {\max }\limits_{{{\mathbf{x}} \in \Upomega }} (I({\mathbf{x}})) $$
(2)

where Ω is the square-shaped filter domain.

To ensure that the local minima and maxima have the same intensities, the filtered intensities are stretched based on the global minimum and maximum intensities:

$$ S({\mathbf{x}}) = {\frac{{N({\mathbf{x}}) - I_{\min } }}{{I_{\max } - I_{\min } }}}.$$
(3)

After the image is properly normalized and stretched, frames 1 and 2 can be subtracted from one another to remove stationary objects in the background:

$$ B_{1}^{{}} ({\mathbf{x}}) = \max (S_{1}^{{}} ({\mathbf{x}}) - S_{2}^{{}} ({\mathbf{x}}),0);\quad B_{2}^{{}} ({\mathbf{x}}) = \max (S_{2}^{{}} ({\mathbf{x}}) - S_{1}^{{}} ({\mathbf{x}}),0).$$
(4)

3 Mask generating for images containing non-stationary objects

When non-stationary objects, like bubbles, are also present in the images, the algorithm for stationary objects requires one additional step. While the normalization, stretching and background subtraction is sufficient to remove the stationary objects, the removal of non-stationary objects is accomplished by applying a mask to the moving objects. This procedure was specifically developed for the removal of bubbles, which appear as bright rings on the image and is similar to Seol and Socolofsky (2008). When other moving objects are present, the generation of the mask might require adaptations depending on the reflection pattern of the object (Fig. 1).

Fig. 1
figure 1

Schematic overview of the preprocessing steps

To create the mask, a frame that does not contain any bubbles is subtracted from the frame to be analyzed. Subsequently, the resulting image is scaled to (i.e. divided by) the maximum intensity of the image, yielding an image with intensities between 0 and 1. Then, the scaled image is binarized, using a threshold that is determined by trial and error giving a typical value of 0.02. That is, each pixel with intensity higher than the threshold is set to 1. Subsequently, noise is removed (i.e., small objects with less than 200 connecting pixels). The obtained image now contains only bright rings originating from the bubbles. These rings may contain openings, which are closed by applying an erode-dilate operation three times to ensure full closure of the bubble edge, using a circular structuring element of 20 px. Now, all bubble edges should form closed rings, and the bubbles can be filled up by setting the intensity of the bubble interior equal to 1. In a final step, any small objects are removed from the image, and the image is inverted so that the bubbles have an intensity value of 0, and all the rest have an intensity value of 1.

4 Results and discussion

4.1 Liquid flow

As a first example of the pre-processing method described in this paper, single-phase liquid flow through a spacer-filled channel is discussed. A spacer is a mat-like structure with two layers of filaments at non-zero angles relative to each other, see for example Fig. 2. Generally, angles vary between 45 and 90°. These spacers are typically used to separate membrane sheets and promote turbulence in a membrane module. This type of structure is encountered in spiral wound modules, which are often used for drinking water production (Schwinge et al. 2004) (also see Fig. 3).

Fig. 2
figure 2

Raw image, filaments \\ are at the front of the cell, filaments // are at the back. The square indicates the position of the interrogation area shown in this article (located at 788, 988 px)

Fig. 3
figure 3

Schematic representation of a spiral-wound membrane module (taken from www.mtrinc.com with permission)

Figure 4a–d show the correlation map at the position indicated in Fig. 2 for various stages of the pre-processing sequence. This area includes parts of the spacer structure. Figure 4a shows the correlation map for the original image. This shows one broad peak with the center at the origin. This is mainly caused by the correlation of the stationary spacer, which is oriented at a 45° angle to the x-direction. Figure 4b shows that after background subtraction, no clear displacement peak is present; however, a displacement peak is visible in a valley. Since this peak is not the highest in the correlation map, it is not detected by the PIV algorithm. The height of the correlation peak in general is also limited due to the varying intensities between the two laser pulses. The correlation map for the normalized image (Fig. 4c) shows a large ridge at a 45° angle to the x-direction with a sharp peak at the origin, which is again caused by the spacer. The displacement peak is only visible once the normalization and background subtraction are combined, as shown in Fig. 4d. The resulting time-averaged vector field is shown in Fig. 5. The problem of elimination of particles with a displacement smaller than one particle diameter by the image subtraction algorithm (Theunissen et al. 2008) is not applicable here, since the magnification combined with the size of the applied interrogation area is not detailed enough to resolve the boundary layer flow around the spacer.

Fig. 4
figure 4

128×128 Correlation map for a the original image, b the background subtracted image, c the normalized image, and d the normalized & background subtracted image (peak position (−12, −11 px)). Note that the original image is indicated by a white square in Fig. 2. The xy positions are indicated in pixels

Fig. 5
figure 5

Time-averaged velocity field (final interrogation area 32×32 px, 100 frames), the inverted original image is shown in the background, and only 1/4 of the vectors is shown for clarity

4.2 Gas–liquid flow

Conventionally, spiral wound modules are operated in single-phase flow. During operation, these modules get fouled by for example deposits and biofouling. Recently, the use of air sparging has been suggested as a cleaning method for these modules (Cui et al. 2003). Several options have been proposed for the mechanism of cleaning method through air sparging, which mechanism dominates is still unknown, and optimization of the cleaning process is mainly empirical. Therefore, a detailed study on two-phase flow in these channels is of interest to ultimately improve drinking water capacity and quality.

The effect of normalization, subtraction, and masking for the position shown in Fig. 6 is shown in Fig. 7. The correlation map of the original image (Fig. 7a) shows a large ridge, which corresponds with the bubble edge. Figure 7b shows that masking does not remove this ridge, due to the uneven illumination of the image pairs. If the image is only normalized (Fig. 7c), this ridge is still present, although the overall height of the peak is reduced. This is due to the reduction in the bubble intensity relative to the particle and spacer intensity by the normalization procedure. As can be seen from Fig. 7d, this problem is not solved by the subsequent background subtraction. Since the bubble is moving, parts of the bubble edge are still present in the subtracted image, and these interfere in the correlation of the particles. Again, the displacement peak of the particles is only detectable in the final step of the process, which is after the bubble masking. This removes the bubble residues from the normalized & background subtracted image, where after only the particles remain in the image. This example shows that a combined approach can significantly enhance the correlation of the images with challenging circumstances. The vector field for this image pair is shown in Fig. 8.

Fig. 6
figure 6

Raw image for gas–liquid flow, the square indicates the interrogation area (position 547, 547 px)

Fig. 7
figure 7

128×128 Correlation map for a the original image, b the masked image, c the normalized image, d the normalized & background subtracted image, and e the normalized, background subtracted, and masked image (peak position (4, −6 px)). Note that the original image is indicated by a white square in Fig. 6. The xy positions are indicated in pixels

Fig. 8
figure 8

Vector field of the image shown in Fig. 6 (final interrogation area 32×32 px), the inverted original image is shown in the background

5 Conclusions

It was shown that the processing of PIV-image pairs can be greatly enhanced by using a proper pre-processing scheme. For single-phase flow, good correlation can be obtained in the presence of stationary objects by normalization followed by background subtraction. This has the advantage over masking of the stationary objects that flow behind/over a semitransparent object can still be studied. For two-phase flow, this procedure was extended with a masking step to remove non-stationary bubbles from the image pair. In both cases, all the steps in the procedure are required to obtain the particle displacement peak. The velocity fields that can be obtained for spacer-filled channels with this procedure will provide valuable information to determine the mechanism behind the cleaning through air sparging as well as high quality validation data for CFD models. In the long term, this information can be used to optimize air sparging in industrial applications.