Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
25 Views

Is there an optimized way to blend to a opaque image?

Hello,

The most common type of blending of RGBA images seems to be using AlphaComp with AlphaType=OVER.

It would seem to be to be quite common at that some point your are going to blend your semi transparent image against some sort of opaque background. In that case, αB=1 so instead of the final image being   αA*A+(1- αA)* αB*B and the final alpha being αA+(1-αA)* αB , the final image αA*A+(1- αA)*B is and the final alpha is 1.

We thought that since that since this was a common scenario, there may be a more optimized way of blending against a fully opaque image that would be faster. Especially if image A is premultiplied, there is then very little work to compose it against an opaque image.

0 Kudos
3 Replies
Highlighted
Employee
25 Views

Hi David,

For your question. I personally believe it might could not bring too much performance improvement for the optimization you discussed. Although the alpha value of each pixel point would be calculated, the alpha channel only calculate once that other 3 times for RGB value. And the optimization could only help for calculating pixel alpha value, do not much helpful to RGB value. If you discuss about special conditions, I am afraid it is too complex to consider one by one, here you discuss αA =0.5, αB =1; but the alpha value for each pixel might be different. If you are using constant alpha value, you could use another interface called "AlphaCompC" which will seen alpha value as const. I believe that interface would be much suitable for your case.

Thanks.

Best regards,
Fiona

0 Kudos
Highlighted
Beginner
25 Views

Hi Fiona,

Thanks for the prompt response.

Just to be clear, I am not discussing αA =0.5, αB =1; I am simply discussing αB =1;

It does eliminate a multiplication in the RGB calculation, but I agree that is only one of several. As you said, it completely eliminates the final alpha calculation.

The only reason that this special case is warranted in my opinion, is that at the end of the day, if dealing with semi-transparent images you always have to do one last AlphaComp against a opaque background to display on screen. So even if it speeds up the calculation by 20% or something by eliminating the alpha calculation and removing one part of the RGB calculation, that may be helpful.

Anyhow, just my 2 cents.

0 Kudos
Highlighted
New Contributor II
25 Views

I also think AlphaComp lacks variants. I needed to do alpha blending in YUV one plane at a time and ended up using http://ermig1979.github.io/Simd/help/group__drawing.html#ga24392fe6c365dbb60678c9540c860e83​.  I thinks I'll eventually roll my own with https://developer.numscale.com/bsimd/documentation/v1.17.6.0/​ ; Alpha blending is actually simple.

0 Kudos