Skip to content

gdal raster tile reduced quality when compared to gdal2tiles (Lanczos in presence of nodata) #14560

@PSZ-Code

Description

@PSZ-Code

What is the bug?

gdal2tiles tested on GDAL 3.10
gdal raster tile tested on GDAL 3.12

I used to run gdal2tiles to generate a clear view of georeferenced vector pdf's. When testing gdal raster tile, i notice a decrease in quality (but also a significant increase in speed).
Quality for this case is defined as sharpness & resemblance to the original pdf, as well as the appearance of artifacts (in this case mostly white pixels between the initial image and transparant zones)

Input is a georeferenced pdf, containing a grey color which is recognized as the nodata value and georeferenced in a local coordinate system (thus the code must reproject)

I've tested 5 methods. For each case using "gdal raster tile", i find the quality to be significantly lower than gdal2tiles.
Note that gdal raster tile uses 'average' resampling, where 'gdal2tiles' used 'antialias'. This is because 'lanczos' in gdal raster tile returned awfull results

Test 1 (Base test):
gdal2tiles -r antialias -z 16-20 -a 178 input.pdf outputfolder --config GDAL_PDF_DPI 600
--> Clear and smooth image, almost no white artifacts at text edges
Image

Test 2 lanczos:
gdal raster tile --min-zoom 16 --max-zoom 20 -r lanczos --skip-blank input.pdf outputfolder --config GDAL_PDF_DPI 600
--> Awful, a lot of lost data. I had expected similar results as the base test
Image

Test 3 average:
gdal raster tile --min-zoom 16 --max-zoom 20 -r average --skip-blank input.pdf outputfolder --config GDAL_PDF_DPI 600
--> to my suprise, average resampling returned the best results of all resampling methods, yet far below the base test. Text became a lot 'fatter'
Setting a higher DPÏ does not improve results
Image

Test 4: generating additional zoom level and averaging from there
gdal raster tile --min-zoom 16 --max-zoom 21 -r average --skip-blank input.pdf outputfolder --config GDAL_PDF_DPI 600
--> Better, but still artifacts and decreased sharpness compared to base test
Image

Test 5: increase tile width to 512
gdal raster tile --min-zoom 16 --max-zoom 20 --tile-size 512 -r average --skip-blank input.pdf outputfolder --config GDAL_PDF_DPI 600
--> Closest to base test, especially for text, but significant increase in tile size and more 'corny' than original antialias
Image

It seems the new implementation has significantly decreased quality, possibly in the reprojection. Especially the Lanczos (which i understood was used for antialias) algorithm returns significant different results

Running gdal2tiles on 3.12 with antialias returns similar results as gdal raster tile. I assume somewhere in these versions the use of PIL was removed...?

Steps to reproduce the issue

Comparison of following codes on geopdf in local coordinate system

GDAL3.10
gdal2tiles -r antialias -z 16-20 -a 178 input.pdf outputfolder --config GDAL_PDF_DPI 600

GDAL 3.12
gdal raster tile --min-zoom 16 --max-zoom 20 -r lanczos --skip-blank input.pdf outputfolder --config GDAL_PDF_DPI 600
gdal raster tile --min-zoom 16 --max-zoom 20 -r average --skip-blank input.pdf outputfolder --config GDAL_PDF_DPI 600
gdal raster tile --min-zoom 16 --max-zoom 21 -r average --skip-blank input.pdf outputfolder --config GDAL_PDF_DPI 600
gdal raster tile --min-zoom 16 --max-zoom 20 --tile-size 512 -r average --skip-blank input.pdf outputfolder --config GDAL_PDF_DPI 600

Versions and provenance

Windows 11
gdal 3.10 for gdal2tiles
gdal 3.12 for gdal raster tile

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    not for AI loversSee https://gdal.org/en/stable/community/ai_tool_policy.html

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions