[MAPSERVER-USERS] help! agg palette quantize algorithmimperfection

BrainDrain paulborodaev at gmail.com
Sat Jun 7 06:35:13 PDT 2008


hmmm, like sample map image with all layers (and most symbols) turned on?
sounds reasonable
That would be enough? (not all colors in sample: the nearest colors will be
used?) Sorry for importunity.

Steve Lime wrote:
> 
> I've generated palettes by rendering a large 24-bit sample image and then
> reducing colors using
> tools like Photoshop, GIMP or ImageMagick. Then I just run gdalinfo output
> on the reduced color
> image through a perl script to extract the palette.
> 
> #!/usr/bin/perl
> 
> $doit = 0;
> while(<>) {
>   if($_ =~ /Color Table/) {
>     $doit = 1;
>     next;
>   }
> 
>   if($doit) {
>     ($r,$g,$b,$a) = split /,/, substr($_,7); 
>     print "$r,$g,$b\n";
>   }
> }
> 
> Works just fine...
> 
> Steve
> 
>>>> On 6/6/2008 at 3:24 PM, in message <17700473.post at talk.nabble.com>,
>>>> BrainDrain
> <paulborodaev at gmail.com> wrote:
> 
>> $? You're kidding)) Anyway, thanks for advise. Will try. 
>> And what about agg rgba mode (bug, invalid color interpretation
>> (inverting?)
>> or something like that)? When
>> this problem will be fixed? I need it, because I want to use map
>> transparency (only rgba mode) to combine with google map layer in
>> openlayers
>> rich client app.
>> 
>> Stephen Woodbridge wrote:
>>> 
>>> Hey, that's what they pay you the BIG BUCKS for! :)
>>> 
>>> Write a perl/bash/{your favorite} script to grab all the COLOR lines 
>>> from you mapfile and reformat the r g b to r,g,b in you palette file.
>>> 
>>> I have a few hundred symbols in my symbol library, but I only use about 
>>> 10 of them regularly so I made sure the primary colors were also in the 
>>> palette file. I make the script add them so I don't have to think about
>>> it.
>>> 
>>> It sounds like a big deal, but it not that bad.
>>> 
>>> YMMV,
>>>    -Steve W
>>> 
>>> BrainDrain wrote:
>>>> Thanks, i already read about preparing palette index file & I see 2
>>>> obstacles:
>>>> 1) I need to monitor my map file (big size) to keep relevant my palette
>>>> file. It is inflexible to extract rgb colors used in pixmap symbols
>>>> (hundreds, updatable). Can I use html palette for ex. (or any other
>>>> 'universal' palette) - to make this process not so time-consuming?
>>>> 2) If I have strict palette, can I be sure that agg renderer will
>>>> always
>>>> use
>>>> the nearest(?) color from my palette?
>>>> 
>>>> pagameba wrote:
>>>>> Use:
>>>>>
>>>>> OUTPUTFORMAT
>>>>>    OUTPUTFORMAT
>>>>>    NAME "AGG_Q"
>>>>>    DRIVER "AGG/PNG"
>>>>>    MIMETYPE "image/png; mode=8bit"
>>>>>    IMAGEMODE RGB
>>>>>    EXTENSION "png"
>>>>>    FORMATOPTION "PALETTE_FORCE=TRUE"
>>>>>    FORMATOPTION "PALETTE=/path/to/palette.txt"
>>>>> END
>>>>>
>>>>> where palette.txt is a text file with RGB tuples in the form:
>>>>>
>>>>> RRR,GGG,BBB
>>>>>
>>>>> For example:
>>>>>
>>>>> 0,0,0
>>>>> 255,255,255
>>>>> 127,127,127
>>>>>
>>>>> MapServer will use AGG 24 bit rendering but reduce the output file to  
>>>>> 8 bit and reserve the colours in your palette.txt file.  This will  
>>>>> give you consistent colours for the ones you care about.   
>>>>> Specifically, you should reserve all the colours that you actually  
>>>>> reference in your map file plus any colours of pixmap symbols.  Don't  
>>>>> put in more colours than you actually need to because MapServer needs  
>>>>> to use whatever space is left (255 less your colours) for
>>>>> antialiasing.
>>>>>
>>>>> Cheers
>>>>>
>>>>> Paul
>>>>>
>>>>> On 6-Jun-08, at 7:53 AM, BrainDrain wrote:
>>>>>
>>>>>> I use this output format in my map file:
>>>>>> OUTPUTFORMAT
>>>>>> NAME "AGG_Q"
>>>>>> DRIVER "AGG/PNG"
>>>>>> MIMETYPE "image/png; mode=8bit"
>>>>>> IMAGEMODE RGB
>>>>>> EXTENSION "png"
>>>>>> FORMATOPTION "QUANTIZE_FORCE=ON"
>>>>>> FORMATOPTION "QUANTIZE_DITHER=OFF"
>>>>>> FORMATOPTION "QUANTIZE_COLORS=256"
>>>>>> END
>>>>>> but every time map draw called (or map image requested fom cgi  
>>>>>> mapserv.exe)
>>>>>> polygons has a little difference in fill color (I think this is  
>>>>>> because
>>>>>> color palette recalculated slightly different each time). This is
>>>>>> unacceptable for me. How can i correct this? (maybe some  
>>>>>> FORMATOPTION?)
>>>>>> -- 
>>>>>> View this message in context:
>>>>>> 
>> http://www.nabble.com/help%21-agg-palette-quantize-algorithm-imperfection-tp1766773 
>> 3p17667733.html
>>>>>> Sent from the Mapserver - User mailing list archive at Nabble.com.
>>>>>>
>>>>>> _______________________________________________
>>>>>> mapserver-users mailing list
>>>>>> mapserver-users at lists.osgeo.org 
>>>>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users 
>>>>>
>>>>> __________________________________________
>>>>>
>>>>>     Paul Spencer
>>>>>     Chief Technology Officer
>>>>>     DM Solutions Group Inc
>>>>>     http://www.dmsolutions.ca/ 
>>>>> _______________________________________________
>>>>> mapserver-users mailing list
>>>>> mapserver-users at lists.osgeo.org 
>>>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users 
>>>>>
>>>>>
>>>> 
>>> 
>>> _______________________________________________
>>> mapserver-users mailing list
>>> mapserver-users at lists.osgeo.org 
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users 
>>> 
>>> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> 

-- 
View this message in context: http://www.nabble.com/help%21-agg-palette-quantize-algorithm-imperfection-tp17667733p17708955.html
Sent from the Mapserver - User mailing list archive at Nabble.com.




More information about the MapServer-users mailing list