[GRASSLIST:1793] Re: r.patch color table question
Richard Greenwood
Rich at GreenwoodMap.com
Mon Nov 17 23:24:14 EST 2003
Glynn,
I am afraid that I will run out of ways of says "thanks" before I run out
of questions<g>. I went the r.reclass route and it works great.
Is there a source of documentation for the format of GRASS files?
Specifically, I am curious about the format of the colr files.
Thanks,
Rich
At 10:37 PM 11/15/2003, Glynn Clements wrote:
>Richard Greenwood wrote:
>
> > I am using grayscale imagery to fill in blank areas in a color imagery
> set.
> > I have used r.composite to create composite color images from the rgb
> > channels in the color imagery. To create a corresponding color table for
> > the grayscale imagery, I am using r.composite and specifying the grayscale
> > image for all three channels. This works, but it seems rather inelegant.
> >
> > Can anyone suggest a more efficient approach?
>
>You could use r.reclass or r.mapcalc, but you would need to compute
>the categories transformation manually. There isn't another tool which
>will do the same job as running r.composite with the same map for each
>of the three channels.
>
>Bear in mind that you aren't just creating a colour table. You are
>changing the category values to match the "encoding" which the colour
>maps use. r.patch operates upon categories, not colours.
>
>For a given intensity level k in the range 0 to levels-1, where
>"levels" is the argument to r.composite's levels=/lev_[rgb]= options
>(the default is 32), the corresponding category is:
>
> k + k * levels + k * levels * levels
>= k * (1 + levels + levels * levels)
>= k * (1 + (1 + levels) * levels)
>
>E.g. for levels=32:
>
> category = k * 1057 // 1024 + 32 + 1 = 1057
>
>For an intensity value in the range 0-255, the corresponding value of
>k is given by either:
>
> (x + 128 / (levels - 1)) * (levels - 1) / 256
>or:
> x * levels / 256
>
>depending upon whether r.composite's -c switch was used (the former is
>with -c, the latter without).
>
>So, for the default r.composite settings (levels=32, without -c), you
>should be able to use:
>
> r.mapcalc 'outmap = (x / 8) * 1057'
>
>[Note: all of this relies upon integer arithmetic; don't try to
>calculate or simplify any of the above using real-number arithmetic.]
>
>--
>Glynn Clements <glynn.clements at virgin.net>
Richard W. Greenwood, PLS
Greenwood Mapping, Inc.
Rich <at> GreenwoodMap <dot> com
(307) 733-0203
http://www.GreenwoodMap.com
More information about the grass-user
mailing list