Click here to Skip to main content
15,914,642 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Color mixing algorithm Pin
Kobi_Z12-Jul-12 21:15
Kobi_Z12-Jul-12 21:15 
AnswerRe: Color mixing algorithm Pin
Luc Pattyn17-Jun-12 8:05
sitebuilderLuc Pattyn17-Jun-12 8:05 
GeneralRe: Color mixing algorithm Pin
Kobi_Z17-Jun-12 9:05
Kobi_Z17-Jun-12 9:05 
GeneralRe: Color mixing algorithm Pin
Luc Pattyn17-Jun-12 9:10
sitebuilderLuc Pattyn17-Jun-12 9:10 
GeneralRe: Color mixing algorithm Pin
BupeChombaDerrick17-Jun-12 13:43
BupeChombaDerrick17-Jun-12 13:43 
GeneralRe: Color mixing algorithm Pin
Kobi_Z26-Jun-12 7:12
Kobi_Z26-Jun-12 7:12 
GeneralRe: Color mixing algorithm Pin
BupeChombaDerrick26-Jun-12 14:22
BupeChombaDerrick26-Jun-12 14:22 
AnswerRe: Color mixing algorithm Pin
YvesDaoust18-Jun-12 20:50
YvesDaoust18-Jun-12 20:50 
In terms of algebra, your question is ill posed. You are in 3D space (the RGB cube). All possible mixtures of the two colors form a line segment (a whole straight line if you allow negative values of the mixing coefficients).

(In this discussion, I admit that the mixture constraint X + Y = 1 is enforced, which you didn't mention.)

Unless by coincidence, there is no reason that your third color belongs to the segment(or the line). You get a system of three equations in one unknown, usually without a solution.

To handle this we can look for the "best approximation", i.e. the mixture that will minimize the discrepancy with the desired color. Even though it is not recognized as "perceptually uniform", you can use the Euclidean distance.

In other words, you will project the desired color to the line segment by means of an orthogonal projection.

Let X C0 + (1-X) C1 be a color between C0 and C1. The vector from this point to C2 needs to be perpendicular to the direction C0C1. Hence, (X C0C2 + (1 - X) C1C2).C0C1 = 0 (. is the dot product). I.e. X C0C2.C0C1 + (1 - X) C1C2.C0C1 = 0, or X = C1C2.C0C1 / (C1C2.C0C1 - C0C2.C0C1) = - C1C2.C0C1 / C0C1.C0C1.

To restrict the solution to the range of positive coefficient mixtures, just clamp the value of X to the range [0..1].

Rather than a week of computation, this should take less than 100 nanoseconds in compiled code.

modified 19-Jun-12 2:59am.

QuestionAND/OR Graph Search Pin
chipchip_boy25-May-12 21:20
chipchip_boy25-May-12 21:20 
AnswerRe: AND/OR Graph Search PinPopular
Richard MacCutchan25-May-12 23:02
mveRichard MacCutchan25-May-12 23:02 
AnswerRe: AND/OR Graph Search Pin
Amarnath S3-Jun-12 21:48
professionalAmarnath S3-Jun-12 21:48 
Questionalgorithms Pin
gunjan adhikari29-Apr-12 3:21
gunjan adhikari29-Apr-12 3:21 
AnswerRe: algorithms Pin
Richard MacCutchan29-Apr-12 4:46
mveRichard MacCutchan29-Apr-12 4:46 
GeneralRe: algorithms Pin
BupeChombaDerrick29-Apr-12 11:58
BupeChombaDerrick29-Apr-12 11:58 
GeneralRe: algorithms Pin
Richard MacCutchan25-May-12 0:56
mveRichard MacCutchan25-May-12 0:56 
AnswerRe: algorithms PinPopular
Luc Pattyn10-May-12 10:49
sitebuilderLuc Pattyn10-May-12 10:49 
JokeRe: algorithms Pin
walterhevedeich10-May-12 15:49
professionalwalterhevedeich10-May-12 15:49 
AnswerRe: algorithms Pin
Luc Pattyn10-May-12 16:20
sitebuilderLuc Pattyn10-May-12 16:20 
JokeRe: algorithms Pin
Paul Conrad31-May-12 12:06
professionalPaul Conrad31-May-12 12:06 
GeneralRe: algorithms Pin
CPallini10-May-12 23:15
mveCPallini10-May-12 23:15 
GeneralRe: algorithms Pin
Pete O'Hanlon11-May-12 0:41
mvePete O'Hanlon11-May-12 0:41 
JokeRe: algorithms Pin
Paul Conrad31-May-12 12:06
professionalPaul Conrad31-May-12 12:06 
AnswerRe: algorithms Pin
Amarnath S3-Jun-12 21:43
professionalAmarnath S3-Jun-12 21:43 
QuestionExtreme Artificial Intelligence Pin
BupeChombaDerrick26-Apr-12 2:44
BupeChombaDerrick26-Apr-12 2:44 
AnswerRe: Extreme Artificial Intelligence Pin
Richard MacCutchan26-Apr-12 3:34
mveRichard MacCutchan26-Apr-12 3:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.