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

feat(cogify): add background color support for overriding transparent pixels BM-1146 #3379

Merged
merged 17 commits into from
Jan 6, 2025

Conversation

tawera-manaena
Copy link
Contributor

@tawera-manaena tawera-manaena commented Dec 12, 2024

Motivation

As a Basemaps user, when I view the NZTopo Raster Maps from afar (low zoom level), I can see black edge artifacts around the perimeter of the imagery.

Topo 50 Topo250
Appears between zoom levels 0-6 inclusive. Hard to notice when zoom level is >= 6.5 Appears between zoom levels 0-4 inclusive. Hard to notice when zoom level is >= 4.5

You may need to open each image/link in a new tab to see the black lines more clearly.

Problem

We suspect the issue resides in the way the basemaps/tiler composes a small tile. The resizing down of many pixels into one, causes artifacts to appear where opaque pixels meet transparent pixels.

Solution

There is already a 'workaround' fix that treats the symptoms of the black edge artifacts. This work, however, seeks to treat the source of the issue by providing a mechanism to replace all transparent pixels with opaque pixels. The effect being to erase such areas where opaque pixels meet transparent pixels.

Modifications

basemaps/cogify

  • We have added a background parameter to the cover command.

    • When the user provides the parameter, the create function will perform two additional gdal steps after gdalwarp and before gdal_translate, to ensure that any and all transparent pixels that would otherwise appear in the resulting tile, are replaced with the provided background colour.

      • gdal_create - To create a background image where all pixels are set to the provided background colour.
      • gdalbuildvrt - To layer the background image behind the source GeoTIFF files after reprojection.

Verification

For a given tile What cogify usually makes What cogify can now make
Example shown: 9-4-325 - Web Mercator (EPSG:3857) No transparent pixels are overwritten. All transparent pixels are overwritten with the provided background colour.

@tawera-manaena tawera-manaena changed the title feat(cogify): force a background color for transparent pixels feat(cogify): force a background color for transparent pixels BM-1146 Dec 12, 2024
@tawera-manaena tawera-manaena changed the title feat(cogify): force a background color for transparent pixels BM-1146 feat(cogify): add background color support for overriding transparent pixels BM-1146 Dec 12, 2024
@tawera-manaena tawera-manaena marked this pull request as ready for review December 12, 2024 03:26
@tawera-manaena tawera-manaena requested a review from a team as a code owner December 12, 2024 03:26
@Wentao-Kuang Wentao-Kuang added the container build pull request container for testing label Dec 12, 2024
github-merge-queue bot pushed a commit that referenced this pull request Dec 17, 2024
… fastShrinkOnLoad. (#3383)

### Motivation

We are adding the background in the imagery importing process(#3379), so
we don't need this for fixing the edge effects.

### Modifications

This reverts commit bd3357e.

### Verification

<!-- TODO: Say how you tested your changes. -->
@Wentao-Kuang Wentao-Kuang added this pull request to the merge queue Jan 6, 2025
Merged via the queue into master with commit b8bedc3 Jan 6, 2025
12 checks passed
@Wentao-Kuang Wentao-Kuang deleted the feat/cogify-add-background-color-support branch January 6, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
container build pull request container for testing
Development

Successfully merging this pull request may close these issues.

3 participants