[mapserver-users] 24bit to 8 bit with dithering
    Frank Warmerdam 
    warmerdam at pobox.com
       
    Tue Nov 19 21:37:15 PST 2002
    
    
  
Folks,
I have completed implementation of 24bit to 8bit dithering in the draw-from
GDAL code.  It turns out this requires the very latest GDAL (ie. build from
CVS later than right now), so I require the ENABLE_DITHER macro to be
added to the makefile.
Dithering is enabled if the PROCESSING keyword is used with the layer to
set the "DITHER=ON" directive. Currently the dithering uses the existing
color table (that created by the usual color cube logic), so results are
still questionable, but better than they were.  I am also interested in
incorporating optimal colortable selection at some point.
I would also note that the approach is pretty cpu intensive, and there is
a fair overhead per raster file processed, so using it for many 24bit "tiles"
from separate files in a single draw would be the worst case.  This
technlogy is not appropriate for servers wanting to maximize performance.
The following is an example of using the new support:
NAME TEST
STATUS ON
SIZE 400 300
EXTENT 0 0 400 300
IMAGECOLOR 255 255 0
PROJECTION
   "proj=utm"
   "zone=12"
   "datum=WGS84"
END
IMAGETYPE png8_t
OUTPUTFORMAT
   NAME png8_t
   DRIVER "GD/PNG"
   IMAGEMODE PC256
   TRANSPARENT OFF
END
LAYER
   NAME grey
   TYPE raster
   STATUS default
   DATA data/pct22.tif
   PROJECTION
     "proj=utm"
     "zone=12"
     "ellps=WGS84"
     "towgs84=1,0,0"
   END
END
LAYER
   NAME rgb
   TYPE raster
   STATUS default
   DATA data/rgb.tif
   OFFSITE 111 222 111
   PROCESSING "DITHER=ON"
   PROJECTION
     "proj=utm"
     "zone=12"
     "ellps=WGS84"
     "towgs84=1,0,0"
   END
END
END # of map file
The output without dithering as a colormapped png file (2.8K) is:
   http://pobox.com/~warmerdam/rgb_overlay_res_to8bit.png
With dithering (18K) is:
   http://pobox.com/~warmerdam/rgb_overlay_res_to8bit_dithered.png
Anyone brave enough to build the latest GDAL and MapServer 3.7 from CVS
are welcome to contact me for help in using the new dithering option.
Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent
    
    
More information about the MapServer-users
mailing list