问题描述
我将几个photoshop元素映射到CIFilter,唯一一个我遇到问题的是这个级别调整:
I'm mapping several photoshop elements to CIFilter, the only one I'm having trouble with is this Levels Adjustment:
哪个CI过滤器(或过滤器的组合)可以让我利用16,1.73,239&第一个例子中的39/245或者第二个例子中的31,1.25,255 30/255。我相信这是一种阴影/黑白水平调整。
Which CI Filter (or combination of filters) would let me utilize the 16, 1.73, 239 & 39/245 above in the first example or the 31, 1.25, 255 30/255 in the second example. I believe this is a kind of shadow/black and white level adjustment.
任何帮助表示感谢。
推荐答案
通过调整此页面中的公式:,我相信你可以使用 CIColorMatrix
, CIGammaAdjust的组合来做到这一点
和另一个 CIColorMatrix
。
By adapting the formula from this page: http://http.developer.nvidia.com/GPUGems/gpugems_ch22.html, I believe you can do this using a combination of CIColorMatrix
, CIGammaAdjust
and another CIColorMatrix
.
让我们调用输入级别 inBlack
, inGamma
和 inWhite
,输出等级 outBlack
和 outWhite
。请注意,Photoshop颜色介于0到255之间,而CI颜色介于0和1之间,因此您需要将Photoshop值(除了 inGamma
!)除以255,然后再将它们放入以下公式。
Let's call the input levels inBlack
, inGamma
and inWhite
respectively, and the output levels outBlack
and outWhite
. Note that Photoshop color are between 0 and 255 while CI colors are between 0 and 1 so you need to divide the Photoshop values (except inGamma
!) by 255 before putting them into the following formulas.
输入映射是 pixel =(inPixel-inBlack)/(inWhite-inBlack)
,其中意味着你的第一个矩阵将是
The input mapping is pixel = (inPixel-inBlack)/(inWhite-inBlack)
, which means your first matrix will be
red = [1/(inWhite-inBlack) 0 0 0]
green = [0 1/(inWhite-inBlack) 0 0]
blue = [0 0 1/(inWhite-inBlack) 0]
alpha = [0 0 0 1]
bias = [-inBlack/(inWhite-inBlack), -inBlack/(inWhite-inBlack),-inBlack/(inWhite-inBlack), 0]
然后使用 CIGammaAdjust
和 inGamma
编号应用伽马校正(我必须使用反算 1 / inGamma
进行计算时,也试试!)。
Then you apply gamma correction using CIGammaAdjust
and the inGamma
number (I had to use the inverse 1/inGamma
when doing my calculations, try that too!).
最后输出映射是pixel = gammaCorrectedPixel *(outWhite - outBlack)+ outBlack
,为您提供最终矩阵
Finally the output mapping is pixel = gammaCorrectedPixel * (outWhite - outBlack) + outBlack
, giving you the final matrix
red = [(outWhite - outBlack) 0 0 0]
green = [0 (outWhite - outBlack) 0 0]
blue = [0 0 (outWhite - outBlack) 0]
alpha = [0 0 0 1]
bias = [outBlack outBlack outBlack 0]
我实际上并没有尝试使用CoreImage,但计算效果很好!
I haven't actually tried this using CoreImage, but the calculations work out nicely!
这篇关于如何将Photoshop的水平调整映射到Core Image过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!