How do you convert a color image to a gray-scale image?

John Zukowski

Using the ColorSpace class, you can convert a multi-color image to gray with the following operation:

ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
ColorConvertOp op = new ColorConvertOp(cs, null);
BufferedImage grayImage = op.filter(colorImage, null);
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.