[GRASSLIST:2239] Re: Import into rast from tiff

Glynn Clements glynn.clements at virgin.net
Thu Jan 15 03:25:14 EST 2004


francesco.pirotti wrote:

> > Can I import tiff image into 1 rast instead of 3 r,g,b rasts?
> > 
> > Why all of 3 imported images looks like gray and broken (with vertical lines)?
> > 
> > I used the command r.in.tiff input=data.tiff output=mydata because 
> > r.in.gdal is not working on Cygwin due to stackdump.
> 
> You have to open the tiff with an image editor (GIMP works great) and save 
> the tiff as (in the gimp program, don't know about others) 
> "Image"->"Mode"->"indexed" instead of as "RGB"... in other words instead of 
> having the colors coded in three bands Red Green Blue with each having 8 
> bits x 3 = 25 bits, you get on single band with 8 bits of info coded into a 
> color table.

That will work, but it's about the worst possible approach. If you
really need a composite layer, import the original 24-bpp TIFF file as
separate R/G/B bands then use r.composite.

By default, r.composite will use 32768 colours (15-bpp; 5 bits per
component, which gives 32 levels), as opposed to 256 colours for an
8-bpp paletted TIFF (256 colours equates to approximately 6 intensity
levels: 6*6*6 = 216 colours).

For most purposes, you don't need a composite layer, but can keep the
data as three separate bands. Such maps can be viewed with d.rgb,
exported using r.out.ppm3 and printed with ps.map's "rgb" command; for
the imagery (i.*) programs, you can create an imagery group comprising
the bands.

The main reason for not combining the bands into a composite layer is
quality. With separate bands, it's practical to use 8 bits (256
levels) or more per component. OTOH, a 24-bpp composite layer would
have over 16 million categories, and require 65536 rules for the
colour table.

While this works, processing such maps becomes extremely slow and can
consume large amounts of memory; in practice, you end up having to
reduce the number of intensity levels simply for performance reasons.

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




More information about the grass-user mailing list