There must be a number of ways to do this but what is considered to be the best?
I came across an option that imagines a RGB color as a point in three dimesions spanned by R,G and B and the finds a palette color closest to the original RGB color.
Thus finds a palette color for which distance is the smallest:
Code:
distance = sqrt( (R_original - R_palette)^2 +(G_original - G_palette)^2 + (B_original - B_palette)^2)
However this can give some decolorations. So I'm thinkig it may be better to decompose a color value into RGB ratios and intensity. Then first find paletted colors closest to the RGB ratios and then select one with the closest intensity.
Are there any other ways to do this?
cheers
Z.