# UBathy (v2.0): A Software to Obtain the Bathymetry from Video Imagery

^{1}

^{2}

^{*}

^{†}

## Abstract

**:**

## 1. Introduction

## 2. Methods and Software Description

**Software characteristics.**UBathy is an open source software developed in (also open source) Python3 and available at GitHub platform. It runs on any platform with a standard installation of Python3.9 (i.e., with “The Python Standard Library”) and OpenCV, NumPy, SciPy and matplotlib modules. The code is complemented with an example case so that any user can fully execute it. A guided example is included to run on Jupyter Notebook to facilitate its use to non-experienced users. The software is suitable for users who are familiar with coastal image processing.**Videos sources.**A novel aspect of UBathy is that allows to directly process videos of raw camera images in addition to usual planview videos. In the first case (raw images), the videos can be acquired typically from fixed video monitoring stations (“Argus” type, [14]) but also from new CoastSnap stations [21]. For their processing, only the calibration of the camera is needed, without any further post-processing, together with the position of the mean water level at the time of the recording. Videos of planviews can normally come from fixed video monitoring stations or from the processing of drone flights. For planview videos it is necessary to know their georeference and the position of the mean water level.**Mode decomposition.**The extraction of the wave modes and corresponding wave periods is performed by global analysis of the images. The software allows, at user’s request, to decompose the videos in time (wave periods) and space (wave phase) using EOF, following [12], or DMD [13]. In addition, the user can also reduce the signal noise of the videos by applying an RPCA [19]. The wavenumber estimation uses local adjustments of the wave phase.**Bathymetry estimation.**The bathymetry is obtained by fitting the surface waves dispersion relationship with the wavenumbers and frequencies of the different modes, taking into account the different mean water levels. Another novel aspect of this software is the flexibility to obtain the bathymetry by assembling videos that: (1) cover different parts of the coastal area, (2) do not need to be recorded synchronously and with the same sea level and, (3) are made of different types of images (planviews and raw images). In addition to the bathymetry obtained from the above analysis, a Kalman filter is used to obtain the bathymetry at a given time by accumulating the results obtained up to that time.

**Step 0:****Video and data setup**. The video frames, data for image georeferencing and mean water level during the recording of the videos are provided.**Step 1:****Generation of meshes.**Generation of the spatial meshes to express the mode decomposition, the wavenumbers and the bathymetry.**Step 2:****Mode decomposition.**The wave is decomposed into different modes, with the corresponding wave period and spatial phase.**Step 3:****Wavenumber computation.**The spatial phase of each mode is analyzed to extract the wavenumbers in the spatial domain.**Step 4:****Bathymetry estimation.**Estimation of the bathymetry from the set of periods and wavenumbers of different videos.**Step 5:****Kalman filtering.**Determination of the bathymetry evolution by time filtering the bathymetry results obtained from videos at different times.

#### 2.1. Methodological Background

#### 2.1.1. Generation of Meshes

#### 2.1.2. Mode Decomposition

#### 2.1.3. Wavenumber Computation

#### 2.1.4. Bathymetry Estimation

#### 2.1.5. Kalman Filtering

#### 2.2. Software Implementation

#### 2.2.1. Video and Data Setup

`xy_boundary.txt`), a file with the list of videos that compose the different bathymetry results (

`videos4dates.json`) and a main file of parameters (

`parameters.json`) where the values of the parameters described in Section 2.1, and few other introduced here, are assigned. The equivalence between the parameters of the previous section and the name of the parameters in the

`parameters.json`file is detailed in the Table 1. It is also possible to provide ground truth bathymetry that can be used to evaluate the results obtained with UBathy.

#### 2.2.2. Generation of Meshes

`parameters.json`, the domain defined in

`xy_boundary.txt`and the spatial region covered by the images as described in Section 2.1.1. These meshes are stored in a temporary

`scratch`folder in NPZ format (a compressed format for multiple arrays from Numpy). On user demand, plots of the meshes are also saved in the

`scratch`folder.

#### 2.2.3. Mode Decomposition

`parameters.json`file. Again, the files generated by the code containing the period and the spatial phase of the wave modes will be stored compressed in the

`scratch`folder and, optionally, plots of the decomposition will be generated.

#### 2.2.4. Wavenumber Computation

#### 2.2.5. Bathymetry Estimation

`videos4dates.json`file. Further, the values of the critical error ${e}_{\mathrm{B}}$ and coefficient ${c}_{\mathrm{B}}$ to estimate the bathymetry must be set (Section 2.1.4, Table 1). Similar to the other steps, the compressed results and plots with the bathymetric results are saved in the

`scratch`folder. Here, additionally, a file with the coordinates of the B-mesh points and another one with the bathymetry values and its self-assessed errors are generated in plain text format. If reference bathymetry (ground truth) have been provided, a file is also generated with the values of the bathymetry interpolated at the same B-mesh. If requested by the user, the corresponding plots are saved in this same folder.

#### 2.2.6. Kalman Filtering

`bathymetries`folder and in a plain text format. In the

`parameters.json`parameter file, the time interval (${t}_{\mathrm{ini}}$ and ${t}_{\mathrm{fin}}$, expressed as

`yyyyMMddhhmm`) over which the filtering is to be performed and the variability of bottom Q are specified. Output files are generated in plain text format in the same folder, including optional plots.

## 3. Results and Discussion

#### 3.1. Bathymetry Estimation

#### 3.1.1. Generation of Meshes

`xy_boundary.txt`, blue lines in Figure 10), the meshes have been constructed setting, in

`parameters.json`, the values for ${\delta}_{\mathrm{M}}$, ${\delta}_{\mathrm{K}}$ and ${\delta}_{\mathrm{B}}$ in Table 1 (“example” column). The M-meshes for both videos are those already shown in Figure 2 (top). The value of ${\delta}_{\mathrm{M}}$ is not used for the planview video, since the M-mesh is directly the squared mesh from the planview. Figure 2 also includes (bottom) the K-meshes. Given that the values of the wavenumbers at K-mesh are computed from the values of the modes at M-mesh, ${\delta}_{\mathrm{M}}$ establishes the maximum reachable spatial resolution and it is recommended that ${\delta}_{\mathrm{K}}\u2a7e{\delta}_{\mathrm{M}}$ to avoid wasted efforts. Finally, the B-mesh, independent on the video, is the one in Figure 3. Following the same reasoning above in regard to the reachable resolutions, it is recommended that ${\delta}_{\mathrm{B}}\u2a7e{\delta}_{\mathrm{K}}$.

#### 3.1.2. Mode Decomposition

#### 3.1.3. Wavenumber Computation

#### 3.1.4. Bathymetry Estimation

#### 3.2. Kalman Filtering

## 4. Conclusions

## Author Contributions

## Funding

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## Abbreviations

EOF | Empirical orthogonal functions |

DMD | Dynamic mode decomposition |

FFT | Fast Fourier transform |

RANSAC | Random sample consensus approach |

RPCA | Robust principal component algorithm |

## Appendix A. Software Source Code

**Software name:**UBathy**Developers:**Gonzalo Simarro, Daniel Calvete**Contact address:**`simarro@icm.csic.es`**Cost:**free**License:**Creative Commons Attribution 4.0 International**Availability:**https://doi.org/10.5281/zenodo.7360216**Year first available:**2022**New developments:**https://github.com/Ulises-ICM-UPC/UBathy (accessed on 10 November 2022)**Hardware requirements:**PC, server.**System requirements:**Windows, Linux, Mac.**Program language:**Python (3.9)**Dependencies:**OpenCV, NumPy, SciPy and matplotlib modules.**Program size:**100 KB**Documentation:**README in GitHub repository and example in an editable Jupyter Notebook.

## References

- Davidson, M.; Van Koningsveld, M.; de Kruif, A.; Rawson, J.; Holman, R.; Lamberti, A.; Medina, R.; Kroon, A.; Aarninkhof, S. The CoastView project: Developing video-derived Coastal State Indicators in support of coastal zone management. Coast. Eng.
**2007**, 54, 463–475. [Google Scholar] [CrossRef] - Kroon, A.; Davidson, M.; Aarninkhof, S.; Archetti, R.; Armaroli, C.; Gonzalez, M.; Medri, S.; Osorio, A.; Aagaard, T.; Holman, R.; et al. Application of remote sensing video systems to coastline management problems. Coast. Eng.
**2007**, 54, 493–505. [Google Scholar] [CrossRef] - Calvete, D.; Coco, G.; Falqués, A.; Dodd, N. (Un)predictability in rip channel systems. Geophys. Res. Lett.
**2007**, 34, 1–5. [Google Scholar] [CrossRef][Green Version] - Arriaga, J.; Rutten, J.; Ribas, F.; Falqués, A.; Ruessink, G. Modeling the long-term diffusion and feeding capability of a mega-nourishment. Coast. Eng.
**2017**, 121, 1–13. [Google Scholar] [CrossRef][Green Version] - Birkemeier, W.; Mason, C. The crab: A unique nearshore surveying vehicle. J. Surv. Eng.
**1984**, 110, 1–7. [Google Scholar] [CrossRef] - Hughes Clarke, J.; Mayer, L.; Wells, D. Shallow-water imaging multibeam sonars: A new tool for investigating seafloor processes in the coastal zone and on the continental shelf. Mar. Geophys. Res.
**1996**, 18, 607–629. [Google Scholar] [CrossRef] - Irish, J.; White, T. Coastal engineering applications of high-resolution lidar bathymetry. Coast. Eng.
**1998**, 35, 47–71. [Google Scholar] [CrossRef] - Almar, R.; Bergsma, E.; Maisongrande, P.; de Almeida, L. Wave-derived coastal bathymetry from satellite video imagery: A showcase with Pleiades persistent mode. Remote Sens. Environ.
**2019**, 231, 111263. [Google Scholar] [CrossRef] - Holman, R.; Plant, N.; Holland, T. CBathy: A robust algorithm for estimating nearshore bathymetry. J. Geophys. Res. Ocean
**2013**, 118, 2595–2609. [Google Scholar] [CrossRef] - Holman, R.A.; Brodie, K.L.; Spore, N.J. Surf Zone Characterization Using a Small Quadcopter: Technical Issues and Procedures. IEEE Trans. Geosci. Remote Sens.
**2017**, 55, 2017–2027. [Google Scholar] [CrossRef] - Bell, P. Shallow water bathymetry derived from an analysis of X-band marine radar images of waves. Coast. Eng.
**1999**, 37, 513–527. [Google Scholar] [CrossRef] - Simarro, G.; Calvete, D.; Luque, P.; Orfila, A.; Ribas, F. UBathy: A new approach for bathymetric inversion from video imagery. Remote Sens.
**2019**, 11, 2722. [Google Scholar] [CrossRef][Green Version] - Gawehn, M.; De Vries, S.; Aarninkhof, S. A self-adaptive method for mapping coastal bathymetry on-the-fly from wave field video. Remote Sens.
**2021**, 13, 4742. [Google Scholar] [CrossRef] - Holman, R.; Stanley, J. The history and technical capabilities of Argus. Coast. Eng.
**2007**, 54, 477–491. [Google Scholar] [CrossRef] - Honegger, D.; Haller, M.; Holman, R. High-resolution bathymetry estimates via X-band marine radar: 1. beaches. Coast. Eng.
**2019**, 149, 39–48. [Google Scholar] [CrossRef] - Simarro, G.; Calvete, D.; Plomaritis, T.A.; Moreno-Noguer, F.; Giannoukakou-Leontsini, I.; Montes, J.; Durán, R. The influence of camera calibration on nearshore bathymetry estimation from UAV videos. Remote Sens.
**2021**, 13, 150. [Google Scholar] [CrossRef] - Holman, R.; Bergsma, E. Updates to and performance of the cbathy algorithm for estimating nearshore bathymetry from remote sensing imagery. Remote Sens.
**2021**, 13, 3996. [Google Scholar] [CrossRef] - Schmid, P.J. Dynamic mode decomposition of numerical and experimental data. J. Fluid Mech.
**2010**, 656, 5–28. [Google Scholar] [CrossRef][Green Version] - Candes, E.; Li, X.; Ma, Y.; Wright, J. Robust principal component analysis? J. ACM
**2011**, 58, 1–37. [Google Scholar] [CrossRef] - Fischler, M.; Bolles, R. Random sample consensus: A Paradigm for Model Fitting with Applications to Image Analysis and Automated Cartography. Commun. ACM
**1981**, 24, 381–395. [Google Scholar] [CrossRef] - Harley, M.D.; Kinsela, M.A. CoastSnap: A global citizen science program to monitor changing coastlines. Cont. Shelf Res.
**2022**, 245, 104796. [Google Scholar] [CrossRef] - Askham, T.; Zheng, P.; Aravkin, A.; Kutz, J.N. Robust and Scalable Methods for the Dynamic Mode Decomposition. SIAM J. Appl. Dyn. Syst.
**2022**, 21, 60–79. [Google Scholar] [CrossRef] - Simarro, G.; Orfila, A. Improved explicit approximation of linear dispersion relationship for gravity waves: Another discussion. Coast. Eng.
**2013**, 80, 15. [Google Scholar] [CrossRef] - Simarro, G.; Calvete, D. UBathy: A Software to Obtain Bathymetry from Video Imagery; Version 2.0.0; CERN: Geneva, Switzerland, 2022. [Google Scholar] [CrossRef]
- de Swart, R.; Ribas, F.; Simarro, G.; Guillén, J.; Calvete, D. The role of bathymetry and directional wave conditions on observed crescentic bar dynamics. Earth Surf. Process. Landforms
**2021**, 46, 3252–3270. [Google Scholar] [CrossRef] - Ribas, F.; Simarro, G.; Arriaga, J.; Luque, P. Automatic shoreline detection from video images by combining information from different methods. Remote Sens.
**2020**, 12, 3717. [Google Scholar] [CrossRef] - Simarro, G.; Bryan, K.; Guedes, R.; Sancho, A.; Guillen, J.; Coco, G. On the use of variance images for runup and shoreline detection. Coast. Eng.
**2015**, 99, 136–147. [Google Scholar] [CrossRef] - Simarro, G.; Ribas, F.; Álvarez, A.; Guillén, J.; Chic, O.; Orfila, A. ULISES: An open source code for extrinsic calibrations and planview generations in coastal video monitoring systems. J. Coast. Res.
**2017**, 33, 1217–1227. [Google Scholar] [CrossRef]

**Figure 1.**Basic characteristics in regard data input and use of Kalman filter for cBathy (

**A**), COCOs (

**B**) and the proposed improved version of UBathy (

**C**).

**Figure 2.**Meshes for modes (

**top**) and wavenumbers (

**bottom**) for videos made up of planviews (

**A**,

**C**) and raw images (

**B**,

**D**). The bathymetry domain is shown in blue; planview (

**A**,

**C**) or camera (

**B**,

**D**) domains are shown in red.

**Figure 4.**Sub-video generation from a video; the time step between frames is 1 fps (fps = frames per second).

**Figure 6.**Spatial phase of two modes obtained for videos of planviews (

**A**) and raw images (

**B**). The white circle (

**A**) represents the size of the neighborhood to estimate the wavenumber.

**Figure 7.**Wavenumber k (

**A**), $\gamma $ (

**B**), ${\mu}_{\gamma}$ (

**C**) and ${\sigma}_{\gamma}$ (

**D**) obtained from the spatial phases and period in Figure 6A, taking ${R}_{\mathrm{K}}$ the radius of the white circle in the same figure.

**Figure 9.**Estimation of ${z}_{b}$ from tuples $\phantom{\rule{0.166667em}{0ex}}\left(\omega ,k,{z}_{s}\right)\phantom{\rule{0.166667em}{0ex}}$: RANSAC discard (

**A**) and optimization (

**B**).

**Figure 10.**Images from Castelldefels beach station. Raw images from the two (out of five) cameras considered (

**A**,

**B**) and the planview (

**C**) obtained from image B. The boundary of the domain to obtain the bathymetry is shown in blue. The black part in C corresponds to the part of the planview domain (rectangular) which is not reached by the camera.

**Figure 11.**Number of useful pairs $\phantom{\rule{0.166667em}{0ex}}\left(\omega ,k\right)\phantom{\rule{0.166667em}{0ex}}$ obtained for the planview video for ${d}_{1}$ (

**A**) and ${d}_{3}$ (

**B**).

**Figure 12.**Bathymetry (

**top**, (

**A**,

**B**)) and errors (

**bottom**, (

**C**,

**D**)), relative to the ground truth (${z}_{b,\mathrm{GT}}$) obtained using the 160 s (

**left**, (

**A**,

**C**)) and 600 s (

**right**, (

**B**,

**D**)) videos.

**Figure 13.**Bathymetry (

**top**, (

**a**,

**b**)) and errors (

**bottom**, (

**c**,

**d**)) obtained without RANSAC for ${c}_{\mathrm{K}}=0.6$ (

**left**, (

**a**,

**c**)) and ${c}_{\mathrm{K}}=0.2$ (

**right**, (

**b**,

**d**)).

**Figure 14.**Bathymetry (

**top**, (

**A**,

**B**)) and errors (

**bottom**, (

**C**,

**D**)) for cropped (160 s) videos without using Kalman (

**left**, (

**A**,

**C**)) and using Kalman filter starting 7 days before (

**right**, (

**B**,

**D**)).

**Table 1.**List of variables in

`parameters.json`, including the present nomenclature, the names in

`parameters.json`, the reference values considered in the examples and a suggested range of use (whenever it is not site dependent).

Variable | parameters.json | Unit | Example | Ranges | |
---|---|---|---|---|---|

generation of meshes | ${\delta}_{\mathrm{M}}$ | delta_M | m | $2.5$ | - |

${\delta}_{\mathrm{K}}$ | delta_K | m | $5.0$ | - | |

${\delta}_{\mathrm{B}}$ | delta_B | m | $5.0$ | - | |

mode decomposition | $\Delta t$ | time_step | s | 30 | [1–60] |

$\{{w}_{1},{w}_{2},\cdots \}$ | time_windows | s | $\{60,90,120\}$ | [30–150] | |

${T}_{\mathrm{min}}$ | min_period | s | 3 | - | |

${T}_{\mathrm{max}}$ | max_period | s | 15 | - | |

${I}_{\mathrm{M}}$ | candes_iter | - | 50 | [40–80] | |

- | DMD_or_EOF | - | “DMD” | “DMD” or “EOF” | |

${r}_{\mathrm{D}}$ | DMD_rank | - | 6 | [5–10] | |

${v}_{\mathrm{E}}$ | EOF_variance | - | $0.025$ | [0.010–0.100] | |

wavenumber computation | ${d}_{\mathrm{min}}$ | min_depth | m | $0.5$ | - |

${d}_{\mathrm{max}}$ | max_depth | m | $6.0$ | - | |

${n}_{\mathrm{K}}$ | nRadius_K | - | 3 | [2–5] | |

${c}_{\mathrm{K}}$ | cRadius_K | - | $0.60$ | [0.40–0.60] | |

${m}_{\mathrm{K}}$ | nRANSAC_K | - | 50 | [25–100] | |

bathymetry estimation | ${e}_{\mathrm{B}}$ | stdGammaC | - | $0.075$ | [0.050–0.150] |

${c}_{\mathrm{B}}$ | cRadius_B | - | $0.20$ | [0.10–0.30] | |

Kalman filtering | ${t}_{\mathrm{ini}}$ | Kalman_ini | yyyyMMddhhmm | 202007250800 | - |

${t}_{\mathrm{fin}}$ | Kalman_fin | yyyyMMddhhmm | 202008010900 | - | |

Q | var_per_day | m/day | $0.1$ | [0.05–0.25] |

**Table 2.**Summary results for the bathymetry obtained for the cropped (160 s) and full (600 s) videos using all ${d}_{j}$ at once (as in UBathy) and using one each time. The reference case is “all ${d}_{j}$” with “videos of 160 s”.

Videos of 160 s | Videos of 600 s | |||||
---|---|---|---|---|---|---|

Case | Points | Biasm | RMSEm | Points | Biasm | RMSEm |

all ${d}_{j}$ | 5609 | $-0.18$ | $0.38$ | 6174 | $-0.10$ | $0.26$ |

only ${d}_{1}$ | 5270 | $-0.07$ | $0.32$ | 6134 | $+0.01$ | $0.23$ |

only ${d}_{2}$ | 5282 | $-0.22$ | $0.39$ | 6026 | $-0.12$ | $0.26$ |

only ${d}_{3}$ | 5105 | $-0.27$ | $0.44$ | 5977 | $-0.17$ | $0.28$ |

**Table 3.**Summary results for the bathymetry using RANSAC with ${e}_{\mathrm{B}}=0.075$ (reference case) and without RANSAC with ${e}_{\mathrm{B}}=0.15$ and for different values of ${c}_{\mathrm{K}}$.

Videos of 160 s | |||
---|---|---|---|

Case | Points | Bias m | RMSE m |

RANSAC, ${c}_{\mathrm{K}}=0.6$ | 5609 | $-0.18$ | $0.38$ |

no RANSAC, ${c}_{\mathrm{K}}=0.6$ | 4420 | $-2.17$ | $2.33$ |

no RANSAC, ${c}_{\mathrm{K}}=0.4$ | 5427 | $-0.86$ | $1.12$ |

no RANSAC, ${c}_{\mathrm{K}}=0.2$ | 5989 | $+0.15$ | $0.57$ |

no RANSAC, ${c}_{\mathrm{K}}=0.1$ | 4502 | $+1.12$ | $1.69$ |

Videos of 160 s | Videos of 600 s | |||||
---|---|---|---|---|---|---|

Case | Points | Biasm | RMSEm | Points | Biasm | RMSEm |

no Kalman | 4119 | $-0.18$ | $0.39$ | 4429 | $-0.09$ | $0.22$ |

1 day | 4346 | $-0.15$ | $0.33$ | 4469 | $-0.13$ | $0.24$ |

2 days | 4364 | $-0.20$ | $0.33$ | 4477 | $-0.17$ | $0.27$ |

3 days | 4394 | $-0.15$ | $0.28$ | 4480 | $-0.14$ | $0.24$ |

4 days | 4394 | $-0.15$ | $0.28$ | 4480 | $-0.14$ | $0.24$ |

5 days | 4412 | $-0.15$ | $0.28$ | 4488 | $-0.13$ | $0.23$ |

6 days | 4419 | $-0.17$ | $0.29$ | 4493 | $-0.15$ | $0.28$ |

7 days | 4419 | $-0.17$ | $0.29$ | 4493 | $-0.16$ | $0.29$ |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Simarro, G.; Calvete, D.
UBathy (v2.0): A Software to Obtain the Bathymetry from Video Imagery. *Remote Sens.* **2022**, *14*, 6139.
https://doi.org/10.3390/rs14236139

**AMA Style**

Simarro G, Calvete D.
UBathy (v2.0): A Software to Obtain the Bathymetry from Video Imagery. *Remote Sensing*. 2022; 14(23):6139.
https://doi.org/10.3390/rs14236139

**Chicago/Turabian Style**

Simarro, Gonzalo, and Daniel Calvete.
2022. "UBathy (v2.0): A Software to Obtain the Bathymetry from Video Imagery" *Remote Sensing* 14, no. 23: 6139.
https://doi.org/10.3390/rs14236139