【问题标题】:Algorithm behind the shadow/highlight filter in photoshopPhotoshop中阴影/高光滤镜背后的算法
【发布时间】:2023-12-29 07:57:01
【问题描述】:

我对 Photoshop 中的阴影/高光滤镜非常感兴趣。有人对阴影/高光滤镜背后的算法有任何想法吗?

【问题讨论】:

  • 我猜它使用Radius 来确定它所应用的区域的位置或大小。在阴影的情况下,它会通过Amount 提高亮度。然后Tonal Range 指定像素在不再被视为增亮候选之前可能距离多远(以亮度计)。 Highlights 则相反。

标签: algorithm photoshop highlight shadow


【解决方案1】:

我制作了一个 10 步长的各种色调的楔形,并为您检查了阴影和高光设置中阴影的各种值,并为电影制作了动画,这样您就可以看到直方图是如何移动的......

您可以看到随着Amount 的增加,第二个直方图条向右移动得越多。随着Tone 的增加,越来越多的不同阴影色调受到影响。

【讨论】:

  • 非常感谢。我找到了阴影/高光滤镜的替代解决方案。
  • 你能分享你的解决方案吗?
  • 很想知道您也找到了什么解决方案。谢谢!
【解决方案2】:

虽然不准确,但模仿得很好。

lumR = 0.299;
lumG = 0.587;
lumB = 0.114;

// we have to find luminance of the pixel
// here 0.0 <= source.r/source.g/source.b <= 1.0 
// and 0.0 <= luminance <= 1.0

luminance = sqrt( lumR*pow(source.r,2.0) + lumG*pow(source.g,2.0) + lumB*pow(source.b,2.0));



// here highlights and and shadows are our desired filter amounts
// highlights/shadows should be >= -1.0 and <= +1.0
// highlights = shadows = 0.0 by default
// you can change 0.05 and 8.0 according to your needs but okay for me

h = highlights * 0.05 * ( pow(8.0, luminance) - 1.0 );
s = shadows * 0.05 * ( pow(8.0, 1.0 - luminance) - 1.0 );

output.r = source.r + h + s;
output.g = source.g + h + s;
output.b = source.b + h + s;

【讨论】:

    【解决方案3】:
    1. 使用 50% 的灰色背景创建新的图层混合模式“柔光”。
    2. 按 4% 选择“画笔”。
    3. 按“D” 黑色的影子。白色 - 突出显示。要快速更改第二种颜色 - 按“X”

    我希望这是你想要的

    【讨论】:

    • 感谢您的宝贵指导。我找到了阴影/高光滤镜的替代解决方案。