Photoshop 中的色相/饱和度调整图层算法
有谁知道 Photoshop 中的调整图层是如何工作的?我需要生成一个结果图像,其中包含来自色相/饱和度调整图层的源图像和 HSL 值。转换为 RGB 然后与源颜色相乘不起作用。
或者是否可以用正常图层替换色相/饱和度调整图层并适当设置混合模式(多重,屏幕,色相,饱和度,颜色,亮度,...)? 如果是这样那怎么办?
谢谢
Does anyone know how adjustment layers work in Photoshop? I need to generate a result image having a source image and HSL values from Hue/Saturation adjustment layer. Conversion to RGB and then multiplication with the source color does not work.
Or is it possible to replace Hue/Saturation Adjustment Layer with normal layers with appropriately set blending modes (Mulitiply, Screen, Hue, Saturation, Color, Luminocity,...)?
If so then how?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我已经对选中“着色”复选框时的计算进行了逆向工程。下面的所有代码都是伪代码。
输入为:
HSV(photoshop_hue, 100, 100).ToRGB()
photoshop_saturation / 100.0
(即 0..1)photoshop_lightness / 100.0
(即 -1..1) 1)pixel.ToHSV().Value
,缩放至 0..1 范围。对单个像素着色的方法:
其中
blend2
和blend3
是:I've reverse-engineered the computation for when the "Colorize" checkbox is checked. All of the code below is pseudo-code.
The inputs are:
HSV(photoshop_hue, 100, 100).ToRGB()
photoshop_saturation / 100.0
(i.e. 0..1)photoshop_lightness / 100.0
(i.e. -1..1)pixel.ToHSV().Value
, scaled into 0..1 range.The method to colorize a single pixel:
Where
blend2
andblend3
are:我已经弄清楚了Lightness是如何工作的。
输入参数亮度b在[0, 2]中,输出为c(颜色通道)。
一些测试:
但是,如果您选择某个间隔(例如红色而不是主色),亮度的表现完全不同,更像饱和度。
I have figured out how Lightness works.
The input parameter brightness b is in [0, 2], Output is c (color channel).
Some tests:
However, if you choose some interval (e.g. Reds instead of Master), Lightness behaves completely differently, more like Saturation.
Photoshop,不知道。但理论通常是:通过特定层的内部方法将RGB图像转换为HSL/HSV;然后根据指定的参数修改每个像素的 HSL,并将所得结果以 RGB 形式返回(用于显示)。
PaintShopPro7 用于以 30° (IIRC) 的离散增量分割 H 空间(假设范围为 0..360),因此如果仅碰撞“黄色”,即仅 H 分量值为 45-75 的像素,被考虑进行操纵。
红色 345..15、橙色 15..45、黄色 45..75、黄绿色 75..105、绿色 105..135 等。
还有其他可能性,例如应用衰减滤镜,如下所示:
Photoshop, dunno. But the theory is usually: The RGB image is converted to HSL/HSV by the particular layer's internal methods; each pixel's HSL is then modified according to the specified parameters, and the so-obtained result is being provided back (for displaying) in RGB.
PaintShopPro7 used to split up the H space (assuming a range of 0..360) in discrete increments of 30° (IIRC), so if you bumped only the "yellows", i.e. only pixels whose H component was valued 45-75 would be considered for manipulation.
reds 345..15, oranges 15..45, yellows 45..75, yellowgreen 75..105, greens 105..135, etc.
There are alternative possibilities, such as applying a falloff filter, as in:
你好,我写了着色着色器,我的方程如下
inputRGB 是源图像,应该是单色
colorRGB 是你的目标颜色
FinalRGB是结果
伪代码:
我认为它快速高效
Hello I wrote colorize shader and my equation is as folows
inputRGB is the source image which should be in monochrome
colorRGB is your destination color
finalRGB is the result
pseudo code:
I think it's fast and efficient
如果有人需要的话,我确实将@Roman Starkov解决方案翻译成java,但由于某种原因它效果不太好,然后我开始阅读一点,发现解决方案非常简单,有两件事必须完成:
https://www.w3.org/TR/compositing-1/#backdrop< /a>
在 Photoshop 中更改亮度时,滑块会指示我们需要在原始亮度上添加或减去多少百分比,才能在 HSL 中获得白色或黑色。
例如 :
如果原始像素亮度为 0.7,亮度滑块 = 20
所以我们需要更多的 0.3 亮度才能达到 1,
所以我们需要添加到原始像素亮度:0.7 + 0.2*0.3;
这将是新像素的新混合亮度值。
@Roman Starkov解决方案Java实现:
I did translate @Roman Starkov solution to java if any one needed, but for some reason It not worked so well, then I started read a little bit and found that the solution is very simple , there are 2 things have to be done :
When changing the hue or saturation replace the original image only hue and saturation and the lightness stay as is was in the original image this blend method called 10.2.4. luminosity blend mode :
https://www.w3.org/TR/compositing-1/#backdrop
When changing the lightness in photoshop the slider indicates how much percentage we need to add or subtract to/from the original lightness in order to get to white or black color in HSL.
for example :
If the original pixel is 0.7 lightness and the lightness slider = 20
so we need more 0.3 lightness in order to get to 1
so we need to add to the original pixel lightness : 0.7 + 0.2*0.3;
this will be the new blended lightness value for the new pixel .
@Roman Starkov solution Java implementation :
选中“着色”复选框后,底层的亮度将与色相和饱和度滑块的值相结合,并根据 https://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL 。 (亮度滑块只是将亮度重新映射到比例的子集,正如您从直方图中看到的那样;效果非常糟糕,我不明白为什么有人会使用它。)
When the “Colorize” checkbox is checked, the lightness of the underlying layer is combined with the values of the Hue and Saturation sliders and converted from HSL to RGB according to the equations at https://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL . (The Lightness slider just remaps the lightness to a subset of the scale as you can see from watching the histogram; the effect is pretty awful and I don’t see why anyone would ever use it.)