开发者

Can we find out the difference between 2 RGb colors to find out a 3rd color?

2 colors are mixed together. If i have the RGB for the resultant color and RGB for one of the colors mixed, then somehow i could calculate the 2nd color?

I will try to explain visually what i am trying to say. Here is a flickr link

http://www.flickr.com/photos/48150615@N08/4407414157

I know that the circle in the 开发者_JAVA技巧middle has an opacity of 20%

Is there any way to know the color value of the circle so that i can deduct that to get the same color value as the background color.


if i understood the task correctly...

let's do some school math

c is color of initial image, t is color of transparent color, a (for alpha) is transparency, c' is result color.

c' = (1 - a) * t + a * c

you want to find c.

c = (c' - (1 - a) * t) / a

you need to know a, t and c'


Firstly it depends how you're going to mix them. That is, you could average the RGB components (this means blue (0,0,255) + yellow (255,255,0) == grey (128,128,128)), or you could work on Hues, Saturation and Value, which often gives a much more "as expected" result.

Anyway, in either case, it's some simple maths:

  • if the way to get the average is C3 = (C1 + C2) / 2
  • then the way to find C2 is C2 = (C3 * 2) - C1


CIELAB color space is specially designed for calculating differences between colors, but it might be a overkill in you case. Probably HSV is easy solution for you.


Just subtract each component. The components are often stored in hexadecimal format, in which case you will need to convert the numbers to decimal or do hex math.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜