What equation best describes the alpha content of a black colored pixel applied to a white pixel when measuring the resulting pixel intensity?
- given a white pixel: argb : 255, 255, 255, 255
- drawing over it with a black pixel: argb : 78, 0, 0, 0
- the result is argb : 255, 50.2, 50.2, 50.2
Measuring the pixel's intensity 50.2 should relate an alpha level of 78 when testing for black.
After trying for it, I settled on a rough formula ~> A = 1 - (I / 255) ^ 2.193
Here A = alpha, I = intensity. It could be 1 - I ^ 2.193 if the values for I were in the range 0 - 1. This is just a gamma function subtracted from one to orient the values correctly. For white alpha pixels applied to a black image the formula would be I ^ 2.193.
This may not be near the solution but I can't dream it up. I may have heard of this equation using a power of 2.2, maybe not. Its results are okay, but then again I also liked the results of a linear equation, happily adding 1 level of alpha for each 1 level of intensity less than 255 (white.)
I would really love to read about the science behind this alpha relationship from one of you!
Thanks to Emre my question is answered. And now that I have the solution I have added some figures to turn it into an example...
3 images ~> a sphere separated into a white part and an alpha part
Images obtained using Gamma 2.2 result and Linear result
re-applied to white layers, respectively
Graph from Wikipedia demonstrates the difference between sRGB (standard red green blue) and Gamma 2.2. Here sRGB is the red line plotting the intensity function, and Gamma 2.2 is a black dashed line drawn below the red line. Not much difference
Thus, A = 1 - I ^ 2.2, is nearly correct choice