Hi,
I am currently trying to install “color math” on OS X 10.6 for Blender 2.62 (which uses Python 3.2, and trying to install ‘colormath’ failed so far with a quick attempt via MacPorts…)
Anyway, so I stumbled over this thread and thought I post my first answer here in this forum 
So I understand the OP is looking for an “algorithm” (or “method”) to provide “pleasant colours”, given a sample colour. Much like humans are able to tell whether two given musical notes are “in harmony or not” (off course also depending on their cultural background I guess) they are also able to tell whether two colours are “pleasant” - to a certain degree at least (“taste matters” ;)).
There are indeed some colour pairs which most people find “disturbing”, especially if you have letters on some background. The letters become hard to read (or they fully take your attention as well, so it might be a deliberate choice!).
For instance red and green, blue and orange and yellow and violet are typically regarded as being “complementary”. Because they lie “opposite” on some given colour “wheel”.
And the later off course depends… on the given colour space, and also whether we are talking about “additive” (such as the light rays of a computer screen) or “subtractive” (such as in real paint colour) colour.
But how do we get “pleasant colours”? I don’t know the answer right away, I think one would also have to dive into psychology here, or read any book about art. I don’t think there’s an algorithm here, it’s more like “certain colour pairs are generally accepted as being pleasant”.
That said, there are off course different “colour spaces” which help you with various tasks! When you deal with computer images the most known one is probably “RGB” (I leave specifics such as “sRGB” etc. away, for the sake of simplicity ;)), that is, every colour is “additively mixed” with Red, Green and Blue.
You can also think about this system as a “colour cube”, with 3 axis Red, Green and Blue.
But RGB is not very good for tasks such as “give me colours which have visually the same distance to a given colour” (“perceptual uniformity”) or “give me the colours which have the same brightness” (but it closely matches how a computer monitor mixes colours).
Or in other words: if you imagine a certain point O (a colour r, g, b) in the colour cube and you move a certain distance ‘d’ in one direction to the new point P1 = (r + d1, g + d2, b + d3), and then you move from the origin by the same distance d to another point P2, the subjective “colour difference” between O and P1 and O and P2 might be entirely different.
That’s why other “colour spaces” such as Lab* have been “invented”. Lab* for instance deals specifically with colour distances, such that when you move in that space (which is also a 3D form, but way more complicated than a simple cube), especially in the plane defined by a* and b*, then the “difference” is visually the same.
Simply put: a* and b* define the colour, and L* the brightness thereof.
Or if you simply want to get a colour with the same “brightness” (but don’t really care about “colour distances”), then you can use HSV (Hue, Saturation, Value), where “Value” would define the “brightness” of a given colour tone. [http://en.wikipedia.org/wiki/HSL_and_HSV]
Summary: depending on what you want (“give me a colour with the same distance as another colour pair” or “Give me a colour which Hue is 60 degrees away”) there are “colour spaces” which are a perfect fit for a given task.
And that’s where “colour conversions libraries” such as the mentioned “color math” in Python enter.
Some colour conversions such as RGB <-> HSV can be done “directly” with easy linear transformations, and they are “lossless”, that is converting a colour from one colour space into another one and back again results in the same colour.
Other conversions such as RGB <-> Lab* or RGB <-> CMYK (the later being used in printing) are more expensive to compute, as they require non-linear transformations, and they use an intermediate step via XYZ colour space. They are also not necessarily “lossless”, as not every colour in one colour space can be represented in another, so it is “clipped” to the nearest colour (think of it as “You can’t print every possible colour on your screen with your printer” or “You can’t display every colour on your screen that you possibly see in real life”).
If you are more interested in the math behind it, and about “chromatic adaption transform” (“reference white point” adaption), then are very good site is: http://www.brucelindbloom.com/
So short answer: Finding pleasant colours is mostly “a matter of taste”
(but there are colour spaces which can help you).
Cheers, Oliver
p.s. Anyone has a step-by-step solution yet how to make “color math” available for Blender 2.6x on Mac OS X? 