I need to zero out one of the color channels in an NSImage, whats the right way to do this?

时光怂恿深爱的人放手 提交于 2019-12-08 04:18:22

问题


I want to achieve the same result as if I were in photoshop and turned off one of the channels. I was about to try to loop through every pixel changing colors. Is there a better way to do this?


回答1:


Use Core Image's Color Matrix filter. The array of vectors can be bewildering, but it's very powerful. In your case, you'll want to set the vector for the channel you want to turn off to all-zeroes.

Obviously, this will only work for RGB images, since Core Image only works for RGB images. You can make it work for gray images (turn off R, G, and B to turn off the K channel), but not for CMYK.



来源:https://stackoverflow.com/questions/4230145/i-need-to-zero-out-one-of-the-color-channels-in-an-nsimage-whats-the-right-way

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!