Geoscience Reference
In-Depth Information
source_file
The input RGB file.
dest_file
The output pseudo-colored file that will be created.
The script automatically generates a color table from the RGB color values in the
three input bands from the input image. Minimum two and maximum 256 different
colors are supported. The RGB values are computed using a median cut algorithm 1
on a downsampled version of the input bands.
As an illustration, we will convert the lena image, which is a well known image
used in the image processing community (see Appendix A.3). The original image,
named 4.2.04.tiff , is in tif format and contains three bands. For convenience,
we will rename it to lena_rgb.tif . We can convert the three band image to a
single band image with a color LUT of 256 values:
rgb2pct.py lena_rgb.tif lena_ct.tif
Compare the outputs from gdalinfo for both files and check a LUT has been
generated for the latter (using gdalinfo ). Moreover, the three band image has been
converted to a single band only. Opening the image with an image viewer reveals the
loss in color depth. This becomes more pronounced if you lower the number colors
using the option -n .
rgb2pct.py lena_rgb.tif -n 16 lena_ct.tif
6.2 pct2rgb.py
This Python script converts an indexed color image to a three band (Byte) image.
The three bands of the output image correspond to the green, red and blue channels
of the RGB color model. Optionally, a fourth band image can be generated for the
transparency value ( -rgba : rgb and alpha channel). However, the new -expand
rgb|rgba option of gdal_translate makes that utility obsolete.
Usage: pct2rgb.py [-of format] [-b <band>] [-rgba]
source_file dest_file
1 A lossy compression which reduces the dynamic range of the input (Heckbert 1982).
 
 
Search WWH ::




Custom Search