Opened 14 years ago

Closed 12 years ago

#1518 closed enhancement (fixed)

PNG8 color quantization uses too few colors resulting in changing colors in small pans

Reported by: gabrimonfa Owned by:
Priority: low Milestone:
Component: Rendering Service Version: 2.4.0
Severity: trivial Keywords:
Cc: External ID:

Description

Mapguide 2.2RC on centos5

PNG8 visual quality is much more appealing than JPEG especially in text and thin lines. However actually it has one problem that may prevent its adoption.

Even doing very small pans objects may change sensibly their colors, which is visually disturbing

Have a look to the right upper corner in

  • map_png8_1.png
  • map_png8_2.png

or at the darker pink polygons in the lower part of the map.

I was wondering if this is inevitable due to the color quantization or not, thus I've made some tests.

First of all, look at the PNG image corresponding to the first image

  • map_png_1.png

Looking at the number of its colors (map_png_1_info.png) it has 16238 different colors.

Obviously map_png8_1.png is limited to 256 colors, but the first surprise is that the PNG8 version has only 135 colors (map_png8_1_info.png).

First question: why the algorithm of color quantization uses so few colors?

Then I try to reduce the number of colors in the PNG version transforming it in a palletted image

  • map_png8_1_gimp.png (and map_png8_1_gimp_info.png)

obtaining an image with 256 colors, which colors are much more like the original one w.r.t. to Mapguide produced one.

I then force GIMP to use only 135 colors, in order to see if it is possible to have better results also with fewer colors

  • map_png8_1_gimp_135.png (and map_png8_1_gimp_135_info.png)

The answer is yes, the image is a lot better that that obtained by Mapguide

Second question: is it possible to improve the quality of the color quantization?

Even if each pan does an independent color quantization, if the obtained image is very similar to the PNG original one, probably the images obtained with small pans also look similar between them. And the problem would disappear.

Third question: is it possible to preserve the stylization colors of the objects in the map if the number of colors involved is less than 256?

I've seen that this has been addressed for base layer in http://trac.osgeo.org/mapguide/wiki/MapGuideRfc60. Would be possible to adopt a similar solution for all the layers?

I mean, probably it is more wise to preserve these colors and changing a bit the colors used for smoothing around lines. Even with a lot of transparencies, as in my examples, we're probably under 256 "stylization colors". This claims is confirmed by the fact that even with only 135 colors GIMP is able to produce an image which at first sight is quite similar to the original one

Attachments (9)

map_png8_1.png (160.8 KB ) - added by gabrimonfa 14 years ago.
map_png8_2.png (161.6 KB ) - added by gabrimonfa 14 years ago.
map_png_1.png (690.9 KB ) - added by gabrimonfa 14 years ago.
map_png_1_info.png (12.2 KB ) - added by gabrimonfa 14 years ago.
map_png8_1_info.png (11.8 KB ) - added by gabrimonfa 14 years ago.
map_png8_1_gimp.png (190.6 KB ) - added by gabrimonfa 14 years ago.
map_png8_1_gimp_info.png (12.0 KB ) - added by gabrimonfa 14 years ago.
map_png8_1_gimp_135.png (172.2 KB ) - added by gabrimonfa 14 years ago.
map_png8_1_gimp_135_info.png (11.7 KB ) - added by gabrimonfa 14 years ago.

Download all attachments as: .zip

Change History (11)

by gabrimonfa, 14 years ago

Attachment: map_png8_1.png added

by gabrimonfa, 14 years ago

Attachment: map_png8_2.png added

by gabrimonfa, 14 years ago

Attachment: map_png_1.png added

by gabrimonfa, 14 years ago

Attachment: map_png_1_info.png added

by gabrimonfa, 14 years ago

Attachment: map_png8_1_info.png added

by gabrimonfa, 14 years ago

Attachment: map_png8_1_gimp.png added

by gabrimonfa, 14 years ago

Attachment: map_png8_1_gimp_info.png added

by gabrimonfa, 14 years ago

Attachment: map_png8_1_gimp_135.png added

by gabrimonfa, 14 years ago

comment:1 by gabrimonfa, 12 years ago

Version: 2.2.02.4.0

This ticket has probably been fixed closing #743.

ASAP I'll try to reproduce it on Mapguide 2.4final

comment:2 by gabrimonfa, 12 years ago

Resolution: fixed
Status: newclosed

Can't reproduce anymore on Mapguide 2.4 Marking it as fixed

Note: See TracTickets for help on using tickets.