8 bit greyscale images look like 4 bit

Stephen Lime steve.lime at dnr.state.mn.us
Tue Nov 28 22:55:57 EST 2000


The programmer that developed much of the raster code made the decision to use 4 bit greyscale instead of 8. That was based on previous experience with that type of data. Works great with DOQs here in the states but obviously has limitations. The work around (other than to hack the code) is to convert from greyscale to paletted (with a greyscale palette).

Colors in the mapfile are pre-allocated regardless of layer state. I did that initially to avoid caching colors thus keeping the C structures a bit cleaner and then when 24-bit output happens it's just a type change. Normally that's not much of an issue. Note that raster colors are added only if processed and because of the way the labels are processed antialiasing only eats colors at the very end of the palette.

I'll look into some alternatives.

Steve

>>> <Tim.Mackey at agso.gov.au> 11/28/00 18:41 PM >>>
Hi,

I also had problems with greyscale images appearing to only have a few
(about 4) shades of grey. Other colours (muddy browns and greens) were then
substituted for the other shades of grey.

After delving into the code, it looks like the colour palette is created
when the map file is parsed. Therefore, the 256 colours of the palette are
spread amongst all of the colours defined in the map file (whether these are
active layers or not).

To make my greyscale images appear ok (without brown or green tinges), I
changed the following code in mapfile.c:
I replaced this line:
map->palette.numcolors = 0;

with:
for(int i=0;i<16;i++)
    {
    map->palette.colors[i].red=i*16;
    map->palette.colors[i].green=i*16;
    map->palette.colors[i].blue=i*16;
    }
map->palette.numcolors=16;

This gave my greyscale at least 16 colours to chooe from. Not perfect, but
better than previous. Still plenty of palette left for the other colours.

In my application (http://www.agso.gov.au/map/national) I have over 100
layers (1500 classes) in the map file so there is lots of colour
substitution going on.

As a development request, it would be much better if the palette were
constructed from active layers only - Steve?

regards,

Tim Mackey
Web Applications Developer
email: tim.mackey at agso.gov.au
phone: (02) 6249 9813
fax: (02) 6249 9984

Australian Geological Survey Organisation
(Geoscience Australia)
ABN: 80 091 799 039
http://www.agso.gov.au/


-----Original Message-----
From: Scott Phillips [mailto:scott at esrp.org]
Sent: Wednesday, 29 November 2000 10:37
To: mapserver-users at lists.gis.umn.edu
Subject: 8 bit greyscale images look like 4 bit


Hello all,

I am setting up a new server with tiles of 8 bit greyscale images
(landsat 7 panchromatic).   Although the images are 255 color, they
are looking like 16 color images on the screen.  I have tried 
converting them to palleted color (with shades of gray), upgrading
to GD1.8.3, and converting the images from TIFF to EPPL, but I get
the same results.

Are the images being cut down in colors in "mapraster.c" or somewhere.
If so, does anyone know of a workaround to let the images show up in
8 bit color.

Thanks,

Scott Phillips
CSUS/ESRP
sphillip at esrp.org




More information about the mapserver-users mailing list