[GRASSLIST:257] r.mapcalc with TIFFs

Hi,

I have imported a tiff file (using r.in.tiff). I need to change some parts of this image, so I decided to create a mask and apply it to the original image using r.mapcalc.
After short playing with r.mapcalc, I realized it sometimes messes colors of the imported image.

For example, simple command

r.mapcalc
mapcalc> tmp = my_tiff + 10

just slightly changes colors.
But command

r.mapcalc
mapcalc> tmp = my_tiff + 30

totally messes colors of the image, making it look like a negative.
I assume it has something to do with the way how colors are encoded as categories.

Is there anybody who has more experience with this and could explain the mechanisms that GRASS uses or point me to some links on this subject?
Thanks in advance.

-- Peter

At 12:02 PM 5/30/2003 +0200, you wrote:

Hi,

I have imported a tiff file (using r.in.tiff). I need to change some parts of this image, so I decided to create a mask and apply it to the original image using r.mapcalc.
After short playing with r.mapcalc, I realized it sometimes messes colors of the imported image.

For example, simple command

r.mapcalc
mapcalc> tmp = my_tiff + 10

just slightly changes colors.
But command

r.mapcalc
mapcalc> tmp = my_tiff + 30

totally messes colors of the image, making it look like a negative.
I assume it has something to do with the way how colors are encoded as categories.

Is there anybody who has more experience with this and could explain the mechanisms that GRASS uses or point me to some links on this subject?
Thanks in advance.

-- Peter

There are several ways that a tiff file can be structured:

1. Each pixel has 3 bytes associated with it, each byte represents the value of the red, green, or blue color channel.

2. Each pixel has 1 byte, which is an index into a color table.

The second method is more compact, but provides fewer colors. I am guessing that is what you have. The color table, or pallet, does not necessarily have any order. Color 1 might be red, 2=light blue, 3=orange, 4=yellow, etc.

So when you add an arbitrary number to a pallet-ed tiff you are likely to get random results.

Rich

Richard W. Greenwood, PLS
(307) 733-0203
Rich@GreenwoodMap.com
www.GreenwoodMap.com

Guillaume Criloux wrote:

There is a color table associated with each raster map. You can play with it using r.colors GRASS command.

Hope it helps,

Guillaume

Yes, you're perfectly right. The color table for the new created map was missing. GRASS used randomly picked colors instead. Thanks for your suggestion.

By the way, is there any way how to export color table or copy it to the another map?
r.colors seems to be good only for importing tables.

-- Peter

Peter Slizik wrote:

By the way, is there any way how to export color table or copy it to the
another map?
r.colors seems to be good only for importing tables.

You can copy colour tables using:

  r.colors map=dest rast=source

There isn't an "export" facility, other than simply copying the file
(<GISDBASE>/<LOCATION_NAME>/<MAPSET>/colr/<mapname>). AFAIK, there
isn't any standard format to which a GRASS colour table could be
"exported" (it isn't a simple lookup table; it may also contain rules
which cover a range of values).

--
Glynn Clements <glynn.clements@virgin.net>