Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two colors in LAB color space, for example:

blue: 32.303, 79.197, -107.864 (hex code: #0000ff)
yellow: 97.138, -21.556, 94.482 (hex code: #ffff00)

I want to mix these two colors, and get the result color (hopefully some green in this case). Any ideas how to accomplish this?

More about LAB color space:

share|cite|improve this question
The coloring flag is for graph colourings. The tag descriptions are displayed in the tag selection interface, so you can use them to decide which tags are appropriate. – joriki Feb 12 '13 at 9:09
Ok, thank you for pointing this out. – Tamás Pap Feb 12 '13 at 9:12
Similar question of mine on SO:… – Tom Pažourek Apr 21 '14 at 11:52

I assume you are writing a computer implementation.

LAB is device independent. Your color codes are not, as they will be processed both by software and hardware before you see the colors. As a first approximation, convert your RGB to sRGB, which in this case will act as a reference device-independent color space.

When the sRGB values are obtained, convert to CIEXYZ and then to LAB, as the Wikipedia article on LAB suggests. Thus, write a function to compute $rgb\rightarrow sRGB \rightarrow XYZ \rightarrow L*a*b*$. Once the latter is obtained, you can interpolate linearly, e.g., take the average values of each value, and then perform the inverse transform to get your new RGB codes.

share|cite|improve this answer
Thank you for your answer. This is what I just finished implementing. It works good for mixing red with yellow (resulting in orange), but mixing blue with yellow results in a kind of purple. It should be a kind of green, if I'm correct.. – Tamás Pap Feb 12 '13 at 9:30

Simen's answer won't work for yellow and blue mixing.

There are two types of mixing of colors: mixing light and mixing pigments. When you are mixing light, then adding something will make it brighter. When you are mixing pigments, you are taking light out... making it darker.

Hence the confusion. On a computer monitor, yellow (255R, 255G, 0B) plus blue (0, 0, 255) is equal to white. If you do some sort of average, you get gray. With pigments, you get green, of course.

Simulating what the pigments do is very difficult. You need to convert to reflectance and form a product, red with red, green with green, and blue with blue. Even that won't work as you expect, but it will highlight the fact that a mixture of pure yellow pigment and pure blue pigment will give you black, and not green.

To make it work out, you need to start with the correct pigments. Cyan (0, 255, 255) mixed with yellow (255, 0, 0) gives you green when you multiply.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.