Geoscience Reference
In-Depth Information
Then manually insert the color table by editing tmp.vrt . For instance, add the
following lines just before the line </VRTRasterBand> :
<ColorInterp>Palette</ColorInterp>
<ColorTable>
<Entry c1="0"c2="0"c3="0"c4="255"/>
<Entry c1="255"c2="0"c3="0"c4="255"/>
<Entry c1="0"c2="255"c3="0"c4="255"/>
<Entry c1="0"c2="0"c3="255"c4="255"/>
</ColorTable>
The columns for c1, c2, c3 and c4 correspond to the values for R, G, B and alpha.
No column is foreseen for the pixel value. The first line corresponds to a pixel value
of 0, the second to a value of 1, etc. In this example, black pixels will be assigned
to a value 0, red to 1, green to 2 and blue to 3. You can add more entries as needed,
depending on the maximum value in your image (not above 255). Finally, you can
fix the table in a new GeoTIFF file image_ct.tif using gdaltransform :
gdal_translate tmp.vrt image_ct.tif
6.1 rgb2pct.py
The Python script rgb2pct.py converts a three band (Byte) image to a single band
(Byte) image including a color table. The transparency value in the color table is set
to 255 (fully opaque).
Usage: rgb2pct.py [-n colors | -pct palette_file] [-of format]
source_file dest_file
-mm
Display the minimum and maximum values for each band in the dataset
-n colors
Select the number of colors in the generated color table. Defaults to 256. Must
be between 2 and 256.
-pct palette_file
Extract the color table from palette_file instead of computing it. Can be used to
have a consistent color table for multiple files. The palette_file must be a raster
file in a GDAL supported format with a palette.
-of format
Format to be generated (defaults to GeoTIFF). Same semantics as the -of flag
for gdal_translate . Only output formats supporting pseudocolor tables
should be used.
 
 
Search WWH ::




Custom Search