CI过滤器,以创建Black&白色图像? [英] CI Filter to create Black & White image?

查看:157
本文介绍了CI过滤器,以创建Black&白色图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CIImage我需要从颜色转换为黑色和白色在我的Cocoa /目标C程序。 Peter H.曾指示我访问此链接 http:// www。它是一个潜在的解决方案...但我有麻烦编译内核程序那里(看到单独的线程,如果感兴趣)。

I have a CIImage I need to convert from color to Black and White within my Cocoa / objective C program. Peter H. previously pointed me to this link http://www.codingadventures.com/2008/06/threshold-filter-in-glsl/ as a potential solution ... but I am having trouble compiling the kernel routine there (see separate thread, if interested).

所以我想知道其他内置CIFilter是否会完成我想做的事情。我不想要一个灰度图像...我想要结果图像中的每个像素是黑色或白色 - 我只需要能够告诉过滤器如何确定哪些像素应变成黑色和哪些应该变成白色。 Photoshop中的阈值过滤器正是这样 - 它让我指定阈值,然后使用此值来决定哪些像素变为白色,哪些变为黑色。这是我想通过我的Xcode项目中的代码复制。

So I am wondering if one of the other built-in CIFilters will accomplish what I'm trying to do. I don't want a grayscale image ... I want each pixel in the Result image to be either Black or White -- I just need to be able to tell the filter how to determine which pixels should become black and which should become white. The "Threshold" filter in Photoshop does exactly this -- it lets me specify the "threshold" and then it uses this value to decide which pixels become white and which become black. This is what I am trying to "replicate" via code in my Xcode project.

任何想法如果其他内置的过滤器可以用于这个?感谢。

Any ideas if one of the other built in filters can be used for this? Thanks.

推荐答案

您可以使用 CIColorMap filter
给它一个20(w)by 1(h)jpg其中左半边是白色,右半边是黑色(或相反),并使用它作为你的颜色地图渐变。这似乎打破了颜色很好。我最初尝试一个2x1图像与1白色像素和一个黑色,但它看起来像它插入一点。

You can use the CIColorMap filter. Give it a 20(w) by 1(h) jpg where the left half is white and the right half is black (or the other way around) and use that as your color map gradient. That seems to hammer down the colors nicely. I originally tried a 2x1 image with 1 white pixel and one black, but it looked like it got interpolated a bit. I went up to 20x1 and it worked fine.

提示:我使用Core Image Funhouse(不是Quartz Composer)进行实验。

Hint: I used Core Image Funhouse (not Quartz Composer) to experiment.

这篇关于CI过滤器,以创建Black&白色图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆