从Photoshop的色相/饱和度调整层的算法 [英] Algorithm for Hue/Saturation Adjustment Layer from Photoshop
问题描述
有没有人知道调整图层如何在Photoshop中工作?我需要从色相/饱和度调整层生成具有源图像和HSL值的结果图像。
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.
或者,可以使用适当设置的混合模式用正常图层替换色相/饱和度调整图层(Mulitiply ,Screen,Hue,Saturation,Color,Luminocity,...)?
如果是,那么如何?
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?
感谢
推荐答案
当选中Colorize复选框时,我已反向设计的计算。以下所有代码都是伪代码。
I've reverse-engineered the computation for when the "Colorize" checkbox is checked. All of the code below is pseudo-code.
输入是:
- hueRGB code>
- 饱和度,即
photoshop_saturation / 100.0
- lightness ,即
photoshop_lightness / 100.0
(即-1..1) - value ,这是
pixel.ToHSV()。Value
,缩放到0..1范围。 li>
HSV(photoshop_hue,100,100).ToRGB()为 <$>
- hueRGB, which is an RGB color for
HSV(photoshop_hue, 100, 100).ToRGB()
- saturation, which is
photoshop_saturation / 100.0
(i.e. 0..1) - lightness, which is
photoshop_lightness / 100.0
(i.e. -1..1) - value, which is the
pixel.ToHSV().Value
, scaled into 0..1 range.
着色单个像素的方法:
color = blend2(rgb(128, 128, 128), hueRGB, saturation);
if (lightness <= -1)
return black;
else if (lightness >= 1)
return white;
else if (lightness >= 0)
return blend3(black, color, white, 2 * (1 - lightness) * (value - 1) + 1)
else
return blend3(black, color, white, 2 * (1 + lightness) * (value) - 1)
其中 blend2
和 blend3
分别是:
blend2(left, right, pos):
return rgb(left.R * (1-pos) + right.R * pos, same for green, same for blue)
blend3(left, main, right, pos):
if (pos < 0)
return blend2(left, main, pos + 1)
else if (pos > 0)
return blend2(main, right, pos)
else
return main
这篇关于从Photoshop的色相/饱和度调整层的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!