[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • 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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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