[gdal-dev] Set color table in NITF
Even Rouault
even.rouault at mines-paris.org
Mon Aug 29 18:29:30 EDT 2011
Le mardi 30 août 2011 00:14:12, Cole, Derek a écrit :
> Hello,
>
> I am trying to create a NITF that uses a color lookup table.
>
> I found the option to add an RGB/LUT to the image, which didnt complain,
> however, when I had my LUT data to the image, it all seems to be kind of
> black and white.
>
> I know when I was displaying the images in my viewer (which I wrote in Qt),
> I had a function to create a 256 element color table, that changed some of
> the values. How would I modify the color table in the NITF?
Use SetColorTable() on the raster band object.
Python example :
from osgeo import gdal
ds = gdal.GetDriverByName('NITF').Create('test.ntf', 1, 1, options =
['IREP=RGB/LUT', 'LUT_SIZE=3'])
ct = gdal.ColorTable()
ct.SetColorEntry( 0, (0,0,0) )
ct.SetColorEntry( 1, (10,10,10) )
ct.SetColorEntry( 2, (20, 20, 20))
ds.GetRasterBand(1).SetColorTable(ct)
ds = None
$ gdalinfo test.ntf
Driver: NITF/National Imagery Transmission Format
Files: test.ntf
Size is 1, 1
[...]
Band 1 Block=1x1 Type=Byte, ColorInterp=Palette
NoData Value=3
Color Table (RGB with 4 entries)
0: 0,0,0,255
1: 10,10,10,255
2: 20,20,20,255
3: 0,0,0,0
>
> Thanks
More information about the gdal-dev
mailing list