核心图像CIImage 8位灰度

时间:2023-01-15 22:56:28

I want to do 2 things:
1) Load 8 bit grayscale image as 8 but grayscale image
2) Save it as 8 bit grayscale image

我想做两件事:1)将8位灰度图像加载为8但是灰度图像2)将其保存为8位灰度图像

I try to load image to CIImage via [CIImage imageWithContentsOfURL:options]`. As I understand I can specify some options in item options. But I didn't find any information how to do it. In reference of CIImage I found only these pixel formats:

我尝试通过[CIImage imageWithContentsOfURL:options]`将图像加载到CIImage。据我所知,我可以在项目选项中指定一些选项。但我没有找到任何信息如何做到这一点。在CIImage的参考中,我发现只有这些像素格式:

extern CIFormat kCIFormatARGB8;
extern CIFormat kCIFormatRGBA16;
extern CIFormat kCIFormatRGBAf;
extern CIFormat kCIFormatRGBAh;

What does it mean? I can't load and save 8 bit grayscale images via CIImage?

这是什么意思?我无法通过CIImage加载和保存8位灰度图像?

1 个解决方案

#1


1  

No, there's no format for 8 bit grayscale. What is it you're trying to do? There are other ways to create an image using 8-bit grayscale, but without more info, it's hard to tell you what to suggest.

不,没有8位灰度的格式。你想做什么?还有其他方法可以使用8位灰度来创建图像,但没有更多信息,很难告诉您要建议什么。

If you are going to use CoreImage to manipulate it, you'll need to put it into one of the RGB formats mentioned above. But if you're not going to use CoreImage to manipulate it, you might be able to create an NSImage (by creating an NSBitmapImageRep) or a CGImage (see CGImageCreate()) in the format you want.

如果您打算使用CoreImage来操作它,您需要将其置于上面提到的RGB格式之一。但是如果您不打算使用CoreImage来操作它,您可能能够以您想要的格式创建NSImage(通过创建NSBitmapImageRep)或CGImage(请参阅CGImageCreate())。

#1


1  

No, there's no format for 8 bit grayscale. What is it you're trying to do? There are other ways to create an image using 8-bit grayscale, but without more info, it's hard to tell you what to suggest.

不,没有8位灰度的格式。你想做什么?还有其他方法可以使用8位灰度来创建图像,但没有更多信息,很难告诉您要建议什么。

If you are going to use CoreImage to manipulate it, you'll need to put it into one of the RGB formats mentioned above. But if you're not going to use CoreImage to manipulate it, you might be able to create an NSImage (by creating an NSBitmapImageRep) or a CGImage (see CGImageCreate()) in the format you want.

如果您打算使用CoreImage来操作它,您需要将其置于上面提到的RGB格式之一。但是如果您不打算使用CoreImage来操作它,您可能能够以您想要的格式创建NSImage(通过创建NSBitmapImageRep)或CGImage(请参阅CGImageCreate())。