How to divide an image by another image in opencv-python?

I’m processing PIV data.

PIV stands for particle image velocimetry. That’s the main tool in experimental fluid mechanics created in 1984s. This method gives you velocity field in a flow. Velocity field is when you know velocity at each point in a flow (turns out velocities at different points in a flow are different in general). All our equations describing fluid motion are written in terms of velocity fields. Once you’ve measured velocity fields, plug them into the equations and you are good to go uncovering new physics of flows. The way to measure velocity field is to seed the flow with tiny particles, illuminated them with a thin laser sheet, take two photos with a high-speed camera. Knowing the time between the photos and, provided you can identify the distance each particle has moved between the photos, you divide the distance by the time and get the velocity of the particle which you assume equal to the velocity of the flow at the point where the particle is located.

Identifying individual particles on the photos reliably enough to get the acceptable measurement accuracy can be difficult (due to uneven laser illumination, reflections and so on). Therefore, before you go ahead and measure velocity fields, you have to preprocess (precondition) the images. The preprocessing scheme can be different. For instance, for some images it is enough to just subtract the background. For others, you have to low-pass-filter the image, subtract it from the original image, then high-pass-filter the image, then binarize it and only then you can estimate the velocity field.

One of the preprocessing steps suggested by the guru (and creator) of PIV is image enhancement. Which is pretty much enhancing the contrast of the image. The contrast of the image (as suggested by the guru) can be enhanced either by the means of histogram equalization of by the means of min-max filter. Both of these methods have the purpose to increase the contrast of the image to make the seeding particles more distinct relative to the background.

The min-max filtering algorithm is suggested in the guru’s book (Adrian & Westerweel, “Particle image velocimetry”, 2011, Cambridge university press, see p.250 for the algorithm). The algorithm is presented in a MATLAB version in the book. I’m trying to convert it to Python for my needs.

As an example, I’m attaching one of my PIV images (not the best one)

1 Like