hotosm / OpenAerialMap

OpenAerialMap is an open service to provide access to a commons of openly licensed imagery and map layer services.
https://openaerialmap.org/
242 stars 31 forks source link

User mosaic stitching problem #129

Open Komzpa opened 6 years ago

Komzpa commented 6 years ago

Trying to look at mosaic of all my imagery,

1) black edges everywhere; 2) different tiles lack different parts of imagery; 3) sort order is not stable.

tms:http://tiles.openaerialmap.org/user/5a02e4c331eff4000c380594/{z}/{x}/{y}@2x

image

mojodna commented 6 years ago

Can you provide the TMS for some of the constituent scenes? I was fairly certain that I'd finally addressed the black edges, so I'd like to take a closer look at the images that are causing problems.

The sort order + geometry intersections are limitations imposed by the combination of MongoDB (which doesn't have the depth of spatial capabilities that PostGIS does; we're prototyping an updated version of that API that's PostGIS-backed) and https://github.com/w8r/martinez/issues/85, which leads to fairly regular crashes, enough so that we should avoid using it too heavily (it's the module used by @turfjs/intersect). (Imprecise footprints (resulting from vectorization of pixellated masks) may also be responsible for the empty zones.)

Short response: I should be able to fix the black edges relatively soon, but the mechanism for selecting source images will need to wait a bit longer until we have PostGIS capabilities and/or the ability to allow users to define their own groups of sources.

Komzpa commented 6 years ago

All of my imagery is uploaded here, take any: https://map.openaerialmap.org/#/27.612075805664062,53.93062413833472,14/user/5a02e4c331eff4000c380594?_k=lxkmzv

mojodna commented 6 years ago

Thanks for helping me get to the bottom of this. I've been focusing on mask behavior a lot, but missed how to approach a certain class of images: RGB images with no alpha channel or mask containing NODATA values (these are pretty common, especially from tools that don't create alpha channels; internal masks are uncommon). The NODATA values flow through and are treated as transparent, but the process of JPEG compressing the source imagery introduces artifacts where neighboring pixels may no longer match the NODATA value (which can be partially eliminated using nearblack, although there are side-effects). I'd initially written off the artifacts as a different problem, assuming that they were ignored when compressing the image, but that assumption was apparently wrong.

There's nothing simple we can do to imagery that's already been uploaded, as the JPEG compression artifacts will have already been introduced, but new imagery uploaded from now on will have compression-friendly masks included.

(DigitalGlobe images were affected by this, so this will be a nice change for large areas that those scenes cover.)

Do you mind re-uploading a couple of your source images to make sure that the problem goes away?

Komzpa commented 6 years ago

Overview is now with black background instead of transparent: https://oin-hotosm.s3.amazonaws.com/5b98f44d3d79420007c32794/0/5b98f44d3d79420007c32795.png

On tiles, there are still compression artifacts, but hurray no black edges: image

A way to fight these artifacts is to fill black under mask with average color of not-NODATA pixels/ :)

Komzpa commented 6 years ago

Per-user mosaic is now not even trying into NODATA: image

mojodna commented 6 years ago

Overview is now with black background instead of transparent

I have a pretty good idea of how to re-introduce proper transparency with the thumbnails...

On tiles, there are still compression artifacts, but hurray no black edges:

I'm inclined to accept the remaining compression artifacts as the cost of ~10x savings on storage.

A way to fight these artifacts is to fill black under mask with average color of not-NODATA pixels/ :)

I'd love a hand if you're able to prototype an approach to this. A simpler (for consumers), more fundamental fix is for whatever toolchain you're using to produce actual [alpha] masks instead of just tagging NODATA values. That'll prevent black pixels in the middle of the image from being treated as transparent.

Per-user mosaic is now not even trying into NODATA:

scratches head This doesn't make any sense yet (esp. with the black edges gone elsewhere), but I'll be taking a closer look.

mojodna commented 5 years ago

The black edges should be fixed now (for newer data). Transparent pixels in the middle of images should also no longer occur after https://github.com/mojodna/marblecutter/commit/7520375808c3fa8fcd58e27528fd501d886e837d.

Thumbnail transparency has also been reintroduced.

Komzpa commented 5 years ago

Thank you!

Black edges now have a different style: image (compare this to first image in thread - they were overlaid there although with black artifact, now only one of them takes the whole tile and the rest of the tile is black)