如何判断 UIImage 是彩色还是单色?
有没有办法确定 UIImage/(或任何其他格式的图像)是彩色还是单色?我的应用程序打算读取 UIImage(存储在照片应用程序中的图像),然后根据其色阶(彩色图像或灰度)对图像进行不同的处理。
Is there a way to find out if a UIImage/(Or the image in any other format) is colored or monochrome? My app intends to read a UIImage(image stored in the Photo app), and then do different set of processing on the image, based on its colorscale (colored image or gray scale).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找的是 UIImage 的颜色空间。您可以在此处找到答案。
单色空间是
任何其他颜色。
What you are looking for is the color space of the UIImage. You can find the answer here.
The mono color spaces are
Anything else is color.
请注意,“彩色”图像可能仍然只使用灰色阴影!单色图像可以以支持颜色的格式存储。
Note that a "color" image might still only use shades of gray! A monochrome image can be stored in a color-supporting format.