-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Lossy mask band causes artifacts #11535
Comments
maybe try -co JXL_ALPHA_DISTANCE=0 so the alpha channel is saved as lossless |
@rouault this works for me. Thanks! Feel free to close this issue if it is actually not a bug. Note that I was also trying to use alpha channel not as a mask, but as a classic alpha channel, but I also did not succeed. Offtopic, feel free to ignore: it is possible to achieve the same with classic JPEG compression and with some external mask - all with overview support per a part (using |
not sure to understand the difference between both
gdal_translate rgba.tif rgb_mask.tif -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG [-co PHOTOMETRIC=YCBCR] will generate a file with RGB JPEG compressed and an internal TIFF mask using lossless 1-bit Deflate lossless compression. You can use gdaladdo to add overviews to both RGB and mask channels |
I've tried to use JPEG codec with internal tiff mask. First I replaced mask in my vrt files with alpha channels: <VRTRasterBand dataType="Byte" band="4">
<ColorInterp>Alpha</ColorInterp>
<SimpleSource>
<SourceFilename relativeToVRT="1">mask-left.tif</SourceFilename>
<SourceBand>1</SourceBand>
</SimpleSource>
</VRTRasterBand> Then: gdalwarp -s_srs 'EPSG:8353' -t_srs 'EPSG:3857' -tr 0.29858214173896972948 0.29858214173896972948 -tap -r lanczos -of GTiff -co COMPRESS=ZSTD -b 1 -b 2 -b 3 -dstalpha right.vrt right-tmp.tif
gdalwarp -s_srs 'EPSG:8353' -t_srs 'EPSG:3857' -tr 0.29858214173896972948 0.29858214173896972948 -tap -r lanczos -of GTiff -co COMPRESS=ZSTD -b 1 -b 2 -b 3 -dstalpha left.vrt left-tmp.tif
gdal_translate left-tmp.tif left.tif -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR
gdal_translate right-tmp.tif right.tif -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR
gdaladdo -r lanczos --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW=YCBCR left.tif
gdaladdo -r lanczos --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW=YCBCR right.tif
gdalbuildvrt final.vrt left.tif right.tif Unfortunately overviews contain similar artifacts. If I omit |
What is the bug?
VRT file produces transparent pixels on mask edge.
Steps to reproduce the issue
Please download input data (54MB) from https://drive.google.com/file/d/1BgUZ2snzYeK3_7EpN4YCIZHe6niaywyJ/view?usp=sharing and unpack it. It contains one orthophoto image (
SNINA_3-0.tif
) and two overlapping masks (mask-left.tif
andmask-right.tif
).create 2 vrt files:
edit
left.vrt
andright.vrt
and add:(use
mask-left.tif
forleft.vrt
andmask-right.tif
forright.vrt
)warp left and right:
produce final VRT:
Issue is not reproducible if
JXL_LOSSLESS=YES
(but I want it to be lossy because of the size).Versions and provenance
Linux bono 6.11.7-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.11.7-1 (2024-11-09) x86_64 GNU/Linux
GDAL 3.11.0dev-051a853584, released 2024/10/31
Additional context
I have multiple huge jpeg-compressed geotiff orthophoto files which I want to reproject to pseudomercator and create a single VRT file from them. Each file covers a part of the country and they have some small overlap. For every JPEG I also have a cutline (vector mask) which I rasterize and use, because JPEG files have no alpha channel or mask.
I expect the resulting VRT to render without any gaps between parts.
I am using JXL because JPEG can't have an alpha channel.
The text was updated successfully, but these errors were encountered: