Alpha 混合红色、蓝色和绿色图像以生成着色为任何 RGB 值的图像?
基本上,我有一个上下文,我无法以编程方式对图像进行着色,尽管我可以更改它的 alpha 值。通过一些实验,我发现我可以使用特定的 alpha 值对图像的红色、蓝色和绿色版本进行分层,以产生各种颜色。但是我想知道是否可以通过这种方法实现真正的RGB表示?如果是这样,将 RGB 值转换为红色、蓝色和绿色层的不同 alpha 值的公式是什么?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Alpha 组合的基本“方程”是:
当您有 3 个带有 Alpha 的图层时,您实际上组合了 4 个图层(第 4 个是黑色),因此最终颜色是:
假设每个图层上都有相同的图像,并且第 1 层是红色通道 (G1=B1=0) 且第 2 层为绿色,第 3 层为蓝色,您将得到:
对于白色像素,您可以采用任何可能的颜色。对于黑色像素,除了黑色之外你什么也做不了。对于任何其他像素,您都受到 R、G 和 B 值的限制。
假设您想在当前颜色为 (R, G, B) 的像素处实现 (Rd, Gd, Bd),那么您必须选择:
问题是 alpha 通常只能在 0 和 1 之间。因此,例如,如果 Rd > R 你无能为力。
如果您可以控制混合功能(例如在 Photoshop 中),您可以做得更好。
The basic "equation" of alpha combination is:
When you have three layers with alpha you are actually combining 4 layers (the 4th one is black) so the final color is:
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:
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:
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).
如果我理解正确的话,我认为这是不可能的。
如果对于某个像素,图像的红色值为 0.5,则可以将其与(典型)范围 [0,1] 中的 alpha 结合起来,形成 0.5 以内的任何值(包括 0.5),但不能继续上面,得到例如 0.6 左右的输出值。
I don't think that's possible, if I understand you correctly.
If, for a certain pixel, your image's red value is, say, 0.5, you can combine that with an alpha in the (typical) range [0,1] to form any value up to and including 0.5, but you can't go above, to get e.g. 0.6 or so as the output value.
如果您想要创建 3 个图层,将它们混合在一起形成原始图像,这是完全有可能的。下面是一个 Python 脚本的链接,该脚本调用 Paint Shop Pro 中的函数来完成困难的部分。
http://pixelnook.home.comcast.net/~pixelnook/SplitToRGB.htm< /a>
如果您需要更多详细信息,请发表评论,我稍后会尝试填写。
If you're looking to create 3 layers that blended together add up to the original image, it's quite possible. Here's a link to a Python script that calls functions in Paint Shop Pro to do the hard parts.
http://pixelnook.home.comcast.net/~pixelnook/SplitToRGB.htm
If you need more detail than that, leave a comment and I'll try to fill it in later.