more: xv to GRASS

BAKERWL at uwyo.edu BAKERWL at uwyo.edu
Wed May 24 08:00:00 EDT 1995


I've been trying to get a scanned aerial photo which I have in the
xv program into GRASS preserving the excellent color rendition I have
inside xv. Since xv can be used interactively to edit and improve
images, I suspect that others would find it useful to be able to transfer
the improved images into GRASS without losing the xv rendition.  However,
I have not been able to find a way to do this well.  Here's what doesn't
work:

        1. save as PBM (raw), then strip off the first few lines, put
the resulting binary file in the cell subdirectory, then run r.support
on it.  This works to get the file in there correctly, but DOES NOT
preserve the xv colortable, so does not (apparently) work as a way to
bring in an aerial photo, where the colors have particular meaning.

        2. save as PBM (raw), then use r.in.ppm to bring in the 
8-bit ppm file.  This also DOES NOT preserve the colortable.

        3. save as TIFF (Full Color) or GIF, then use r.in.tiff or
r.in.gif to bring in the 8-bit TIFF or GIF files.  This also DOES NOT
preserve the colortable.

In fact all three xv output formats (PBM, TIFF, GIF) result in the same
degraded color rendition when input into GRASS.  The colors in xv
are great in 8-bit format, even undithered, but when the image on screen
in xv is output, then input into GRASS, the colors are fewer, different,
and not at all what xv shows.

I have been careful to halt xv completely and start GRASS so that there
is no competition for colors between these applications.
My machine is a Sparcstation 1 using SunOS 4.1.3 with an 8-bit graphics
accelerator.

I did, however, find one way that works:  Use the Sun Open Windows
snapshot tool to capture the xv screen into a sunraster file, then
use r.in.sunrast to bring in the resulting file.  The color rendition
in the resulting GRASS map is very close to that on the xv screen and
vastly superior to that from r.in.ppm, r.in.tiff, or r.in.gif.  Also,
curiously, if you output the xv screen to a sunraster file (through
the xv save command, rather than a frame grab), then input the file
using r.in.sunrast you get the same degraded colortable as with
r.in.tiff etc.  The only way I have found to preserve the improved
xv image is through the Sun snapshot tool.  This method, however, has
the severe limit of only capturing screen resolution (about 100 dpi), 
when the original scanned aerial photo might have 600 or 1200 dpi.  It
is not a good solution.

The color table that gets brought in when using the Sun snapshot tool
seems to have comparatively few colors (e.g., 61 in one cas, 64 in
another), even though the color rendition is quite good.  So, to explore
the possibility that xv may be outputing too many colors for GRASS to
handle, I started xv with the -nc option, which allows you to limit
the number of colors xv uses.  I tried 8, 16, 32, 64, 128, and 216 colors,
then output the xv image and input it via TIFF and GIF (no difference
as it turns out).  In general, there was a slight improvement in the
resulting color rendition in GRASS as the number of xv colors decreased,
down to about 32, but worsening below 32.  The image in its best form
was still dramatically poorer using r.in.tiff than going through the
snapshot tool.

My knowledge of GRASS color handling is meager.  I cannot figure out
why GRASS cannot assign a colortable like that in xv, other than the
well known matter that GRASS reserves some of the 256 colors for vector
overlays.  But, this does not explain why a 128 color xv image that
looks dandy comes into GRASS and becomes a 128 category GRASS map
that looks much poorer.  Oh, by the way, there is no color improvement
with d.colormode float compared to d.colormode fixed.

Anyone have an explanation or work-around?

One work-around might be possible: xv allows one to use a window larger
than the screen to display an image, so one can display a 3,000 X 3,000
pixel image at actual resolution and pan around to see the whole thing.
Unfortunately, the Sun snapshot tool, which has an option to capture
a "window" only grabs the portion displayed on the screen.  Anyone know
of a frame-grabber program that will grab the whole window and dump it
into a Sun raster file or other image format?  That would allow image
enhancement in xv and transfer to GRASS of the enhanced color rendition.

Maybe I'm missing something simple in all of this...?

Bill Baker
bakerwl at uwyo.edu

P.S. sorry for such a long message...





More information about the grass-user mailing list