如何在颜色模型之间进行转换 [英] How to convert between color models
问题描述
我对图像处理很新。我有一个PNG图像(使用 ImageIO.read()
读取),当我调用<$时,它会产生 BufferedImage.TYPE_CUSTOM
c $ c> getType()就可以了。
I am very new to image processing. I have a PNG image (read using ImageIO.read()
) that yields BufferedImage.TYPE_CUSTOM
when I call getType()
on it.
BufferedImage bi = ImageIO.read(new URL("file:/C:/samp1.png"));
int type =bi.getType(); //TYPE_CUSTOM for samp1.png
现在我想将其转换为以下模型之一:
Now I would like to convert it to one of the following models:
- TYPE_USHORT_GRAY
- TYPE_3BYTE_BGR
- TYPE_BYTE_GRAY
- TYPE_INT_RGB
- TYPE_INT_ARGB
- TYPE_USHORT_GRAY
- TYPE_3BYTE_BGR
- TYPE_BYTE_GRAY
- TYPE_INT_RGB
- TYPE_INT_ARGB
以上需要完成使用仅识别上述类型的库进一步处理图像。
The above needs to be done to process the image further using a library that recognises only the above types.
如何将 TYPE_CUSTOM
颜色模型转换为其他模型?
How do I convert from TYPE_CUSTOM
color model to other models?
非常感谢任何帮助/指针。
如果没有任何现有的库可以执行此操作,那么任何链接/发布到步骤/算法都会很棒。
Any help/pointers would be much appreciated. If there aren't any existing library to do this, any link/post to steps/algorithm would be great.
推荐答案
你试过这个吗?
BufferedImage rgbImg = new BufferedImage(bi.getWidth(), bi.getHeight(), BufferedImage.TYPE_INT_RGB);
这篇关于如何在颜色模型之间进行转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!