Here is my problem:
I have a set of 'n' colors including the primary colors and their codes in hexadecimal. Now given another color 'x' I wonder if it's actually possible to come up with a mix between two or more of the colors of the set that will produce 'x'. The mix should be subtractive.
Here is an example of the result of the algorithm:
My set of colors is: c1, c2, c3, c4, c5, c6. I am trying to find the mix to produce the color x. The result could be: 50% of c1, 25% of c4 and 25% of c5.
If anyone could point me in the right direction (or at least tell me if it is unfeasible), any help would be gladly appreciated!
-
2Since you did not write if you mean additive or subtractive mixing, I guess you should first have a look here: en.wikipedia.org/wiki/Color_mixingDoc Brown– Doc Brown2013年09月02日 20:04:13 +00:00Commented Sep 2, 2013 at 20:04
-
1Related question (possibly a duplicate of) What class of problem is this, and what math do I need to know to solve it?user40980– user409802013年09月02日 20:30:58 +00:00Commented Sep 2, 2013 at 20:30
-
1A related old SO post - Mixing two RGB color vectors to get resultantuser40980– user409802013年09月03日 16:02:36 +00:00Commented Sep 3, 2013 at 16:02
-
1Paul Saski's answer contains a link to Color Models which is a recommended read.rwong– rwong2013年09月04日 06:07:59 +00:00Commented Sep 4, 2013 at 6:07
-
1More recommended reads: Stanford CS178, and Gamut on Wikipediarwong– rwong2013年09月04日 06:14:32 +00:00Commented Sep 4, 2013 at 6:14
1 Answer 1
This is a basic linear algebra problem. Let b = [ b1, b2, b3 ] be your mixed colour, x = [ x1, x2, ... xn ] be your solution, I = [ 1, 1, 1 ] (or whatever your white value is), and A = [ c1, c2, ..., cn ] be your colour set where each ci is a column vector in the matrix A. You must solve for x in the the equation I - Ax = b or Ax = I - b. You can check out the Khan Academy video about how to do that here if you do not already know how.
If there is no solution to this equation there is also no subtractive mix (obviously), but there is also no subtractive mix if there is a value in x, xi, that is negative or greater than one. If there is a negative value then you are actually adding the colour, and if there is one greater than one, you are subtracting the colour more than once. Otherwise your solution is the vector x.