# Water Level Detection

Given a reigon of interest, the water level can be estimated for preventing flood. There are three ways to detect the water level that I implemented - texture, optical flow, and matting methods.

## Using Optical Flow

When the current of water is strong, the optical flow of the ROI is useful to detect the water level. I implemented [1] for this, and the optical flow is calculated in each patch of the ROI. As a result, a kind of probaility map for water is created. It can be used as a water mask. This is a time consuming algorithm due to the optical flow estimation as the ROI is getting large, but it is the most intuitive way to detect the water level when the flow is obvious. Considering we want to detect the flood after all, it is a reasonable assumption that the flow would be strong when we use this algorithm.

## Using Texture

There may be the light or shadow which is obstructing the correct detection. For this situation, the only ripple shape or feature can be extracted in the water image. In [2], it is possible that the strong ripple can be estimated column by column which is pre-determined using Local Binary Patterns. The middle image is the LBP of the left image which has ripples as above. From this LBP, the ripple line can be estimated as the red lines of the right image. The pixels below this lines can be considered as a water mask.

## Using Matting

Matting is well-known algorithm for foreground detection. It can separate a complex object such as hair or fur from the background image. This can be applied to detect the water level becuse we can see the water area as the foreground. In [3], the authors suggest a probabilitic way to estimate matte, and it seems to be great to detect the water level in terms of the performance. The middle image is the estimated matte from the left image, and the right image is the extracted foreground.

The sample video at the top is based on the video [4], I used the part of this video for testing.

## References

[1] Bruhn, A., Weickert, J., Feddern, C., Kohlberger, T., and Schnorr, C., Real-time optic flow computation with variational methods, 2003

[2] Mettes, P., Tan, R. T., Veltkamp, R. C., Water Detection through Spatio-Temporal Invariant Descriptors, 2015

[3] Kaiming He, Christoph Rhemann, Carsten Rother, Xiaoou Tang, Jian Sun, A Global Sampling Method for Alpha Matting, 2011