Ticket #2096 (closed enhancement: fixed)

Opened 6 years ago

Last modified 2 years ago

static color Palette support for gd output

Reported by: assefa Owned by: jmckenna
Priority: normal Milestone:
Component: Documentation - MapServer Version: 5.0
Severity: normal Keywords:
Cc:

Description

The gd format has currently the possiblity to draw a 24 bits image and output an 8 bits image using the QUANTIZE_COLORS functionality. When using this method in Mapserver and generating tiled maps (eg with kaMap), there was an issue since the colors were "random" between tiles and may cause 2 adjacent tiles to use a different color for the same feature. The idea here is to be able to add a static color palette that can be used when tranforming 24bits to 8 bits.

Change History

Changed 6 years ago by assefa

The initial implementation has been done and tests ar on going. The functionality is accessed by defining a the following in the outputformat :

OUTPUTFORMAT

NAME "agg/png24" MIMETYPE "image/png; mode=24bit" DRIVER "AGG/PNG" EXTENSION "png" IMAGEMODE "RGBA"

FORMATOPTION "PALETTE=c:/msapps/fbs-navteq/map/palette.txt" FORMATOPTION "FULL_RESOLUTION=TRUE"

END

The path to the palette is for now a full path to a test file conating r,g,b values on each line :

242,236,230 150,150,150 0,0,0 ...

the current implemenation allocates the colors found in the palette into the 8 bit image and also uses the gdImageCreatePaletteFromTrueColor to allocate the rest of the available colors.

Changed 6 years ago by sdlime

  • status changed from new to assigned
  • version set to 5.0
  • component changed from MapServer C Library to MapServer Documentation
  • milestone set to 5.0 release

Leaving this ticket open but changing component to documentation to make sure that happens.

Steve

Changed 6 years ago by dmorissette

  • summary changed from ststic color Palette support for gd output to static color Palette support for gd output

Changed 6 years ago by assefa

We are running into some performance issues with images of 6000/6000 (kaMap Tiles). The performance hit seems to come from the msImageCopyForcePaletteGD when goinf through each pixel and using gdImageColorClosest to find the closest color. There may be ways to optimize this (maybe some sort of caching or hashing). Looking into this but Steve if you have suggestions let me know.

Changed 6 years ago by assefa

We looked a bit in the performance issue reported earlier with large images.

One possible solutions we tried was to cache few colors in msImageCopyForcePaletteGD so we do not call gdImageColorClosest for those that are in the cache.

Just caching the last color made a dramatic drop in time with our test tiles of 6000/6000. Tried diffrent size of cache (keeping 10, 20, 50 colors) and we had the best result with 10 colors although the diffrence between them was not significant.

Steve, I would like to add this cahing if it is ok with you.

As a comparative, results here are the numbers that Zak got:

Here is the timing information, just for the record. Image is 6144*6144 navteq road data of wisconsin.

AGG before patch: 111.855 AGG after patch: 27.520 GD-PNG 8: 19.526 GD24: 19.731

Changed 6 years ago by sdlime

By all means, add the caching. Are there any threading issues with the color cache?

Steve

Changed 6 years ago by assefa

Caching is done locally in the function and should not have any threading issues. Commited in r6335.

Changed 6 years ago by hobu

Has this work been completed and this bug can be closed? If so, we should update HISTORY.TXT also.

Changed 6 years ago by assefa

Work is completed with the exception of full path requirement for the palette file. Once docs are done on it, this bug should be moved to a Future or 5.2 to be able to adress the full path issue.

Adding missing entry in HISTORY.txt r6502

Changed 6 years ago by dmorissette

I'd suggest using two bugs (creating a new bug for the 5.2 enhancements) to avoid having the confusion of bugs spanning over multiple versions.

Changed 6 years ago by sdlime

There is a full path bug already for 5.2.

Steve

Changed 6 years ago by assefa

  • owner changed from sdlime to jmckenna@…
  • status changed from assigned to new

my mistake : only the doc part is remaining for this bug; there was already a seperate bug on the path issues (#2115)

Changed 6 years ago by assefa

Note : just found a bug in msImageCopyForcePaletteGD, fix commited in r6525.

Changed 6 years ago by jmckenna

  • owner changed from jmckenna@… to jmckenna
  • status changed from new to assigned

Changed 5 years ago by jmckenna

  • status changed from assigned to new

Changed 2 years ago by tbonfort

  • status changed from new to closed
  • resolution set to fixed

this is documented now

Note: See TracTickets for help on using tickets.