-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cogify): add background color support for overriding transparent…
… 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 <[email protected]> Co-authored-by: Blayne Chard <[email protected]>
- Loading branch information
1 parent
9c1d78f
commit b8bedc3
Showing
10 changed files
with
109 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters