• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

Calculating RGBA given different RGB colours.

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
Unimatrix_001
Asked:
Unimatrix_001
  • 3
1 Solution
 
ozoCommented:
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
 
Unimatrix_001Author Commented:
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
 
Unimatrix_001Author Commented:
Very well done ozo... I really am jealous how you seems to just know how to solve any maths issue... :(
0
 
Unimatrix_001Author Commented:
Brilliant!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now