Gimp-Forum.net
What is GIMP's color matching algorithm? - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: What is GIMP's color matching algorithm? (/Thread-What-is-GIMP-s-color-matching-algorithm)



What is GIMP's color matching algorithm? - trandoductin - 06-11-2021

When you have an image that is in indexed color (so it has a palette that contains a set numbers of colors, example 10 colors only).
Then when you bring in an RGB full color image (by pasting it in I guess).
GIMP will turn your your RGB full color image into indexed as well, while trying to match colors of your RGB to indexed as best it can.

What is their formula/algorithm for doing this? I want enough details to replicate GIMP's color-matching functionality.


How can I find it in code in GIMP's source code?

Why do I want to know this?: I want to add a color matching method for my cross-stitching plug-ins called "GIMP's method" instead of Delta-E and Perceptive as these are sometimes off as well...and GIMP's seem to do a great job at keeping the RGB image looking very close with those limited indexed colors.  Just curious to find out if GIMP's method is superior compared to Perceptive and/or Delta-E.

Thank you in advance.


RE: What is GIMP's color matching algorithm? - trandoductin - 06-11-2021

Never mind, I found the code:
It looks like it's just using perceptive proportions:
#define DISTP(R1,G1,B1,R2,G2,B2,D) do {D = sqrt( 30*SQR((R1)-(R2)) + \
59*SQR((G1)-(G2)) + \
11*SQR((B1)-(B2)) ); }while(0)