Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calculating RGBA given different RGB colours.

Posted on 2010-08-26
4
Medium Priority
?
252 Views
Last Modified: 2012-05-10
Hello,

I have three RGB colours, background, foreground and target. The target colour is always between the background and foreground colours. Now, given these three RGB colours, I want to find out what the alpha channel of the foreground colour should be to give the closest approximation of the target colour that only had the RGB channels.

Any ideas on where I can even start this thing???

Thanks,
Uni
0
Comment
Question by:Unimatrix_001
  • 3
4 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 33532897
depending n how you define closest, it may be
(rt+gt+bt)-(rb+gb+bb)/((rf+gf+bf)-(rb+gb+bb))
or
((rt-rb)/(rf-rb)+(gt-gb)/(gf-gb)+(bt-bb)/(bf-bb))/3
perhaps with gamma or other correction
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 33533637
Hi ozo,

Very sorry for not getting back sooner, thanks very much - I'll give them a go this evening and let you know how things are.

Thanks again,
Uni
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 33534928
Very well done ozo... I really am jealous how you seems to just know how to solve any maths issue... :(
0
 
LVL 3

Author Closing Comment

by:Unimatrix_001
ID: 33534929
Brilliant!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Suggested Courses

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question