Message Boards Message Boards


Estimation of water velocity in a video using Mathematica

Posted 3 months ago
5 Replies
18 Total Likes


Today morning I measured the velocity of river flow by velocimeter and it was 1.15 m/s.

For studying the ability of the Mathematica in video file processing, I took a 60-second video from the water surface with a smartphone. I attached herewith the video file.

Is it possible to estimate this important parameter in this video using the Mathematica?

enter image description here

Although, two years ago, we did a study for estimating water suspended sediment in a laboratory flume, based on image processing (NOT VIDEO). We got the expected results and it was excellent.enter image description here enter image description here

Thank you for your help.

5 Replies
Posted 2 months ago

I am not familiar with Mathematica video processing capabilities. However, this does seem like a very interesting problem.

I do not know if standard image descriptors would be enough to reliably track the motion of ripples in the water, but maybe one of the algorithms in ImageKeypoints could be used to estimate flow in pixel space by tracking the movement of descriptor features. Pixel-space motion could be converted to real-world speeds if you know the distance of the camera from the water and the camera's calibration parameters.

To use machine learning, I believe you would need a diverse dataset with hundreds --or perhaps thousands-- of flow measurements and videos of different rivers. If you built a large dataset, you might be able to use the audio from the video to improve the flow rate estimate as well.

I have done some basic filtering and data exploration in the notebook below.

I do not know enough about turbulence to even begin to estimate the flow rate just from frame-to-frame differences in the water's surface. I would try to collect more data and see what accuracies can be achieved using standard image regression algorithms like wolfram's Predict - which uses gradient-boosted trees, neural networks, etc.

Frame-to-frame difference after image blur:


Frame-to-frame difference after GaussianFilter:


Frame-to-frame difference after LaplacianGaussianFilter:


Sorry that I have no definitive solutions, this is a challenging problem!

Best of luck, Mr. Ghorbani. Be sure to write a reply if you think of any interesting solutions yourself!

Dear Alec,

You did a great job. Thank you so much for your effort. Estimating water velocity with the camera/smartphone is very important. I will take a high-quality video from water surfaces in specific dimensions and try some things. I will definitely let you know if I find a solution.

I really really appreciate your help.

Posted 2 months ago

Dear Alec,

One of the famous researchers in this field is Dr. Daniel Bung ( from the University of Applied Sciences, Germany.

He has published excellent papers in measuring the velocity of surface water using image processing. For your info, I send you his suggestion :

"Dear Prof. Ghorbani,

I thank you for your e-mail. Estimation of surface velocities based on ripples, i.e. image textures, is possible (a sufficient sample rate is necessary). You may use a) a cross-correlation-based techniques or b) an optical-flow-based technique. In the latter case, a (almost) constant illumination is required, which may be difficult to obtain in a natural environment. However, I am convinced that you may succeed if an appropriate method is used. The Lucas-Kanade technique, for instance, is comparable to a PTV method (i.e. Lagrangian), selecting good features (textures) to track. I am not sure if this method was applied in your code. Such method may perform superiorly in comparison to some global methods as no continuous pattern is available for image velocimetry. I am not familiar with Mathematica, but I know that this method works fine with OpenCV in Python. However, a traditional cross-correlation-based method (i.e. like PIV) may be suitable as well. Please note that there is even commercial instrumentation available using exactly this technique (stationary or with cell phone). In any case, image preprocessing (filtering), like background subtraction, histogram equalization and blurring (as was done in the code) may help to improve the results. The quality of the filters depend on the particular case. We have tested some filters in a congress paper (IAHR World congress in The Hague) applied to bubble images. The results may give you an idea of how these filters perform. So, all in all I think you are on the right way. I hope these comments are helpful.

Kind regards from Germany,


Posted 2 months ago


You did a good job. This is a very important issue in water engineering.

In the lab, I measured the velocity of water for 20 velocities e.g. 0, 0.264, 0.444,......, and 0.607 m/s. I enclosed only a sample of videos. It may be helpful in achieving the expected results. enter image description here

Posted 1 month ago


I took a 60 seconds high-quality video from another river. The surface water velocity is 1.66 m/s. It may be better for video analysis. Please see the enclosed video.


Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract