[Gdal-dev] Color scaling to 8 bit?

Markus Neteler neteler at itc.it
Fri Feb 10 09:41:41 EST 2006


Hi,

I tried to scale a 24bit IMG file to 8 bit, but failed.
Doing so, I observed another thing, the report of indices
which is very slow. Maybe it should not be printed at all?

time gdalinfo hanoi_lsat7_brovey_UTM48N_small.img
Driver: HFA/Erdas Imagine Images (.img)
Size is 1404, 2807
Coordinate System is:
PROJCS["UTM Zone 48, Northern Hemisphere",
...
Center      (  517560.000, 2361688.125) (105d10'9.72"E, 21d21'25.85"N)
Band 1 Block=64x64 Type=Int16, ColorInterp=Palette
  Description = Layer_1
  Metadata:
    COLOR_TABLE_RULES_COUNT=1024
    COLOR_TABLE_RULE_RGB_0=0.000000e+00 3.100000e+01 0 0 0 255 0 0
    COLOR_TABLE_RULE_RGB_1=3.200000e+01 6.300000e+01 0 8 0 255 8 0
    COLOR_TABLE_RULE_RGB_2=6.400000e+01 9.500000e+01 0 16 0 255 16 0
...
  <Row index="32762">
    <F>0.8352941176470589</F>
    <F>1</F>
    <F>1</F>
    <F>1</F>
  </Row>
  <Row index="32763">
    <F>0.8705882352941177</F>
    <F>1</F>
    <F>1</F>
    <F>1</F>
  </Row>
</GDALRasterAttributeTable>

real    1m0.206s
user    0m51.657s
sys     0m0.293s

Back to my problem, doing:

  gdal_translate -of HFA -scale -ot Byte hanoi_lsat7_brovey_UTM48N_small.img test_8bit.img
  Input file size is 1404, 2807
  0...10...20...30...40...50...60...70...80...90...100 - done.


still results in a non 8bit file:

  gdalinfo test_8bit.img
  ...
  32757: 172,255,255,255
  32758: 180,255,255,255
  32759: 189,255,255,255
  32760: 197,255,255,255
  32761: 205,255,255,255
  32762: 213,255,255,255
  32763: 222,255,255,255
  ...

Or is the file 8 bit but the color table remains 24bit?

Suggestions welcome,
thanks

 Markus




More information about the Gdal-dev mailing list