GNOME Bugzilla – Bug 616138
Inaccurate colormap choices when converting RGB to indexed
Last modified: 2016-11-16 16:09:59 UTC
From http://bugs.debian.org/577623: When converting an RGB image to indexed, the GIMP sometimes fails to choose as accurately as it could between similar colors in a chosen palette, even when each pixel has an exact match somewhere in the palette. The enclosed colormaptest.ppm and Colormap_test files together form a test case to reproduce this bug, as follows: 1. Compare colormaptest.ppm (a text PPM image) and Colormap_test (a GIMP palette) to verify that each contains the same RGB triples in the same order. 2. Move or copy Colormap_test into a directory for GIMP palettes, e.g., the ~/.gimp-2.6/palettes/ directory. 3. Start the GIMP and open colormaptest.ppm, then zoom in enough that you can see each individual pixel. 4. Right-click image -> Image -> Mode -> Indexed... to open the Indexed Color Conversion dialogue, and set it as follows: a. Under "Colormap", select "Use custom palette", then click the button below that selection to pop up the list of available palettes. From this list select "Colormap_test". Uncheck the "Remove unused colors from colormap" checkbox if it's checked. b. Under "Dithering", for "Color dithering:" select "None". Uncheck the "Enable dithering of transparency" checkbox if it's checked. c. Click "Convert". 5. Observe that while the leftmost and middle pixels have been mapped to their exact matches in the palette, the rightmost pixel has been mapped to the same color as the middle pixel. (Try pressing ^Z to undo and ^Y to redo repeatedly if you don't see it at first.)
Created attachment 159040 [details] test .ppm
Created attachment 159041 [details] test colormap
Duplicate of bug #66257 ?
I'm not positive, but that bug looks more related to generating an optimal palette.
Greetings from Debian (l)userland! As far as already-existent bug reports go, this one seems to mostly resemble bug #421751, and its clone, bug #602632. After reading the mention in bug #421751 that the conversion works in CIE-LAB colorspace, I think it would be best to work straight in RGB space so as to minimize odd colormap choices like these. After examining the code in question (app/core/gimpimage-convert.c) for a bit, though...good grief it's a mess. I don't think the proper solution is to take out indexed mode entirely (as Michael Schumacher mentions in bug #602632 comment 2), though, so I'd like to help fix it properly, presuming somebody or another has managed to "find time to debug" in the intervening THREE YEARS since the bug was first reported. :)
Another bug to reevaluate for 2.10.
I don't know what has changed, but converting to a palette that contains *all* the image's colors seems to work now in master. The attached test case produces identical colors after indexed conversion.