This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
Photoshop 通过对图像 A 中的每个像素与图像 B 中的相应像素执行混合操作来将两个图像混合在一起。每个像素都是由多个通道组成的颜色。假设我们使用 RGB 像素,每个像素中的通道将为红色、绿色和蓝色。为了混合两个像素,我们混合它们各自的通道。
Photoshop 中每种混合模式发生的混合操作可以总结为以下宏:
要混合单个 RGB 像素,您将执行以下操作:
如果我们想要以特定的不透明度(例如 50%)执行混合操作:
如果如果您有指向图像 A、B 和 T(我们的目标)的图像数据的指针,我们可以使用此宏来简化所有三个通道的混合:
并且可以导出以下 RGB 颜色混合宏:
示例如下:
余数Photoshop 混合模式涉及将 RGB 转换为 HLS,然后再转换回来。
这些函数将有助于将 RGB 转换为 HLS。
关于这个主题还有更多资源,主要是:
Photoshop blends two images together by performing a blend operation on each pixel in image A against its corresponding pixel in image B. Each pixel is a color consisting of multiple channels. Assuming we are working with RGB pixels, the channels in each pixel would be red, green and blue. To blend two pixels we blend their respective channels.
The blend operation that occurs for each blend mode in Photoshop can be summed up in the following macros:
To blend a single RGB pixel you would do the following:
If we wanted to perform a blend operation with a particular opacity, say 50%:
If you have pointers to the image data for images A, B, and T (our target), we can simplify the blending of all three channels using this macro:
And can derive the following RGB color blend macros:
And example would be:
The remainder of the photoshop blend modes involve converting RGB to HLS and back again.
These functions will be helpful in converting RGB to HLS.
There are more resources on this topic, mainly:
这个答案中的色相、颜色、饱和度混合模式是错误的。 Adobe 产品不转换为 HSB,它们直接对 RGB 值进行运算。
以下是用于设置亮度的 GLSL,例如:
CIKernels 中不支持 if .. else 语句,因此使用三元运算符。
The Hue, Color, Saturation blending modes in this answer are wrong. No Adobe product converts to HSB, they do the operation directly on RGB values.
Here's the GLSL for setting luminosity, for example:
No support for if .. else statements in CIKernels, hence the use of ternary operators.
流行的答案是 99.9% 正确,但正如 Greyfriars 所说,它不会得到确切的结果,因为 Adobe 在混合过程中任何时候都不会使用 HLS。
但您不需要在 Adobe 工作才能做到这一点...您可以按照 Adobe 文档中的所有规则实现完全相同的混合:
基本上是第 4 章和第 7 章:
http://partners.adobe.com/public/developer/en/pdf /PDFReference.pdf
然后您将得到像 Adobe 一样的精确结果!一个像素一个像素!
The popular answer is 99.9% correct, but as Greyfriars said, it won't get the exact result because Adobe doesn't use HLS any moment in the blending.
But you don't need to be working at Adobe in order to do that... you can reach exactly the same blending following all the rules here in this document from Adobe:
basically chapters 4 and 7:
http://partners.adobe.com/public/developer/en/pdf/PDFReference.pdf
Then you will reach the exact result just like Adobe does! Pixel by Pixel!
虽然流行的答案大多是正确的,但以下陈述是错误的。 “Photoshop 混合模式的其余部分涉及将 RGB 转换为 HLS,然后再转换回来。”不,Photoshop(并且仅 Photoshop)使用 Chroma 和 Luma 而不是 HLS。
因此,对于色相、颜色、亮度和饱和度模式,您不能使用简单的算法。要在这些情况下匹配 Photoshop 的方法,您需要为 Adobe 工作。
While the popular answer is mostly correct, the following statement is wrong. "The remainder of the photoshop blend modes involve converting RGB to HLS and back again." No, Photoshop (and only Photoshop) uses Chroma and Luma instead of HLS.
So for Hue, Color, Luminosity and Saturation modes, you can't use simple algorithms. To match Photoshop's method in these cases, you need to be working for Adobe.