到CS_GRAY我知道它可以将图像转换使用的Java转换色彩空间而不使用ConvertColorOp
public static BufferedImage getGrayBufferedImage(BufferedImage image) {
BufferedImageOp op = new ColorConvertOp(ColorSpace
.getInstance(ColorSpace.CS_GRAY), null);
BufferedImage sourceImgGray = op.filter(image, null);
return sourceImgGray;
}
然而CS_GRAY,这是我整个程序的阻塞点。我需要经常这样做,在800x600像素的图像上,平均需要大约200-300ms才能完成此操作。我知道我可以更快地做到这一点,通过使用一个循环来遍历图像数据并立即设置它。另一方面,上面的代码构造了一个全新的800x600 BufferedImage,它是灰度级的。我宁愿只是转换我通过的图像。
是否有人知道如何使用for循环执行此操作,并且该图像是RGB色彩空间?