3
$\begingroup$

my question is if i have only 3 basic colors (each made of rgb):

color1 : R:150, B:zero, G:255 color2 : R:255, B:150, G:zero color3 : R:zero, B:255, G:150 

  They can be mixed using the formula :

new_color = floor(X*0.9)+floor(Y*0.1) 

X and Y can be a basic color or a new color already created by using the formula.   for example, if i want to mix color1 as main with color3 :

new_color(R,B,G) = (floor(0.9*150)+floor(0.1*0) , floor(0.9*0)+floor(0.1*255) , floor(0.9*255)+floor(0.1*150) ) = (135, 25, 244). 

  I need to find a way to mix many colors in order to get a desired color, for example : R:187 B:135 G:201 so far i wrote a "brute force" program which go all over the combinations of basic colors (runing for 7 days now got up to 16 mixing steps) and a bit smarter AStar algorithm (got good reults for small sequnces, letting it run for the week end...). Since i know some colors are made of more then 100 mixing steps, it will take me forever to go over all of the results...   Help me find a smarter and faster way to solve this.

Thanks.

  • 0
    1. Should all intermediate and final colors consist only of two colors mixed using the linear combination `0.9 * [ x1.R x1.G x1.B ] + 0.1 * [ x2.R x2.G x2.B ]`? 2. Or is it possible to replace the scaling factors (scalars) `0.9` and `0.1` with some other values, say `a` and `b`: `a * [ x1.R x1.G x1.B ] + b * [ x2.R x2.G x2.B ]` ? 3. If answer to 2 is yes, do `a` and `b` have have a sum of `1` ? 4. Is it possible to mix directly more than two colors and by which scaling ratios?2012-06-15
  • 3
    The question would be easier to follow if OP followed the usual convention that (RGB) triples are printed in that order (rather than (RBG)) and of using '0' in place of 'zero'.2012-06-15
  • 0
    Scaling factors cannot be changed, you can mix directly only 2 colors, basic ones or colors created by the formula.2012-06-15
  • 0
    You can use rgb, zero was written istead of 0 because someforums convert0 to smily.2012-06-15
  • 0
    As defined your function (call it `mix`) is not (quite) *idempotent*. For example, with `color1 = [150,255,0]`, `mix(color1,color1)` results in `[150,254,0]`. I would expect a colour mixing function to be idempotent; yours would be if you replaced `floor(0.9x)+floor(0.1y)` with `floor(0.9x+0.1y)`. Is your function deliberately not idempotent ?2012-06-15
  • 0
    Yes, it is deliberately not idempotent.2012-06-15
  • 0
    Mix (color1,color1) should give [150, 254, 0].2012-06-15
  • 0
    it would help if you could show your basis colors2012-06-15
  • 0
    Look at the begining...2012-06-15
  • 0
    I thought so. Your problem doesn't have a solution: for instance, it is impossible to get [255 255 255]. Either expand you basic colors, or accept certain colors are unobtainable.2012-06-15
  • 0
    You can expand the basic colors int new ones created by the formula.2012-06-16
  • 0
    You cant get [255 255 255] but you can get many other colors, the color i wrote in the question is reachable.2012-06-16
  • 1
    @user1458131 I'm not sure what your understanding is of basic linear algebra, but i gave you one example to explain that many solutions are unreachable ([254 0 0] is another). If your not looking for a brute force approach (which you can add some intelligence to), you may have better luck in the math stack exchange given the complexity of your space, the fact that your operator is non-linear, and that your basis doesn't span the entire space. Remember, Matlab is just a means to an end. You're problem isn't programming, it's trying to find a workable solution to a topological space2012-06-16
  • 0
    Rasman, Thanks for your answer.2012-06-16
  • 0
    As i wrote, im using a simple brute force code and also AStar, If you can direct me to a smarter way it would be great.Thanks again.2012-06-16

1 Answers 1