简体   繁体   English

Photoshop选择性滤色镜背后的数学/算法是什么?

[英]What's the Math / Algorithm Behind Photoshop's Selective Color Filter?

I'm working on an image-processing software on iPhone and get stuck in the selective color function as photoshop. 我正在研究iPhone上的图像处理软件,并陷入了Photoshop的可选色彩功能中。

How to caculate new RGB values after selective color adjustment on a pixel via code? 通过代码对像素进行选择性颜色调整后,如何计算新的RGB值?

I mean how to create a tool which has the same function as Photoshop's selective color(In Image->Adjustment->Selective Color). 我的意思是如何创建一种与Photoshop的选择性颜色具有相同功能的工具(在“图像”->“调整”->“选择性颜色”中)。

Special thx! 特别感谢!

Finally I sampled data of images which have be processed by photoshop, and got a quadratic curve with hue. 最后,我对经过Photoshop处理的图像数据进行了采样,得到了具有色相的二次曲线。 But it is not exactly the same as photoshop's. 但这与photoshop并不完全相同。

I have come across a code which uses image buffer to manipulate alpha of an image but the same can be used to manipulate rgb as well see this link 我遇到了一个使用图像缓冲区来处理图像的Alpha的代码,但是同样可以用于处理rgb,请参见此链接

See this sample it will give a general idea of image manipulation in objective c 看到此示例,它将给出物镜c中图像处理的一般概念

I too am trying to understand the math. 我也想了解数学。 Here are some observations from experiments with pure colors in "Absolute" mode, which as an end user is all I care about 以下是在“绝对”模式下使用纯色进行实验的一些观察结果,作为最终用户,我只关心这些

1) As expected, adding the opposite of any color turns the starting color black. 1)如预期的那样,添加任何颜色的相反颜色会将初始颜色变为黑色。 So 100% red + 100% cyan = black 因此100%红色+ 100%青色=黑色

2) Adding neighboring color does nothing. 2)添加相邻颜色无济于事。 So 100% red + any amount of yellow or magenta = 100% red 因此100%红色+任意数量的黄色或品红色= 100%红色

3) Adding triadic colors converts the primary color into a neighboring. 3)添加三色系颜色会将原色转换为相邻色。 So 100% red + 100% green = 100% yellow 因此100%红色+ 100%绿色= 100%黄色

In RGB space this translates to something like 在RGB空间中,这转化为类似

|r'|   |1, 0, 1, 1, 1, 0|   |r|
|y'|   |0, 1, 0, 1, 1, 1|   |y|
|g'|   |1, 0, 1, 0, 1, 1|   |g|
|c'| = |1, 1, 0, 1, 0, 1| * |c|
|b'|   |1, 1, 1, 0, 1, 0|   |b|
|m'|   |0, 1, 1, 1, 0, 1|   |m|

There is of course the adjustments for clipping, and black to white. 当然,有剪裁和黑到白的调整。 Here is a more mathy discussion 这是一个更数学的讨论

http://blog.pkh.me/p/22-understanding-selective-coloring-in-adobe-photoshop.html http://blog.pkh.me/p/22-understanding-selective-coloring-in-adobe-photoshop.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM