1. color difference equations
- Posted by Tone Škoda <tskoda at email.si> Sep 29, 2004
- 515 views
- Last edited Sep 30, 2004
I know there exist these color difference formulas: CIELAB, CMC, BFD, CIE94, GLAB but I just can't find them on the net. Can somebody help me find them? I want to test them to find out which one is working best. As input I want to have RGB not LUV or something like that, because finding formulas to do conversion is also hard. I don't know which formula this function uses, but it doesn't work good:
--// Returns difference of two colors. --// atom between 0 and 1. --// 0 = smallest difference --// 1 = biggest difference global function weighted_color_distance (COLOR color1, COLOR color2) integer rmean integer dr,dg,db rmean = floor((GetRValue (color1) + GetRValue (color2)) / 2) dr = (GetRValue (color1) - GetRValue (color2)) dr *= dr dr = floor((dr * (512 + rmean)) / 256) dg = (GetGValue (color1) - GetGValue (color2)) dg = (dg * dg) * 4 db = (GetBValue (color1) - GetBValue (color2)) db *= db db = floor((db * (767 - rmean)) / 256) return (dr + dg + db) / 584970 end function
2. Re: color difference equations
- Posted by Greg Haberek <ghaberek at gmail.com> Sep 30, 2004
- 495 views
How weird.... GMail displays Google Ads pertaining to the message you're reading. One of the 'Related Pages' links that popped up was this: www.easyrgb.com/math which I'm sure you'll find quite useful. ~Greg On Thu, 30 Sep 2004 00:41:35 +0200, mic _ <stabmaster_ at hotmail.com> wrote: > > Where did you get that code from? It looks very similar to something I wrote > a long time ago, but I can't remember for what program. > Anyway, you could view the two colors as 3D vectors and calculate the > difference in length of the vectors, the angle between the vectors or some > other measure. Or you could calculate the luma of each color and take the > difference between those (where luma = 0.299*R + 0.587*G + 0.114*B). I bet > there are lots of other formulaes. > > > >I don't know which formula this function uses, but it doesn't work good: > >}}} <eucode> > >--// Returns difference of two colors. > >--// atom between 0 and 1. > >--// 0 = smallest difference > >--// 1 = biggest difference > >global function weighted_color_distance (COLOR color1, COLOR color2) > > integer rmean > > integer dr,dg,db > > > > rmean = floor((GetRValue (color1) + GetRValue (color2)) / 2) > > dr = (GetRValue (color1) - GetRValue (color2)) > > dr *= dr > > dr = floor((dr * (512 + rmean)) / 256) > > > > dg = (GetGValue (color1) - GetGValue (color2)) > > dg = (dg * dg) * 4 > > > > db = (GetBValue (color1) - GetBValue (color2)) > > db *= db > > db = floor((db * (767 - rmean)) / 256) > > > > return (dr + dg + db) / 584970 > >end function > ></eucode> {{{ > > > > > > >
3. Re: color difference equations
- Posted by Tone Škoda <tskoda at email.si> Sep 30, 2004
- 511 views
Greg Haberek wrote: > > How weird.... GMail displays Google Ads pertaining to the message > you're reading. One of the 'Related Pages' links that popped up was > this: www.easyrgb.com/math which I'm sure you'll find quite useful. There is some useful stuff on that site, thanks. But still no color difference formulas.