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(config): Add resizeKernel into the config tileset then disable fastShrinkOnLoad. BM-1146 #3377

Merged
merged 3 commits into from
Dec 5, 2024

Conversation

Wentao-Kuang
Copy link
Contributor

Motivation

As raster Topo map got edge effects on low zoom levels usually below zoom 6, like following.
image

We have tests that with output resize kernel of mitchell and disable the fastShrinkOnLoad for lower scales levels will fix this problem.
image

Modifications

  • Add the resiseKernel setting in the config bundle, so that we can bundle it into server.

  • disable fastShrinkOnLoad for the resize.scaleless than 0.125.

  • Not fix yet: The virtual tileset for topo-raster-50k and topo-raster-250k won't fix as we can't propagate the resize kernel from combined tileset -> imagery config -> virtual tileset. Unless we add optional resizeKernal property for imagery config.

Verification

Local test.
image

@Wentao-Kuang Wentao-Kuang requested a review from a team as a code owner December 5, 2024 02:24
@tawera-manaena
Copy link
Contributor

@blacha - We thought about how to carry through a preset value from the tileset.json into this part of the code.

pipeline.webp({ preset: <e.g "text">, lossless: true, quality: 100, alphaQuality: 100 })

But haven't figured out a clean way to do it.

@tawera-manaena tawera-manaena changed the title feat(config): Add resizeKernel into the config tileset then disable fastShrinkOnLoad. feat(config): Add resizeKernel into the config tileset then disable fastShrinkOnLoad. BM-1146 Dec 5, 2024
@blacha blacha added this pull request to the merge queue Dec 5, 2024
Merged via the queue into master with commit bd3357e Dec 5, 2024
11 of 12 checks passed
@blacha blacha deleted the feat/support-resizekernel branch December 5, 2024 20:57
Wentao-Kuang added a commit that referenced this pull request Dec 17, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jan 6, 2025
… pixels BM-1146 (#3379)

### Motivation

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

| [Topo 50][basemaps-topo50] | [Topo250][basemaps-topo250] |
| - | - |
| ![][topo50] | ![][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][kernel-pr] 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 |
| - | - | - |
| ![][verification-tile] | ![][verification-before] |
![][verification-after] |
| Example shown: [9-4-325][basemaps-9-4-325] - Web Mercator (EPSG:3857)
| No transparent pixels are overwritten. | All transparent pixels are
overwritten with the provided background colour. |

<!-- links -->

[nztopo-raster-maps]:
https://dev.basemaps.linz.govt.nz/@-41.8899962,174.0492437,z5?style=topo-raster&i=topographic&config=TmVmbYRQjL9T2JWgyaSie193b4D1qZnBD8hjaSqPFYSsEvEYYhaGYKrcp1HoDE7nHXaP89x5RKia68nGwyRKku4ExE7QvB424FYmjokRMr2qXgj6oehUjHaB27QiY6d

[basemaps-topo50]:
https://basemaps.linz.govt.nz/@-40.4900187,173.5118508,z5?style=01JE7PGRG2AHNAN80CVCBK5JS1&i=01JE7PGRG2AHNAN80CVCBK5JS1&config=5LN3whfVkKeLNsSo5jGHMuw3a3bk5rR1ekotn4iApaGccpE1D8L2hLZdbsYkzbUrGCFpy2jXFkbngKguAkob2ZKZHKkKGTw6xx1f14Zxe2VaPmUV3PNRTJero5NDH1WgtA16AnKtaRVXQ7KaQevPzeTfwNmxdWZECGqDkps59ifDDuTAQJXXJK6rfMk3tF15s&debug=true
[basemaps-topo250]:
https://basemaps.linz.govt.nz/@-41.8971463,173.1394504,z4?style=01JE7NBEJHND65K0WWWB9PWXQZ&i=01JE7NBEJHND65K0WWWB9PWXQZ&config=L8TuzSUutDHnXXerPsYTDJdYLrUMAR6yseMyXuNiLyqvD5SPvX6E3CkoPoqhkogKnBCaQpbQ7LUHiSXGsM9ctAVTvjWU8BnSaV3SrRRGDULg5PSGz8thtzn5BGc28bijrqq677m9gSHJqVdwXPsjQ78pKez8TMncCYth2s4npjkmokz7q2r1GgMumQ3WTjT72y&debug=true

[topo50]:
https://github.com/user-attachments/assets/aaa16253-efed-45b9-a6bd-fb6054b33927
[topo250]:
https://github.com/user-attachments/assets/64655fe0-b5ad-4036-aab6-2810fef3c578

[kernel-pr]: #3377

[basemaps-9-4-325]:
https://basemaps.linz.govt.nz/@-43.8859446,-176.8266051,z8?debug=true&debug.tile=true

[verification-tile]:
https://github.com/user-attachments/assets/2159eb1d-3009-4aec-a747-d886cd51df32
[verification-before]:
https://github.com/user-attachments/assets/3889e3a2-c784-4436-94d4-f264dc546866
[verification-after]:
https://github.com/user-attachments/assets/89018eb0-4aad-437d-a4fd-f4f62c10eb54

---------

Co-authored-by: Wentao Kuang <wkuang@linz.govt.nz>
Co-authored-by: Blayne Chard <bchard@linz.govt.nz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants