本文介绍了Alpha混合红色,蓝色和绿色图像以产生图像着色任何rgb值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 基本上,我有一个上下文,我不能编程的图像色调,虽然我可以改变它的alpha值。通过一些实验,我发现我可以使用特定的alpha值来层叠图像的红色,蓝色和绿色版本,以产生各种颜色。然而,我想知道是否可能通过这种方法实现一个真正的RGB表示法?如果是,将RGB值转换为红色,蓝色和绿色层的不同alpha值的公式是什么。 解决方案 Alpha组合的基本方程式是: alpha *(R1,G1,B1)+(1-alpha)*(R2,G2,B2) 当你有三个alpha层的图层,你实际上是组合4层(第四个是黑色),所以最终的颜色是: alpha1 *(R1,G1,B1)+(1-alpha1)*( alpha2 *(R2,G2,B2)+(1-alpha2)* b $ b alpha3 *(R3,G3,B3)+(1-alpha2)*(0,0,0))) 如果每个图层都有相同的图片,layer1是红色通道(G1 = B1 = 0),layer2是绿色,layer3是蓝色的,你会得到: (alpha1 * R,(1-alpha1)* alpha2 * G,(1-alpha1)*(1-alpha2)* alpha3 * / code> 对于白色像素,您可以做任何可能的颜色。对于黑色像素,你不能做任何东西,但黑色。对于任何其他像素,您受到R,G和B的值的限制。 假设您想在一个像素处实现(Rd,Gd,Bd)当前颜色为(R,G,B),则您必须选择: alpha1 = Rd / R alpha2 = Gd /(G *(1-alpha1)) alpha3 = Bd /(B *(1-alpha1)*(1-alpha2)) R,那么你可以做什么。 pre> $ b 如果您可以控制混合功能(例如,在Photoshop中),您可以做得更好。 Basically, I have a context where I can't programatically tint an image, though I can change it's alpha value. With some experimentation, I've found that I can layer a red, blue, and green version of the image, with specific alpha values, to produce a wide range of colors. However, I am wondering if it's possible to achieve a true RGB representation through this method? If so, what is the formula for converting an RGB value into different alpha values for the red, blue, and green layers. 解决方案 The basic "equation" of alpha combination is:alpha * (R1,G1,B1) + (1-alpha) * (R2,G2,B2)When you have three layers with alpha you are actually combining 4 layers (the 4th one is black) so the final color is:alpha1 * (R1,G1,B1) + (1-alpha1) * ( alpha2 * (R2,G2,B2) + (1-alpha2) * ( alpha3 * (R3,G3,B3) + (1-alpha2) * (0,0,0) ) )Provided you have the same image on each layer and layer1 is the red channel (G1=B1=0) and layer2 is green and layer3 is blue you get:(alpha1 * R, (1-alpha1)*alpha2 * G, (1-alpha1)*(1-alpha2)*alpha3 * B)For a white pixel you can do any possible color. For a black pixel you cannot do anything but black. For any other pixel, you are restricted by the values of R, G and B.Say you wanted to achieve (Rd, Gd, Bd) at a pixel where the current color is (R, G, B) then you would have to choose:alpha1 = Rd/Ralpha2 = Gd/(G*(1-alpha1))alpha3 = Bd/(B*(1-alpha1)*(1-alpha2))The problem is that alpha can typically only be between 0 and 1. So, for example, if Rd > R there is nothing you can do.You can do better if you can control the blending function (for example, in Photoshop). 这篇关于Alpha混合红色,蓝色和绿色图像以产生图像着色任何rgb值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!