# Colour Mixing

colin shuker
Ranch Hand
Posts: 750
Hi, I want to be able to mix colours...

I tried to do it by averaging out the components, but this doesn't work, eg R+G+B = WHITE.

Thers a thing called subtractive colour mixing, but all the examples I've seen don't give you the numbers.

I want to be able to mix say rgb=(100,200,150) with rgb=(50,60,70) and get the same result you would as when mixing paint.

Can anyone help?

Thanks

Peter van de Riet
Ranch Hand
Posts: 112
For mixing paint I think you have to take the average of the colors:
((100,200,150) + (50,60,70)) / 2 = (75, 130, 110)

BTW: mixing paint is NOT the same as mixing light like 255,0,0 (red) + 0,255,0 (green) + 0,0,255 (blue) = 255,255,255 (white)
try it yourself: take the 3 colors paint (red green blue) and paint 3 parts of a circle each with a different color, then spin the circle (using a pencil)
take the same colors and mix then with same amounts, you won't get the same color as with spinning the circle.

colin shuker
Ranch Hand
Posts: 750
Thanks, but I don't think its that simple.

Eg Green = (0,255,0) and Magenta = (255,0,255)
So they are opposite corners of the colour cube.

But when you average them out you get (127,127,127) which is a medium gray.

I might be wrong, but mixing green and magenta paint, I would not expect it to come out gray.

Any thought(s) ?

Ulf Dittmer
Rancher
Posts: 42968
73

Results obtained when mixing additive colors are often counterintuitive for people accustomed to the more everyday subtractive color system of pigments, dyes, inks and other substances which present color to the eye by reflection rather than emission.

Also see Color mixing and Subtractive color.

colin shuker
Ranch Hand
Posts: 750
I figured it was subtractive colour but nothing seems to explain the math needed to do it.

Supposing I have 2 CMY or CMYK colours, how can I do the 'subtraction' ?

Thanks

Tim McGuire
Ranch Hand
Posts: 820
The last page of this PDF contains C source code for conversion of paint mixing into RGB colors:
http://threekings.tk/mirror/ryb_TR.pdf

colin shuker
Ranch Hand
Posts: 750
Thanks, so I've translated the code to java..

I'm able to convert any ryb colour into rgb colour (using the cubic interpolation)

So regarding mixing colours..
If I wanted to mix ryb1 with ryb2, would I just average out the ryb components...
ryb3 = ((r1+r2)/2, (y1+y2)/2, (b1+b2)/2), and then convert ryb3 to rgb to be displayed?

Thanks