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

A footprint problem with JPEG compressed 1 band + alpha TIFF #8834

Closed
jratike80 opened this issue Nov 27, 2023 · 2 comments
Closed

A footprint problem with JPEG compressed 1 band + alpha TIFF #8834

jratike80 opened this issue Nov 27, 2023 · 2 comments
Assignees

Comments

@jratike80
Copy link
Collaborator

I have created successfully thousands of image footprint polygons with gdal_footprint but it does not work for one image. All images have been created in the same way that is close to this.
gdalwarp -of COG -t_srs epsg:3067 -co compress=jpeg -co quality=90 -cutline temp.json -crop_to_cutline input.tif output.tif

The source image that makes trouble has 1 band and alpha while the others have 3 bands + alpha.

The problematic image is this: http://latuviitta.org/downloads/%2323491076!_2.tif
Original data are in this package (.jpg + mask TIFF which are georeferenced and combined with a vrt) http://latuviitta.org/downloads/1band.zip

The difference to successful footprint extraction seems to be that gdal_footprint finds extraordinary many polygon fragments from this image. The process is not at all ready when the status reaches "done" but gdal_footprint continues to generate very heavy CPU load. Probably that would last forever but I did not wait so long. I believe that the alpha band is also JPEG compressed because it has nearblack mice bite artefacts like in this image round the boundaries.

kuva

0...10GDALRasterPolygonEnumerator: Counted 345222 polygon fragments forming 41724 final polygons.
...20...30...40...50...60...70...80...90...100 - done.

Gdalinfo reports 2 bands from the image

Band 1 Block=512x512 Type=Byte, ColorInterp=Gray
  Overviews: 3085x3085, 1542x1542, 771x771, 385x385
  Mask Flags: PER_DATASET ALPHA
  Overviews of mask band: 3085x3085, 1542x1542, 771x771, 385x385
Band 2 Block=512x512 Type=Byte, ColorInterp=Alpha
  Overviews: 3085x3085, 1542x1542, 771x771, 385x385

From the 3 bands + alpha gdalinfo reports only 3 bands

Band 1 Block=512x512 Type=Byte, ColorInterp=Red
  Overviews: 2953x2953, 1476x1476, 738x738, 369x369
  Mask Flags: PER_DATASET
  Overviews of mask band: 2953x2953, 1476x1476, 738x738, 369x369
Band 2 Block=512x512 Type=Byte, ColorInterp=Green
  Overviews: 2953x2953, 1476x1476, 738x738, 369x369
  Mask Flags: PER_DATASET
  Overviews of mask band: 2953x2953, 1476x1476, 738x738, 369x369
Band 3 Block=512x512 Type=Byte, ColorInterp=Blue
  Overviews: 2953x2953, 1476x1476, 738x738, 369x369
  Mask Flags: PER_DATASET
  Overviews of mask band: 2953x2953, 1476x1476, 738x738, 369x369

Could there be some issue in converting alpha band into binary mask with single band data and JPEG compression?

rouault added a commit to rouault/gdal that referenced this issue Nov 27, 2023
rouault added a commit to rouault/gdal that referenced this issue Nov 27, 2023
…nly the alpha band and not the other ones (really fixes OSGeo#8792, fixes OSGeo#8834)
@rouault
Copy link
Member

rouault commented Nov 27, 2023

hum it turns out that gdal_footprint on input datasets with an alpha band was totally broken (and will still be in 3.8.1). Fixed per #8839
A workaround is to explicitly specify "-b 2" (or "-b 4" for RGBA images) to explictly force the vectorization of the alpha band only
And in #8838, I've modified the COG driver such that for a grey+alpha input, it produces when JPEG compression is asked a JPEG-compressed grey + a DEFLATE-compressed 1-bit alpha

@rouault
Copy link
Member

rouault commented Nov 27, 2023

was totally broken

I'm exaggerating a bit. Let's say quite broken, because in some situations like #8792, the fix of b28a386 happens to work when the non-alpha bands and the alpha-bands are 0 and non-0 in the same pixels...

@rouault rouault self-assigned this Nov 27, 2023
rouault added a commit that referenced this issue Nov 28, 2023
gdal_footprint: really fix datasets with alpha band, by vectorizing only the alpha band and not the other ones (really fixes #8792, fixes #8834)
rouault added a commit that referenced this issue Nov 28, 2023
rouault added a commit that referenced this issue Nov 28, 2023
…nly the alpha band and not the other ones (really fixes #8792, fixes #8834)
rouault added a commit that referenced this issue Nov 28, 2023
[Backport release/3.8] gdal_footprint: really fix datasets with alpha band, by vectorizing only the alpha band and not the other ones (really fixes #8792, fixes #8834)
ralphraul pushed a commit to 1SpatialGroupLtd/gdal that referenced this issue Mar 11, 2024
ralphraul pushed a commit to 1SpatialGroupLtd/gdal that referenced this issue Mar 11, 2024
…nly the alpha band and not the other ones (really fixes OSGeo#8792, fixes OSGeo#8834)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants