Mathematica Stack Exchange is a question and answer site for users of Mathematica. 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 4 colors that I converted from RGB to CIELAB L*a*b* model.

  1. How can I calculate mix of these 4 colors when I have (L,a,b) for each such color?

  2. How can I calculate same mix, if I want to put weights (w1, w2, w3, w4) on such 4 colors, having 1 maximum and 0 minimum (none) weight?

share|improve this question
Unlike the RGB and CMYK color models, Lab color is designed to approximate human vision - CIE Lab* (CIELAB) is the most complete color space specified by the International Commission on Illumination (French Commission internationale de l'éclairage, hence its CIE initialism). It describes all the colors visible to the human eye and was created to serve as a device independent model to be used as a reference. – user1585 Jun 26 '12 at 18:33
Which RGB Color Space and what are the 4 CIELab values? – R Hall Jun 27 '12 at 0:45
@RHall - I am looking for mixing any 4 colors in CIELab format. See link in my question to find out more details about conversion. To answer your questions: (1) No RGB Color Space; (2) any 4 CIELab values – user1585 Jun 27 '12 at 1:12
Your link is inaccurate, but regardless I'm asking to determine why you mention you began with RGB values, Lab is a simple cartesian coordinate system, although perceptually non-uniform is a regularly used color space. The issue here is if the colors make up a device dependent color gamut. RGB color spaces make up device dependent and device independent gamuts, CIE Lab does not, but is an interim exchange space. – R Hall Jun 27 '12 at 1:41
@RHall - Okay then, so PLEASE show me how to mix any 4 colors (in RGB) to get realistic human color mix. Most of codes I tested lead to white/gray/black unrealistic mix. THANK YOU. Also please consider to edit Wikipedia page you believe is inaccurate. – user1585 Jun 27 '12 at 17:42

Could you mix them in RGB and then convert?

helper[x_] := If[((x) > 0.00885645), (x^(1/3)), (7.787*(x) + 0.137931)];
RGBToLAB[RGBColor[r_, g_, b_]] := Module[
    {x, y, z, fy}, 
    {x, y, z} = {{0.412387, 0.357592, 0.180451}, 
        {0.212637, 0.715183, 0.0721803}, {0.0193306, 0.119197, 0.950372}}.{r, g, b};
        x = x/.950429; z = z/1.0889; fy = helper[y];
        .01*{116*fy - 16, 500*(helper[x] - fy), 200*(fy - helper[z])}

enter image description here

share|improve this answer

You should first convert the colors in CIE XYZ, which is a linear space.

How do you want to mix them?

  • If the mixture is an average, the sum of your weights should be equal to 1
  • If it's an additive mixture, each color weight will vary between 0 & 1

You just multiply each color XYZ's by their weight and sum; this will give you the XYZ coordinate of the resulting color. Then you can convert back your XYZ to Lab.

share|improve this answer

Your Answer


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