Reputation: 33
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 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.
Upvotes: 1
Views: 2736
Reputation: 2096
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.
Upvotes: 1
Reputation: 546025
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:
C3 = (C1 + C2) / 2
C2 = (C3 * 2) - C1
Upvotes: 3
Reputation: 39833
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.
Upvotes: 0
Reputation: 60065
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'
Upvotes: 3