Simplification of the colors of a picture

You did not understand anything, I am sorry!
When I find the solution I will explain to you.

If you share the problem context, we can more easily help you find a solution. This is an interesting question, but difficult to assist with in the abstract.

1 Like

If you reduce the number of colors, you will lose some faint colors.

You cannot have it both ways.

So you’re losing the Alpha channel?

Did you manage to get any solution?

Of course!
For the moment I arrived at that but I must deepen.
I proceed as follows:

  1. For each pixel of the image, we transform it into HSV.
  2. With the value H we are already sure to have the right color.
  3. The problem is that for a too low value of saturation (S) the distance between the colors brings us back to white for example.
    For any saturation value (S) close to 0 but not zero, it is reduced to 12.5%.
  4. Then we convert the color of the pixel into XYZ and finally into LAB to calculate the distance between the colors (CIEDE2000)
    We retain the closest distance in the color palette and therefore the final color of the pixel.
    It works for light colors but not for some grays, etc, you have to play on the “V” too I think.
    I will continue to search.

I’m not a specialist but I’m still on the 2010 version of Xojo and there we weren’t talking about the Alpha channel yet I think