On Dec 30, 2010, at 6:18 AM, Vincent Schut wrote: > On 12/30/2010 12:07 PM, Even Rouault wrote: >> Le jeudi 30 décembre 2010 11:52:34, Vincent Schut a écrit : >>> Hi all, >>> >>> Kind of a corner case, but i was hoping that gdal_translate's -expand >>> option (to expand colorindexed 1-band files into 3-band rgb files) would >>> also copy and expand the overviews when run with the (geotiff specific, >>> I know) create option "-co COPY_SRC_OVERVIEWS=YES". It appears to not do >>> so, and just discards the overviews. Would this be a bug, or maybe a >>> feature to add? >> >> When you use -expand, an intermediate VRT file is created to do the color >> expension, but it doesn't retain the source overviews, so when the GeoTIFF >> driver copies the VRT into the final TIFF, there are no more source overviews >> from its point of view. "-co COPY_SRC_OVERVIEWS=YES" will only work if no >> intermediate VRT is used, so basically when you don't use any gdal_translate >> options, except creation options of the target driver. >> >>> >>> Use case: for a classified, indexed image, I have built overviews using >>> the 'mode' operator, which is obviously the most usefull for this kind >>> of image, and only applicable on 1-band indexed data. I want to have a >>> rgb version of this, but with those overviews, so the overviews should >>> be an rgb version of the 'mode' overviews of the original. It is >>> impossible to create the same overviews once the image has been expanded >>> into rgb; mode will result in wrong, and sometimes even weird results (I >>> presume mode works band-wise), >> >> yes, mode works band per band >> >>> and average and partners will result in >>> colors that are not defined in the original colorindex (which I want to >>> avoid, we are talking maps and legends here). >>> >>> I think I can work around this by creating a separate file for each >>> overview level (bla.ovr, bla.ovr.ovr, and so on), expanding those, and >>> than using copy_src_overviews to create one file with internal overviews >>> again, but this feels kind of awkward, and the above seemed so elegant... >> >> yes that's a plausible way of proceeding. Making what you wish work would >> require : >> 1) add support for using/exposing source overviews in the VRT >> 2) add support for doing color expansion on overviews of the VRT >> >> which I feel would be rather complicated to implement > > Which I understand. I didn't know it worked through vrt, though now that > sounds very plausible. > I'll script my workaround, no problem.
The Ossim utility ossim-icp has a --res-level option that will extract an overview level from a file something similar might be a useful addition to gdal functionality pseudo code for level in overviews ossim-icp -r level tiff_tiled $SRC tmp$SRC_%level gdal_translate -expand tmp$SRC_%level $SRC_%level ?? how best to recombine overviews ?? I don't know how best to do step 3 Cheers Norman
_______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
