混合两个 RGB 颜色向量以获得结果 [英] Mixing two RGB color vectors to get resultant

查看:35
本文介绍了混合两个 RGB 颜色向量以获得结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试混合两个源 RGB 向量来创建第三个合成向量",它是前两个的直观混合.

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

理想情况下,我将能够模拟真实的油漆混合特性",但为了简单起见,我试图找到一种方法,使结果直观地看起来像您通过组合两个源 rgb 得到的结果.

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)

--

我目前正在通过添加两个源 RGB 向量/255,然后归一化(并乘以 255)来以懒惰的方式"执行此操作.所以,使用这个: [Red = <1,0,0> * 255] + [Blue = <0,0,1> * 255] 给出 Magenta=<1,0,1>/sqrt(2)* 255,虽然其他颜色不太直观甚至不可见......我需要一个更好的方法!请帮忙:-)

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 :-)

推荐答案

您建议的与加权平均值相同吗?

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

w 是加权分数,它们的总和为 1.

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

例如,R1 是要混合的第一种颜色的红色分量.

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?

这篇关于混合两个 RGB 颜色向量以获得结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆