Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create better weights in dem_mosaic #381

Open
oleg-alexandrov opened this issue Aug 12, 2022 · 0 comments
Open

Create better weights in dem_mosaic #381

oleg-alexandrov opened this issue Aug 12, 2022 · 0 comments

Comments

@oleg-alexandrov
Copy link
Member

The dem_mosaic tool performs seamless blending of DEMs. To do that, each DEM is assigned a weight image, with one weight per DEM pixel. Weights decay to 0 at each DEM boundary. So, dem_mosaic does a weighted average of the DEMs, and since each DEM's weight falls off to 0 at its boundary, its contribution gently gets reduced to nothing by the time one gets there, so the combined DEM becomes seamless.

The current weights are based on the Manhattan distance, so, if the DEM boundary is a rectangle, the weight looks like the roof of a house. (The weight is forced to plateau at some distance inward, as otherwise one can't do per-tile-processing uniquely, so the top pointy part of the roof gets flattened, getting eventually a truncated pyramid as the weight.)

The problem is that when the DEM has complicated and noisy boundary, the Manhattan distance results in something not pretty. One hack used in this tool is to blur the resulting weight (option --weights-blur-sigma). Unfortunately, it is not possible to easily blur a function which is supposed to drop off to 0 so the new blurred function does not go beyond the footprint of the original function, so where the original weight is 0 the new blurred weight stays 0, but where both are non-zero, the blurred weight is nicer than the original one, and smoothly decays to 0.

The resulting logic kind of works, more or less, but for a big blur, like 200 pixels, and very complicated geometry the resulting weight is acting out, resulting in a seam in the final blended DEM.

All current logic for creation of weights need to be thrown out. A new function needs to be added, which, given a 2D shape, finds a smooth weight which decays to 0 when moving from inwards to the shape boundary. When moving in reverse, from the boundary inwards, it should grow, but then plateau, also smoothly. Moreover, it should take as input a parameter to control the smoothness of the transition, both at the boundary of shape, and where it plateaus.

A good initial solution for this is the truncated Euclidean distance to boundary. Then it needs to be made smoother, somehow, while still staying within the shape footprint. This will take some work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant