QC 组合将黑色和白色像素转换为其他两种颜色
我刚刚开始学习 Quartz Composer,我想要创建的第一件事是最终可以在 Cocoa 应用程序中使用的组合,该应用程序将接受黑白图像和两个 NSColor,并将黑色像素更改为 NSColor # 1 和 NSColor #2 的白色像素。
我花了一些时间研究 QC,但似乎无法弄清楚如何将所有部分组合在一起。
我唯一想到的是我需要使用图像过滤器模板,并且我确实看到有一个图像像素补丁可以从图像中获取像素...但是,我没有看到用于设置像素的补丁像素。 Pixellate 补丁似乎也是必要的……不过,我不必担心它会生成无限尺寸的图像,因为我的源图像只是固定大小的 PNG 图像。
I'm just starting to learn about Quartz Composer and the first thing I would like to create is a composition that could eventually be used in a Cocoa application which would accept a black and white image and two NSColor's and change the black pixels to NSColor #1 and the white pixels to NSColor #2.
I've spent some time playing with QC, but cannot seem to figure out how to put all of the pieces together.
About the only thing I have figured out is that I need to use the Image Filter template and I do see there is a Image Pixel patch that can get pixels from an image...however, I don't see a patch to set a pixel. It also seems possible the Pixellate patch might be necessary...although, I shouldn't have to worry about it producing an image with infinite dimensions since my source images will only be fixed size PNG images.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下
False Color
补丁 - 它获取图像并用一对颜色重新映射它。事实上,由于
False Color
补丁只是具有相同名称 (CIFalseColor
) 的 Core Image 过滤器的包装,因此您可以在不涉及 Quartz Composer 的情况下完成此操作 - -- 只需设置一个 CIFilter 实例并将其应用到您的 NSImage 即可。编辑 - 或编写您自己的核心图像过滤器,从以下内容开始:
...它获取输入图像的红色通道的亮度 (
sample(image, samplerCoord(image)).r
),并将其用作colorForDark
和colorForLight
之间线性插值的系数。Take a look at the
False Color
patch — it takes an image and remaps it with a pair of colors.In fact, since the
False Color
patch is just a wrapper around the Core Image filter with the same name (CIFalseColor
), you could do this without involving Quartz Composer at all --- just set up and apply aCIFilter
instance to your NSImage.Edit — or write your own Core Image filter, starting with something like this:
...which takes the brightness of the red channel of the input image (
sample(image, samplerCoord(image)).r
), and uses it as a coefficient for linear interpolation betweencolorForDark
andcolorForLight
.