[mapguide-internals] RFC60 - PNG8 color palette improvements pleasecomment

UV uvwild at gmail.com
Mon Mar 2 00:04:17 EST 2009


Thanks Jason.

comments inline

Jason Birch wrote:
> Hi UV,
>  
> I'm not a graphics guru, but I have a few comments:
>  
> I really think that this work should be preceded by moving the definition of the tile / base layer image format out of the serverconfig.ini file and into the MapDefinition.  One size definitely does not fit all here.
>   
Thats a fine feature but does it have to be part of this code change as 
it has much wider scope?
The use case of using different image formats per map seems a useful 
feature but I think not necessarily in the scope of color quantization 
for PNG8 images.
There are solutions by running another instance of the mapguide server 
serving the different image format. Not pretty but workable.

Also it seems precomputing all images for the tile cache seems to be 
most efficient and the only really reliable way to use the mapserver for 
complex maps.
So the remaining use case is a server serving many fairly simple maps in 
different image formats....is that a common use case?
>  
> The palette to use should be defined at the base map scale range level, not at the map level.  It's quite possible that maps will use signifigantly different colour palettes at different scale ranges; look at Google Maps.
>   
The color palette is only used as a hint, it does not omit the color 
quantization happening in the tile service, it just adds the base colors 
(e.g. 45 in total of a big australian map)
so they will be the same per picture. If I collect the base colors per 
zoom level I am saving a few colors. I doubt that those saved color 
entries have a significant impact of the set
of colors produced by the current quantification algorithm which uses 
the supplied palette to start with.
The current approach does not prohibit antialiasing , uses the correct 
base colors for the map polygons and looks quite good.
(I am not sure how we can make a better test at this stage)
>  
> There should be an option for the user to hard-code the palette by attaching a PNG via resource data and reference it somewhere in the base map definition's extended data XML.
>   
Thats, fine and this is simply another option to control the color 
quantization and very easy to add. However, I do believe that the base 
colors plus box quantization is sufficient.
UseColorPalette = OFF
UseColorPalette = Computed
UseColorPalette = UserProvided
>  
> I don't think that parsing the layer definitions for colours is going to be adequate.  Both antialiasing and transparency will lead to situations where important colours are not explicitly defined in the layer definitions.  I believe that in production scenarios, it will be worthwhile to have a way of seeding the entire scale range at PNG24 and then analyzing the resulting images to generate an optimal 8 bit palette (and then attaching that to the map resource).
>   
This "brute force approach" was my original idea (precomputing the 24bit 
tiles and then using the complete set to determine the best map) and we 
discussed this prior to the POC.
However, collecting the base colors from the map definition XML and then 
using those _plus _the color created by the standard quantization algorithm
firstly, seems to be an intuitively correct approach. (compute a palette 
from the image, replace the least important with the provided map's base 
colors, and use that)
secondly the resulting images are so close to the brute force attack 
operating on the images only that its gonna be difficult in verifying 
any improvements.
Besides computing all tile maps can take weeks. (i have to wait 2 days 
for a complete layer in one zoom level) which is simply impractical.

>  
> Jason
>
> ________________________________
>
> From: mapguide-internals-bounces at lists.osgeo.org on behalf of UV
> Sent: Sun 2009-03-01 5:59 PM
> To: MapGuide Internals Mail List
> Subject: [mapguide-internals] RFC60 - PNG8 color palette improvements pleasecomment
>
>
>
> Hello,
>
> there is RFC60 place in the list and needs some commenting.
> Currently, we are looking into a serverconfig.ini parameter
> UseColorPalette in the TileServiceSection.
> upon init of the tile cache this parses the map definition and produces
> a palette with the map colors.
> Those are then used in some 100 extra line of C code in AGGImageIo.cpp
> to force those colors in
> the map used for the PNG8 created from the truecolor tile passed in by
> the rendering service.
>
> 1- which memory strategy is recommended for the color quantization? (3
> options in the RFC (stack, fast heap, efficient heap))
> 2 - is the ServerTileService the right place to put the code to collect
> the map colors?
> 3 - any suggestions regarding the naming and location of the color
> palette within the map definition?
>
> Comments are welcome!
> Also a few guiding remarks concerning the integration of the
> configuration code would make extremely helpful
> as just knowing where to start looking saves day of wasted code studies.
> These things are missing in the architecture
> docs so far.
>
> This is work in progress as there is a sponsor for it.
> Thanks for your support.
> UV
>
> _______________________________________________
> mapguide-internals mailing list
> mapguide-internals at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-internals
>
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> mapguide-internals mailing list
> mapguide-internals at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-internals
>   



More information about the mapguide-internals mailing list