Results 1 to 5 of 5

Thread: mapping RGB to color palette

  1. #1
    Join Date
    Dec 2006
    Location
    Netherlands
    Posts
    983

    Default mapping RGB to color palette

    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.

  2. #2
    Join Date
    Dec 2006
    Location
    Pflugerville, TX, USA
    Posts
    1,977

    Default

    I looked into it but couldn't find anything. But, I am curious why you would need to do that?

  3. #3
    Join Date
    Jun 2007
    Posts
    44

    Default

    Hi zoof,

    Using the euclidean distance (square root of sum of squares) is a good idea. Unfortunately, colours which are nearby in the RGB space are not necessarily perceived as similar by humans.

    One solution is to use another colour space. The euclidean distance in CIE L*a*b* colour space is called "delta E" and is commonly used as a measure of the perceived difference in colors by humans. This should give you a better result.

    The conversion from RGB to CIE L*a*b* colour space is trivial and you can find many examples on the internet.

    http://en.wikipedia.org/wiki/Lab_color_space

    Kind regards,

    sonaluma

  4. #4
    Join Date
    Oct 2006
    Location
    Central Florida
    Posts
    7,067

    Question

    I was going to post this as the second post... but now that others have posted... WHAT? O, and why?
    Love, peace, and grease,

    allthat... aka: aaron@pangolin

  5. #5
    Join Date
    Dec 2006
    Location
    Netherlands
    Posts
    983

    Default

    sonaluma: Thanks! That will get me started!

    carmangary: The reason I'm looking into this is because I'll be using LDS soon which is palette based. So I need to be able to convert RGB values of my existing clip art into palette values.
    I was first using Mamba Black because is did handle RGB but it has other drawbacks so I'm switching to LDS.
    Hope the palettes don't end up frustrating me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •