Mixing two RGB color vectors to get resultant

前端 未结 4 1678
粉色の甜心
粉色の甜心 2020-12-06 05:28

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 \"re

4条回答
  •  再見小時候
    2020-12-06 05:47

    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?

提交回复
热议问题