View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Get a color name from any RGB combination?

The hard bit is to define a virtual "colour space" that reflects the
very different way the human eye perceives colour differences vs the
actual RGB differences. Eg the eye perceives green as occupying a
much larger relative space than its neighbour in the spectrum cyan.
There are various example spaces out there but replicating them is
difficult. I gave up and devised my own colour space as a semi
regular 3D space, complex but regular enough to be defined with an
algorithm.

Then map all the colours in the list in the space with XYZ
coordinates from a given reference point, and similar with the RGB
you want to match. Finally the simple bit, calculate all the 3d
distances of your colour to match to each of the mapped swatch
colours. The best match is the one with the shortest distance in the
space, though in a large swatch a good idea to return and rank a few
other close matches and let your own eye judge the best. And that's
all there is to it!


Hi Peter,

What purpose is a "virtual color space"? What purpose does the "xyz"
assignments serve?

VB's RGB() function only requires the 3 RGB values, and so I don't get
the need for all the extra 'fluff' if using that function to
define/name colors derived from RGB values. Am I missing something?

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion