[GRASSLIST:259] Re: r.mapcalc with TIFFs

Richard Greenwood rich at greenwoodmap.com
Fri May 30 09:27:14 EDT 2003


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 at GreenwoodMap.com
www.GreenwoodMap.com 


More information about the grass-user mailing list