Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixing two RGB color vectors to get resultant

I am trying to mix two source RGB vectors to create a third "resultant vector" that is an intuitive mix of the first two.

Ideally, I would be able to emulate "real paint mixing characteristics", but for simplicity, I am trying to find a method where the resultant looks intuitively like what you'd get from combining the two source rgb's.

minimally, these characteristics:
RED + BLACK = DARK RED
RED + WHITE = LIGHT RED

optimally, also with real paint characteristics:
RED + BLUE = PURPLE
RED + YELLOW = ORANGE
(etc)

--

I am currently doing this the "lazy way" by adding the two source RGB vectors/255, then normalizing (and multiplying by 255). So, using this: [Red = <1,0,0> * 255] + [Blue = <0,0,1> * 255] gives Magenta=<1,0,1>/sqrt(2) * 255, though the other colors are less intuitive or even visible... I need a better method! Please help :-)

like image 912
yos Avatar asked Dec 12 '09 02:12

yos


People also ask

How do you combine RGB colors?

If you mix red, green, and blue light, you get white light. Red, green, and blue (RGB) are referred to as the primary colors of light. Mixing the colors generates new colors, as shown on the color wheel or circle on the right. This is additive color.

What happens when you mix RGB?

Red , green , and blue (RGB) are the primary colors of lights, and when they're combined, they make white .

How many color combinations are possible with RGB?

RGB Color Values Each parameter (red, green, and blue) defines the intensity of the color with a value between 0 and 255. This means that there are 256 x 256 x 256 = 16777216 possible colors!

When all colors of the RGB color model are combined What color is produced?

Additive Color The additive colors are red, green and blue, or RGB. Additive color starts with black and adds red, green and blue light to produce the visible spectrum of colors. As more color is added, the result is lighter. When all three colors are combined equally, the result is white light.


2 Answers

Is what you suggested the same as a weighted average?

Average R = w1*R1 + w2*R2 + w3*R3 + ... + wn*Rn

Average G = w1*G1 + w2*G2 + w3*G3 + ... + wn*Gn

Average B = w1*B1 + w2*B2 + w3*B3 + ... + wn*Bn

The w's are the weighting fractions and the sum of them is 1.

R1 is the red component of the first color to mix, for example.

So if you wanted to mix two colors evenly, it would be:

Average R = 0.5*R1 + 0.5*R2

Average G = 0.5*G1 + 0.5*G2

Average B = 0.5*B1 + 0.5*B2

As for mapping the resultant color to a named color ("dark red") maybe just do a lookup table and pick the closest one?

like image 62
John Avatar answered Sep 24 '22 14:09

John


The problem is that you're trying to relate two different color theories. RGB is additive color theory (colored light is emitted from the source). In this case the more of the spectrum you add to the mix, the closer you get to white.

For "paint mixing" you need to emulate subtractive color theory which governs the way reflected colors are mixed. (i.e. reflected light such as paints, different surfaces etc.) Here's an overview.

The JavaScript on this page is a clue as to how you might proceed in converting RGB to CMYK.

like image 27
Paul Sasik Avatar answered Sep 21 '22 14:09

Paul Sasik