2
$\begingroup$

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:

  1. http://www.colourphil.co.uk/lab_lch_colour_space.html
  2. http://www.broadhurst-family.co.uk/lefteye/MainPages/Lab.htm
  3. http://en.wikipedia.org/wiki/Lab_color_space
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – joriki Feb 12 '13 at 9:09
  • $\begingroup$ Ok, thank you for pointing this out. $\endgroup$ – Tamás Pap Feb 12 '13 at 9:12
  • $\begingroup$ Similar question of mine on SO: stackoverflow.com/questions/1351442/… $\endgroup$ – Tom Pažourek Apr 21 '14 at 11:52
2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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.. $\endgroup$ – Tamás Pap Feb 12 '13 at 9:30
2
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

In L*a*b* the difference between two colors is the euclidian distance.

If you want to mix "equal" amounts, then that is the midpoint of the line between the two colors.

$ L^*a^*b^*_{mix} = \frac{L^*_1 + L^*_2}2, \frac{a^*_1 + a^*_2}2,\frac{b^*_1 + b^*_2}2 $

However, you might also want to look at CIELCh, which converts LAB to polar coordinates, allowing you to keep chroma constant and then ust adjust hue as the angle between the two colors. You'll find that many color blends in LAB will end up near grey if the colors are nearly opposite. This is because the midpoint line will go through the center of the LAB space, which is a chroma of zero.

Here's an example of four types of mixing between the colors.

color mixes

The mid color for just mixing between the two sRGB values is #808080, for LAB it's #C98AA9 and for LCh it's #FF006A

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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