[gdal-dev] GDAL translate 16 bit to 8 bit

Hanlie Pretorius hanlie.pretorius at gmail.com
Fri Aug 22 05:01:21 PDT 2014


Hi Cleo,

I used

-scale 0 4095 0 255

The reason for the 4095 is that the images actually use only the first
12 bits of the 16 bits (according to the documentation) and 2^12 =
4096.

If it was a true 16 bit image I would use 65535 for the 'max from' value.

Regards
Hanlie



2014-08-22 13:56 MGT+02:00, Cleo Drakos <cleo21drakos at gmail.com>:
> hi Hanlie,
> can you tell me what value you put for -scale to convert into 8 bit?
>
> cleo
>
>
> On Fri, Aug 22, 2014 at 7:02 PM, Hanlie Pretorius <
> hanlie.pretorius at gmail.com> wrote:
>
>> Hi Even,
>>
>> Yes, I quoted the exact message, but it displays in the QGIS interface.
>>
>> I tried gdal_translate with the -ot and -scale parameters on the
>> multispectral image and that worked much better, thanks.
>>
>> Regards
>> Hanlie
>>
>> 2014-08-21 20:33 MGT+02:00, Even Rouault <even.rouault at spatialys.com>:
>> > Le jeudi 21 août 2014 08:57:32, Hanlie Pretorius a écrit :
>> >> Hi,
>> >>
>> >> I'm working with a 16 bit SPOT 6 image that I want to convert from 16
>> >> bit pixel depth to 8 bit pixel depth. I say 16 bit, but if I load the
>> >> file into Envi, it reports that uses only 12 bits. However gdalinfo
>> >> reports 16 bit (see below).
>> >>
>> >> I've manage to do so on the multispectral image, but the result is
>> >> poor colour wise.
>> >>
>> >> So I split the image into its four bands that is, I now have one image
>> >> per
>> >> band.
>> >>
>> >> When I now try to convert to 8 bit, I get a message that says:
>> >> "Warning 742327101_R1C1_band1_8bit.TIF not created".
>> >
>> > Are you quoting the exact message ? I can't find any trace of it in the
>> > relevant parts of the source code. Did you check that you have write
>> > permissions in the directory where you launch the command ?
>> >
>> > Anyway for what you want to do you likely need to explore the -scale
>> option
>> > of
>> > gdal_translate. But that's unrelated to the error
>> >
>> >>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>


More information about the gdal-dev mailing list