Opened 16 years ago
Last modified 15 years ago
#2440 new enhancement
[PATCH] Improves raster 8-bit output rendering
Reported by: | rouault | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | MapServer C Library | Version: | unspecified |
Severity: | normal | Keywords: | raster 8-bit output |
Cc: | warmerdam |
Description
Currently, 8-bit output rendering can lead to bad looking visual results when the WMS request matches several source raster products.
If there are 2 paletted source raster products, the palette of the first one is used to fill the output palette. When the second product is rendered, there's often not enough room for its colors and it is badly rendered.
If there are 2 24-bit source raster products, the color cube palette is used and leads to bad visual results with smoothly changing images. This can be improved with using DITHER=ON.
The attached patch adds a new processing option, "PALETTE_PRELOAD=ON", that greatly improves the rendering in the 2 above cases. It adds a function msPreallocateColorTable that is run before rendering layers. This function loops on all layers, and on all raster products in each layers that will be rendered and collects all the colors that are going to be used. Then it uses the algorithm taken from gdalmediancut.cpp to reduce the colors to 256 and allocate them to the output image. In the case of source 24-bit images, the function reads a text file that contains the optimal 8-bit palette for the 24-bit image. This text file is of the form :
R1 G1 B1 R2 G2 B2 ...
This can be obtained in pre-processing by GDALComputeMedianCutPCT for example. Of course, for 24-bit input images, the use of "DITHER=ON" is highly encouraged in addition to the use of "PALETTE_PRELOAD=ON"
I'm also attaching a mapfile and a set of 24-bit images and their 8-bit reduced equivalent that demonstrate the improvements.
Attachments (6)
Change History (12)
by , 16 years ago
Attachment: | degrade.tar.gz added |
---|
by , 16 years ago
Attachment: | result_8bit_no_preload.gif added |
---|
Output of 3 8-bit images, without the new option
by , 16 years ago
Attachment: | result_8bit_preload.gif added |
---|
Output of 3 8-bit images, with the new option
by , 16 years ago
Attachment: | result_24bit_no_preload.gif added |
---|
Output of 2 24-bit images, without the new option
by , 16 years ago
Attachment: | result_24bit_preload.gif added |
---|
Output of 2 24-bit images, with the new option
comment:1 by , 16 years ago
Type: | defect → enhancement |
---|
comment:2 by , 16 years ago
Cc: | added |
---|
comment:3 by , 16 years ago
Milestone: | → 5.2 release |
---|
by , 16 years ago
Attachment: | mapserver_svn_trunk_improves_8bit_output.patch added |
---|
comment:5 by , 16 years ago
Owner: | changed from | to
---|
Reassigning to warmerdam... (raster stuff is really his baby) I'd hate to see a contribution like this not make it in assuming it's a good idea.
Steve
comment:6 by , 15 years ago
Milestone: | 5.6 release |
---|
Set of input raster and mapfile to demonstrate the improvements of the patch