如何在手动“叠加”中处理alpha混合操作? [英] How to handle alpha in a manual "Overlay" blend operation?

查看:180
本文介绍了如何在手动“叠加”中处理alpha混合操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩一些手动(步行像素)图像处理,我正在重新创建标准的覆盖混合。我在这里查看Photoshop数学宏:

http://www.nathanm.com/photoshop-blending-math/
另请参阅这里了解更多可读版本的Overlay)



这两个源图像都处于相当标准的RGBA每个8位)格式,就像目的地一样。当两幅图像完全不透明时(alpha为1.0),结果如预期般正确混合:

但如果我的混合图层(顶部图像)具有透明度对于如何正确地将该alpha分解为混合等式,我有点fl ed不安。我期望它能够工作,使得混合图层中的透明像素对结果没有影响,混合图层中的不透明像素按正常方式进行叠加混合,而半透明混合图层像素对结果具有一定比例效果。



有人可以向我解释混合方程式或背后的概念吗?

积分如果你可以帮助我这样做,使得生成的图像正确地预乘alpha(这只对在两层中不透明的像素起作用,我认为。)



感谢!

  // blendLayerA中的因子,(1-blendLayerA)莫名其妙? 
resultR = ChannelBlend_Overlay(baseLayerR,blendLayerR);
resultG = ChannelBlend_Overlay(baseLayerG,blendLayerG);
resultB = ChannelBlend_Overlay(baseLayerB,blendLayerB);
resultA = 1.0; //还有,这应该是什么?


解决方案

只是一个猜测,但我会尝试

  resultA = 1  - (1-baseAlpha)*(1-blendAlpha)


I'm playing with some manual (walk-the-pixels) image processing, and I'm recreating the standard "overlay" blend. I'm looking at the "Photoshop math" macros here:

http://www.nathanm.com/photoshop-blending-math/ (See also here for more readable version of Overlay)

Both source images are in fairly standard RGBA (8 bits each) format, as is the destination. When both images are fully opaque (alpha is 1.0), the result is blended correctly as expected:

But if my "blend" layer (the top image) has transparency in it, I'm a little flummoxed as to how to factor that alpha into the blending equation correctly. I expect it to work such that transparent pixels in the blend layer have no effect on the result, opaque pixels in the blend layer do the overlay blend as normal, and semitransparent blend layer pixels have some scaled effect on the result.

Can someone explain to me the blend equations or the concept behind doing this?

Bonus points if you can help me do it such that the resulting image has correctly premultiplied alpha (which only comes into play for pixels that are not opaque in both layers, I think.)

Thanks!

// factor in blendLayerA, (1-blendLayerA) somehow?
resultR = ChannelBlend_Overlay(baseLayerR, blendLayerR); 
resultG = ChannelBlend_Overlay(baseLayerG, blendLayerG);
resultB = ChannelBlend_Overlay(baseLayerB, blendLayerB);
resultA = 1.0; // also, what should this be??

解决方案

Just a guess, but I would try

resultA = 1 - (1-baseAlpha) * (1-blendAlpha)

这篇关于如何在手动“叠加”中处理alpha混合操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆