Geoscience Reference
In-Depth Information
Chapter 6
Indexed Color Images
This chapter covers the concept of pseudocolor images. We explain what it is and how
you can generate such images via virtual files. In Sect. 14.3.6 of Chap. 14, we show
how to create a program that adds a color table to an existing raster dataset. Finally
we also cover two GDAL utilities that are related to color tables ( rgb2pct.py and
pct2rgb.py ).
Color images can be represented asmulti-band raster data as explained in Sect. 3.2 .
However, some image file formats are able to store a selection of limited colors in a
single band image file, also referred to as an indexed color image file. Examples of
such file formats are: TIFF (GeoTIFF), graphics interchange format (GIF), portable
network graphics (PNG) and joint photographic expert group (JPEG). The color
palette (or color table) is stored as a lookup table (LUT) that links a pixel value
(index) to a pseudocolor. For instance, a raster image with temperature values can be
represented in color where blue indicates low values and red indicates high values.
The color LUT is described by a four entry structure. The first three entries are
used for the color: a value for green (G), blue (B) and red (R). The fourth entry
is used for transparency (alpha), as opposed to opaqueness. An alpha value of 0
indicates full transparency and an alpha value of 255 indicates full opaqueness (no
transparency). The implementation in GDAL supports indexed color images of the
data type Byte.
Adding a color table to a raster image is a frequently asked question in fora dealing
with geospatial data. There are several ways to do this. If it is just for visualization,
you can use a GIS software like QGIS. If you want to encode the table in your raster
file (if supported), there are alternatives. In Sect. 14.3.6 , you learn how to build a
small program to add a predefined color table to a dataset, based on the GDAL API.
In pktools (Chap. 12 ) , a similar tools is already implemented. It can also define the
color table for a variable number of values smaller than 256. Yet another way to add
a color table to a raster file is to create first a virtual file (see Chap. 11 ) :
gdal_translate -of VRT image.tif tmp.vrt
 
 
Search WWH ::




Custom Search