TopoToolbox / libtopotoolbox

A C library for the analysis of digital elevation models.
https://topotoolbox.github.io/libtopotoolbox/
GNU General Public License v3.0
0 stars 5 forks source link

Sink filling (`fillsinks`) #7

Closed wkearn closed 6 months ago

wkearn commented 6 months ago

The MATLAB code uses morphological reconstruction as implemented by the Image Processing Toolbox (imreconstruct) to fill sinks in the DEM.

@Teschl: you have some sink filling C code, right? How confident are you that it works?

Teschl commented 6 months ago

The fillsinks code only fills sinks that are 1 pixel in size. So as of right now i would say it does not work at all.

wschwanghart commented 6 months ago

Yes, filling sinks is not trivial...

wkearn commented 6 months ago

I have something that replicates the MATLAB imreconstruct functionality in C. I'll try to get a pull request together today so we can have a look. Even if we ultimately decide to implement sink filling in a different way, I think it will be a good point to start iterating on the library interface and to start building some frameworks for testing, benchmarking and documentation.

wschwanghart commented 6 months ago

A replication of imreconstruct would be perfect as morphological image reconstruction is much more flexible than most sink-filling algorithms. For example, it is relatively straight forward to fill only smaller sinks (see the fillsinks function). This is important for handling endorheic basins, for example.