[GRASSLIST:1442] Re: r.patch geotiff-mosaic wrong color problem

Hamish hamish_nospam at yahoo.com
Wed Oct 8 04:34:39 EDT 2003


> > An 8bit tiff uses a color palette. The value of any given pixel is
> > used to lookup the red,green,blue value in a table. The table is the
> > palette, and is a part of the tif file. It is likely that each of
> > tiff's has a different palette. The color table for each image is in
> > the colr directory of your location. They are just ASCII files.
> >
> > You can preprocess each image with Gimp or Photoshop so that they
> > all have the same color palette before you import them into GRASS,
> > or you can convert them to 24bit tiffs before importing. In a 24bit
> > tiff each pixel has 3 bytes, one each for red, green, and blue, so
> > no color palette is used.
...
>
> We had the same problem, but we solved it within GRASS:
> 1.step: Import the 24-bit image with r.in.gdal (produces three GRASS
> raster maps: red, green, blue)
> 2.step: change the colormap of the channels (red, green, blue) with
> r.colors  map=... color=grey

Beware if the maps do not cover the full range of color data, i.e.
0-255. Use r.info to check.

Better:

r.colors INPUT_MAP color=rules << EOF
  0 black
  255 white
EOF


for all three chanels.


> 3.step: put these modified  channels together with r.composite
> r_map=... g_map=... b_map=.... output=....
> 
> -> The output of r.composite has an unified colormap and can be
> patched(or be put together with r.mapcalc) without any color-problems.



Hamish




More information about the grass-user mailing list