首页 文章

Photoshop中的色相/饱和度调整层算法

提问于
浏览
12

有谁知道调整图层在Photoshop中是如何工作的?我需要从Hue / Saturation调整图层生成具有源图像和HSL值的结果图像 . 转换为RGB然后与源颜色相乘不起作用 .

或者是否可以使用适当设置的混合模式(多重,屏幕,色调,饱和度,颜色,亮度......)将Hue /饱和度调整图层替换为普通图层?如果是这样呢?

谢谢

5 回答

  • 3

    When the “Colorize” checkbox is checked ,底层的亮度与Hue和饱和度滑块的值组合,并根据https://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL处的等式从HSL转换为RGB . (亮度滑块只是将亮度重新映射到刻度的一个子集,正如您在观看直方图时看到的那样;效果非常糟糕,我不明白为什么有人会使用它 . )

  • 1

    我已经为 when the "Colorize" checkbox is checked 反向设计了计算 . 下面的所有代码都是伪代码 .

    输入是:

    • hueRGB,这是 HSV(photoshop_hue, 100, 100).ToRGB() 的RGB颜色

    • 饱和度,即 photoshop_saturation / 100.0 (即0..1)

    • 亮度,即 photoshop_lightness / 100.0 (即-1..1)

    • 值,即 pixel.ToHSV().Value ,缩放为0..1范围 .

    着色单个像素的方法:

    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)
    

    blend2blend3 在哪里:

    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
    
  • 0

    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等 .

    if (h >= 45 && h < 75)
            s += s * yellow_percent;
    

    还有其他可能性,例如应用衰减滤波器,如:

    /* For h=60, let m=1... and linearly fall off to h=75 m=0. */
    m = 1 - abs(h - 60) / 15;
    if (m < 0)
            m = 0;
    s += s * yellow_percent * d;
    
  • 9

    我已经弄明白了 Lightness 的工作原理 .

    输入参数亮度 b 在[0,2]中,输出为 c (颜色通道) .

    if(b<1) c = b * c;
    else    c = c + (b-1) * (1-c);
    

    一些测试:

    b = 0  >>>  c = 0  // black
    b = 1  >>>  c = c  // same color
    b = 2  >>>  c = 1  // white
    

    但是,如果您选择一些间隔(例如Reds而不是Master),Lightness的行为完全不同,更像饱和度 .

  • 3

    你好我写了着色着色器,我的方程如下

    inputRGB是应该是单色的源图像

    (r+g+b) * 0.333
    

    colorRGB是您的目标颜色
    finalRGB就是结果

    伪代码:

    finalRGB = inputRGB * (colorRGB + inputRGB * 0.5);
    

    我认为它快速有效

相关问题