[gdal-dev] Problem with black edges to DOQQs using JPEG in Tiff compression

Even Rouault even.rouault at spatialys.com
Sun Feb 12 06:54:29 PST 2017


On samedi 11 février 2017 18:18:35 CET Stephen Woodbridge wrote:
> Hi All,
> 
> I need your wisdom. I'm downloading NAIP DOQQs in GTiff format and I
> have a processing chain something like the following:
> 
> gdalwarp -t_srs EPSG:4326 -dstalpha -r "bilinear -multi -co TILED=YES
> -dstnodata '0 0 0' srctiff tmpfile
> 
> nearblack -nb 15 -q tmpfile
> 
> gdal_translate -co TILED=YES -co JPEG_QUALITY=90 -co COMPRESS=JPEG -co
> PHOTOMETRIC=YCBCR -b 1 -b 2 -b 3 -mask auto --config
> GDAL_TIFF_INTERNAL_MASK YES  tmpfile, target
> 
> nearblack -nb 5 -q target
> 
> gdaladdo -clean -r bilinear  target 2 4 8 16 32 64 128 512
> 
> And create a tileindex for mapserver of all the tiffs
> 
> If I skip the gdal_translate (ie: JPEG compression) and the 2nd
> nearblack, the doqq tiles are perfect with no nearblack edges between
> the doqq tiles. But when a JPEG compress them, I get edges between the
> doqqs like this:
> 
> http://imaptools.com:8080/dl/doqq-issue.jpg
> 
> I've never used the JPEG in tiff compression and I'm very impressed by
> the amount of size reduction there and how good the image remains, but I
> have not been able to figure out the magic trick to clearing the edge
> artifacts.

Steve,

I managed to replicate something similar to the above with an image I've at hand.
The cause of the issue is the nearblack invokation after the gdal_translate. The effect of this 
nearblack is to "eat" some pixels at the border of the validity / invalidity transition, but that 
doesn't update the existing mask.
If you add -setmask to this nearblack, that should fix it.
Even better, I think you can just remove this second nearblack.

And you probably must add -setalpha for the first nearblack invokation as well.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170212/0376d06c/attachment.html>


More information about the gdal-dev mailing list