[gdal-dev] TIFF overviews issue

Even Rouault even.rouault at mines-paris.org
Sat Dec 1 01:32:17 PST 2012


Le vendredi 30 novembre 2012 16:21:59, Fabian Schindler a écrit :
> Dear devs,
> 
> I'm experiencing an strange issue concerning overviews when I try to add
> overviews via Python. Essentially I want to create overviews for
> Greyscale images encoded in RGB, but on one overview level I always get
> colored pixels in a specific rectangle area of the image.
> 
> I created the boiled down test script to demonstrate what I am doing
> (create RGB grey image of certain size, save it to disk and apply
> overviews) which is available in the attachment. The script is called
> like that: `python test_overviews.py out.tif`
> 
> In my case I could see the colorfull overviews in QGIS (or MapServer
> WMS) if I zoomed out a little. A screenshot of QGIS with the image can
> be found in the attachment.
> 
> Strangely, I only have this issue on CentOS 6.3 (gdal 1.9.1, libgeotiff
> 1.4.0, libtiff 3.9.4) but not on my host Ubuntu 12.10 system (gdal
> 1.9.2, libgeotiff2 1.3.0, libtiff 4.0.2).
> 
> I tried different interpolation methods for the `BuildOverviews`
> function, with no effect. If I remove the level `2` or `4` from my level
> list, the effect does *not* show. A different image size results in a
> different colour and position of the rectangle and sometimes the
> rectangle is not visible at all.
> 
> The issue is the same when I use `gdaladdo out_no_ovr.tif 2 4 8 16`.
> 
> Any idea on this?

I can also reproduce with libtiff 3.9.2. libtiff 3.X suffers sometimes from some 
problems when generating overviews in a interleaved way, as it is done by 
BuildOverviews("NEAREST", [2,4,8,16]). Those problems have been corrected in 
libtiff 4.0

A way to workaround this is to generate each overview level one after another 
one, like this :

out_ds.BuildOverviews("NEAREST", [ 2 ])
out_ds.BuildOverviews("NEAREST", [ 4 ])
out_ds.BuildOverviews("NEAREST", [ 8 ])
out_ds.BuildOverviews("NEAREST", [ 16 ])

This will work on both libtiff 3.X and libtiff 4.0. Note that it might perform a 
little less than generating all the levels in a single instruction, since the 
source data must be read several times.

> 
> Regards,
> Fabian


More information about the gdal-dev mailing list